macro_rules! topics {
(@tp_tys ( $dir:expr ) $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(@tp_tys ( $dir:expr ) omit_std=true; $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(@tp_tys ( $dir:expr ) omit_std=false; $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(@tp_tps ( $dir:expr ) $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(@tp_tps ( $dir:expr ) omit_std=true; $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(@tp_tps ( $dir:expr ) omit_std=false; $([[$($meta:meta)?] $tp_name:ident])*) => { ... };
(
list = $list_name:ident;
direction = $direction:expr;
$(omit_std = $omit:tt;)?
| TopicTy | MessageTy | Path | $( Cfg |)?
| $(-)* | $(-)* | $(-)* | $($(-)* |)?
$(| $tp_name:ident | $msg_ty:tt $(< $($msg_lt:lifetime),+ >)? | $path_str:literal | $($meta:meta)? $(|)?)*
) => { ... };
}
Expand description
ยงTopics macro
Used to define multiple Topic marker types that implements the Topic trait.
use postcard_rpc::{topics, TopicDirection};
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Message1 {
a: u8,
b: u64,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Message2 {
a: i8,
b: i64,
}
topics!{
list = TOPIC_LIST_NAME;
direction = TopicDirection::ToServer;
| TopicTy | MessageTy | Path |
| ------- | --------- | ---- |
| Topic1 | Message1 | "topics/one" |
| Topic2 | Message2 | "topics/two" |
}