pub trait RpcHandler: Send + Sync {
// Required methods
fn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
proc: u32,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn prog_vers(&self) -> ProgVers;
}Expand description
Trait for implementing RPC service handlers.
Implement this trait to define how your service handles incoming RPC
calls. Generated protocol dispatchers implement it; hand-written services
can too. Register handlers with rpc_driver::ServiceMap and pass the map
to rpc_driver::RpcServer.
For bidirectional RPC (calling back to the peer from within a handler),
use rpc_driver::peer() to obtain the per-connection sender.
With the driver’s default serial dispatch, calling back to the peer
inline will deadlock — spawn a separate task instead. With the driver’s
concurrent-dispatch feature enabled, inline callbacks work without
deadlocking.
Required Methods§
Sourcefn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
proc: u32,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn dispatch<'life0, 'life1, 'async_trait>(
&'life0 self,
proc: u32,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle an incoming RPC call for the given procedure number.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".