pub trait RpcHandler:
Clone
+ Send
+ Sync
+ 'static {
type Request: DeserializeOwned + Send + Sync + Debug;
// Required method
fn on_request(
&self,
request: Self::Request,
) -> impl Future<Output = ResponseResult> + Send;
// Provided method
fn on_call(
&self,
call: RpcMethodCall,
) -> impl Future<Output = RpcResponse> + Send { ... }
}Expand description
Helper trait that is used to execute ethereum rpc calls
Required Associated Types§
Required Methods§
Sourcefn on_request(
&self,
request: Self::Request,
) -> impl Future<Output = ResponseResult> + Send
fn on_request( &self, request: Self::Request, ) -> impl Future<Output = ResponseResult> + Send
Invoked when the request was received
Provided Methods§
Sourcefn on_call(
&self,
call: RpcMethodCall,
) -> impl Future<Output = RpcResponse> + Send
fn on_call( &self, call: RpcMethodCall, ) -> impl Future<Output = RpcResponse> + Send
Invoked for every incoming RpcMethodCall. Notifications are adapted to method calls
with an anvil_rpc::request::Id::Null identifier, and their responses are discarded.
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>" }
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".