pub trait RpcHandler:
RpcService<JsonRpcRequest, JsonRpcResponse>
+ RpcService<BinRequest, BinResponse>
+ RpcService<OtherRequest, OtherResponse> {
// Required method
fn restricted(&self) -> bool;
}
Expand description
An RPC handler.
This trait represents a type that can turn Request
s into Response
s.
Implementors of this trait must be:
- A
tower::Service
that usesJsonRpcRequest
&JsonRpcResponse
- A
tower::Service
that usesBinRequest
&BinResponse
- A
tower::Service
that 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 Request
s 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 restricted(&self) -> bool
fn restricted(&self) -> bool
Is this RpcHandler
restricted?
If this returns true
, restricted methods and endpoints such as:
/json_rpc
’srelay_tx
method- The
/pop_blocks
endpoint
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.