-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(sails-rs): move ProgramMeta and ServiceMeta to new crate (#588)
- Loading branch information
1 parent
97cd872
commit 329b8c3
Showing
12 changed files
with
99 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "sails-idl-meta" | ||
description = "IDL meta information for the Sails framework" | ||
documentation = "https://docs.rs/sails-idl-gen" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
scale-info.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#![no_std] | ||
|
||
use scale_info::{prelude::vec::Vec, MetaType}; | ||
|
||
pub trait ServiceMeta { | ||
fn commands() -> MetaType; | ||
fn queries() -> MetaType; | ||
fn events() -> MetaType; | ||
fn base_services() -> impl Iterator<Item = AnyServiceMeta>; | ||
} | ||
|
||
pub struct AnyServiceMeta { | ||
commands: MetaType, | ||
queries: MetaType, | ||
events: MetaType, | ||
base_services: Vec<AnyServiceMeta>, | ||
} | ||
|
||
impl AnyServiceMeta { | ||
pub fn new<S: ServiceMeta>() -> Self { | ||
Self { | ||
commands: S::commands(), | ||
queries: S::queries(), | ||
events: S::events(), | ||
base_services: S::base_services().collect(), | ||
} | ||
} | ||
|
||
pub fn commands(&self) -> &MetaType { | ||
&self.commands | ||
} | ||
|
||
pub fn queries(&self) -> &MetaType { | ||
&self.queries | ||
} | ||
|
||
pub fn events(&self) -> &MetaType { | ||
&self.events | ||
} | ||
|
||
pub fn base_services(&self) -> impl Iterator<Item = &AnyServiceMeta> { | ||
self.base_services.iter() | ||
} | ||
} | ||
|
||
pub trait ProgramMeta { | ||
fn constructors() -> MetaType; | ||
fn services() -> impl Iterator<Item = (&'static str, AnyServiceMeta)>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters