RpcHandler

Trait RpcHandler 

Source
pub trait RpcHandler:
    Clone
    + Send
    + Sync
    + 'static {
    type Request: DeserializeOwned + Send + Sync + Display;

    // Required methods
    fn on_request<'life0, 'async_trait>(
        &'life0 self,
        request: Self::Request,
        original_call: RpcMethodCall,
    ) -> Pin<Box<dyn Future<Output = ResponseResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_call<'life0, 'async_trait>(
        &'life0 self,
        call: RpcMethodCall,
    ) -> Pin<Box<dyn Future<Output = RpcResponse> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_websocket<'life0, 'async_trait>(
        &'life0 self,
        socket: WebSocket,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Helper trait that is used to execute starknet rpc calls

Required Associated Types§

Source

type Request: DeserializeOwned + Send + Sync + Display

The request type to expect

Required Methods§

Source

fn on_request<'life0, 'async_trait>( &'life0 self, request: Self::Request, original_call: RpcMethodCall, ) -> Pin<Box<dyn Future<Output = ResponseResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Invoked when the request was received

Source

fn on_call<'life0, 'async_trait>( &'life0 self, call: RpcMethodCall, ) -> Pin<Box<dyn Future<Output = RpcResponse> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Invoked for every incoming RpcMethodCall

This will attempt to deserialize a { "method" : "<name>", "params": "<params>" } message into the Request type of this handler. If a Request instance was deserialized successfully, Self::on_request will be invoked.

Note: override this function if the expected Request deviates from { "method" : "<name>", "params": "<params>" }

Source

fn on_websocket<'life0, 'async_trait>( &'life0 self, socket: WebSocket, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles websocket connection, from start to finish.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§