Skip to main content

Crate moonpool_transport_derive

Crate moonpool_transport_derive 

Source
Expand description

Proc-macros for moonpool RPC interfaces.

This crate provides the #[service] attribute macro for generating RPC server/client boilerplate from a trait definition.

§Example

use moonpool_transport::{service, RpcError};

#[service(id = 0xCA1C_0000)]
trait Calculator {
    async fn add(&self, req: AddRequest) -> Result<AddResponse, RpcError>;
    async fn sub(&self, req: SubRequest) -> Result<SubResponse, RpcError>;
}

This generates:

  • CalculatorServer<C> with RequestStream fields, init(), and serve()
  • CalculatorClient with ServiceEndpoint fields for each method
  • The trait itself with #[async_trait(?Send)]

Attribute Macros§

service
Attribute macro for defining RPC service interfaces.