Trait Dispatcher

Source
pub trait Dispatcher:
    Send
    + Sync
    + 'static {
    // Required methods
    fn dispatch<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        request: Request,
        tx: Option<&'life1 Sender<Message>>,
        id: u64,
        frame_type: Option<FrameType>,
    ) -> Pin<Box<dyn Future<Output = Option<ResponseAndSubScriptionNotifier>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn method_names(&self) -> Vec<&str>;

    // Provided method
    fn match_method(&self, _name: &str) -> bool { ... }
}
Expand description

A method dispatcher. These take a request and handle the method execution. Can be generated from an impl block using nimiq_jsonrpc_derive::service.

Required Methods§

Source

fn dispatch<'life0, 'life1, 'async_trait>( &'life0 mut self, request: Request, tx: Option<&'life1 Sender<Message>>, id: u64, frame_type: Option<FrameType>, ) -> Pin<Box<dyn Future<Output = Option<ResponseAndSubScriptionNotifier>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Calls the requested method with the request parameters and returns it’s return value (or error) as a response.

Source

fn method_names(&self) -> Vec<&str>

Returns the names of all methods matched by this dispatcher.

Provided Methods§

Source

fn match_method(&self, _name: &str) -> bool

Returns whether a method should be dispatched with this dispatcher.

§Arguments
  • name: The name of the method to be dispatched.
§Returns

true if this dispatcher can handle the method, false otherwise.

Implementors§