macro_rules! flowey_request {
(
$(#[$root_a:meta])*
pub enum_struct $req:ident {
$($tt:tt)*
}
) => { ... };
(
$(#[$a:meta])*
pub enum $req:ident {
$($tt:tt)*
}
) => { ... };
(
$(#[$a:meta])*
pub struct $req:ident {
$($tt:tt)*
}
) => { ... };
(
$(#[$a:meta])*
pub struct $req:ident($($tt:tt)*);
) => { ... };
}Expand description
Declare a new Request type for the current Node.
§struct and enum Requests
When wrapping a vanilla Rust struct and enum declaration, this macro
simply derives Serialize, Deserialize, and IntoRequest for the
type, and does nothing else.
§enum_struct Requests
This macro also supports a special kind of enum_struct derive, which
allows declaring a Request enum where each variant is split off into its own
separate (named) struct.
e.g:
ⓘ
flowey_request! {
pub enum_struct Foo {
Bar,
Baz(pub usize),
Qux(pub String),
}
}will be expanded into:
ⓘ
#[derive(Serialize, Deserialize)]
pub enum Foo {
Bar(req::Bar),
Baz(req::Baz),
Qux(req::Qux),
}
pud mod req {
#[derive(Serialize, Deserialize)]
pub struct Bar;
#[derive(Serialize, Deserialize)]
pub struct Baz(pub usize);
#[derive(Serialize, Deserialize)]
pub struct Qux(pub String);
}