Skip to main content

RpcHandler

Trait RpcHandler 

Source
pub trait RpcHandler:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        method: Method,
        params: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, RpcError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn healthz<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn version(&self) -> String { ... }
}
Expand description

The node behind the RPC server.

Implemented by the DIG node; consumed by RpcServer.

Provided Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 self, method: Method, params: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a resolved method call, returning a result value or a canonical error. params is the raw JSON-RPC params (Null when absent) — the handler deserializes it into the method’s params type from dig_rpc_protocol::types.

The default implementation rejects every method with -32601, so a handler need only override the methods it actually serves (its profile).

Source

fn healthz<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Liveness probe backing the HTTP GET /healthz route. Ok(()) ⇒ the node can serve. Default: always healthy.

Source

fn version(&self) -> String

The node’s software/API version, embedded in the generated OpenRPC document served by rpc.discover. Default: this crate’s version.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§