pub trait RpcHandler: Clone + Send + Sync + 'static {
type Request: DeserializeOwned + Send + Sync + Debug;
// Required method
fn on_request<'life0, 'async_trait>(
&'life0 self,
request: Self::Request
) -> Pin<Box<dyn Future<Output = ResponseResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
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 { ... }
}Expand description
Helper trait that is used to execute starknet rpc calls
Required Associated Types§
Required Methods§
sourcefn on_request<'life0, 'async_trait>(
&'life0 self,
request: Self::Request
) -> Pin<Box<dyn Future<Output = ResponseResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_request<'life0, 'async_trait>(
&'life0 self,
request: Self::Request
) -> Pin<Box<dyn Future<Output = ResponseResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Invoked when the request was received
Provided Methods§
sourcefn 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_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>" }
Object Safety§
This trait is not object safe.