pub trait RpcHandler:
RpcService<JsonRpcRequest, JsonRpcResponse>
+ RpcService<BinRequest, BinResponse>
+ RpcService<OtherRequest, OtherResponse> {
// Required method
fn is_restricted(&self) -> bool;
}Expand description
An RPC handler.
This trait represents a type that can turn Requests into Responses.
Implementors of this trait must be:
- A
tower::Servicethat usesJsonRpcRequest&JsonRpcResponse - A
tower::Servicethat usesBinRequest&BinResponse - A
tower::Servicethat usesOtherRequest&OtherResponse
In other words, an RpcHandler is a type that implements tower::Service 3 times,
one for each request/response enum type found in cuprate_rpc_types.
The error type must always be anyhow::Error.
See this crate’s RpcHandlerDummy for an implementation example of this trait.
§Panics
Your RpcHandler must reply to Requests with the correct
Response or else this crate will panic during routing functions.
For example, a JsonRpcRequest::GetBlockCount must be replied with
JsonRpcResponse::GetBlockCount. If anything else is returned,
this crate may panic.
Required Methods§
Sourcefn is_restricted(&self) -> bool
fn is_restricted(&self) -> bool
Is this RpcHandler restricted?
If this returns true, restricted methods and endpoints such as:
/json_rpc’srelay_txmethod- The
/pop_blocksendpoint
will automatically be denied access when using the
axum::Router provided by RouterBuilder.
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.