macro_rules! endpoints {
(@ep_tys $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(@ep_tys omit_std=true; $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(@ep_tys omit_std=false; $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(@ep_eps $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(@ep_eps omit_std=true; $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(@ep_eps omit_std=false; $([[$($meta:meta)?] $ep_name:ident])*) => { ... };
(
list = $list_name:ident;
$(omit_std = $omit:tt;)?
| EndpointTy | RequestTy | ResponseTy | Path | $( Cfg |)?
| $(-)* | $(-)* | $(-)* | $(-)* | $($(-)* |)?
$( | $ep_name:ident | $req_ty:tt $(< $($req_lt:lifetime),+ >)? | $resp_ty:tt $(< $($resp_lt:lifetime),+ >)? | $path_str:literal | $($meta:meta)? $(|)? )*
) => { ... };
}
Expand description
ยงEndpoints macro
Used to define multiple Endpoint marker types that implements the Endpoint trait.
use postcard_rpc::endpoints;
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Req1 {
a: u8,
b: u64,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Resp1 {
c: [u8; 4],
d: i32,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Req2 {
a: i8,
b: i64,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Resp2 {
c: [i8; 4],
d: u32,
}
endpoints!{
list = ENDPOINTS_LIST;
| EndpointTy | RequestTy | ResponseTy | Path |
| ---------- | --------- | ---------- | ---- |
| Endpoint1 | Req1 | Resp1 | "endpoints/one" |
| Endpoint2 | Req2 | Resp2 | "endpoints/two" |
}