Expand description
§netxbuilder — proc-macro code generation for the netx RPC framework
This crate provides four proc-macro attributes:
| Attribute | Where used | Purpose |
|---|---|---|
#[build_client] | trait | Generate client proxy struct + optional dispatcher |
#[build_server] | trait | Generate server-push proxy + optional dispatcher |
#[build_impl] | impl block | Marker (no-op); validates the impl block parses |
#[build_impl_client] | impl block | Same as above + adds #[async_trait::async_trait] |
#[tag(N)] | trait method | Assigns a command ID; consumed by the above macros |
§How it all fits together
User writes:
#[build_client(ClientController)] ← "I am the server; clients implement this"
pub trait IClientController {
#[tag(2001)]
async fn on_message(&self, from: String, text: String); // tt=0: fire-and-forget
#[tag(2002)]
async fn on_ping(&self, t: i64) -> Result<i64>; // tt=2: returns a value
}
Macro generates:
1. The trait itself (with #[async_trait])
2. impl IController for ClientController { fn call(...) { match cmd_tag { ... } } }
— deserialises arguments and dispatches to the correct method
3. pub struct ___impl_IClientController_call<T> { client: T }
— a proxy struct that can be used as `impl IClientController`Attribute Macros§
- build_
client - Generate the client-side interface infrastructure from a
traitdefinition. - build_
impl - Marker attribute for server-side
implblocks. - build_
impl_ client - Marker attribute for client-side
implblocks. - build_
server - Generate the server-side push interface from a
traitdefinition. - tag
- Pass-through attribute that assigns a command ID to a trait method.