JsonRpcHandler

Trait JsonRpcHandler 

Source
pub trait JsonRpcHandler: Send + Sync {
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        params: Option<RequestParams>,
        session_context: Option<SessionContext>,
    ) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn handle_notification<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        params: Option<RequestParams>,
        session_context: Option<SessionContext>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn supported_methods(&self) -> Vec<String> { ... }
}
Expand description

Trait for handling JSON-RPC method calls

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned by this handler

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, params: Option<RequestParams>, session_context: Option<SessionContext>, ) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a JSON-RPC method call with optional session context Returns domain errors only - dispatcher handles conversion to JSON-RPC errors

Provided Methods§

Source

fn handle_notification<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, params: Option<RequestParams>, session_context: Option<SessionContext>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a JSON-RPC notification with optional session context (optional - default does nothing)

Source

fn supported_methods(&self) -> Vec<String>

List supported methods (optional - used for introspection)

Implementors§

Source§

impl<F, N, E> JsonRpcHandler for FunctionHandler<F, N, E>
where E: Error + Send + Sync + 'static, F: Fn(&str, Option<RequestParams>, Option<SessionContext>) -> BoxFuture<'static, Result<Value, E>> + Send + Sync, N: Fn(&str, Option<RequestParams>, Option<SessionContext>) -> BoxFuture<'static, Result<(), E>> + Send + Sync,

Source§

type Error = E