Skip to main content

service

Attribute Macro service 

Source
#[service]
Expand description

Marks a trait as a vox RPC service and generates all service code.

§Generated Items

For a trait named Calculator, this generates:

  • mod calculator containing:
    • pub use of common types (Tx, Rx, VoxError, etc.)
    • mod method_id with lazy method ID functions
    • trait Calculator - the service trait
    • struct CalculatorDispatcher<H> - server-side dispatcher
    • struct CalculatorClient - client for making calls

§Example

#[vox::service]
trait Calculator {
    async fn add(&self, a: i32, b: i32) -> i32;
}