Trait RpcServiceT
pub trait RpcServiceT {
// Required methods
fn call<'a>(
&self,
request: Request<'a>,
) -> impl Future<Output = MethodResponse> + Send + 'a;
fn batch<'a>(
&self,
requests: Batch<'a>,
) -> impl Future<Output = MethodResponse> + Send + 'a;
fn notification<'a>(
&self,
n: Notification<'a, Option<Cow<'a, RawValue>>>,
) -> impl Future<Output = MethodResponse> + Send + 'a;
}Expand description
Represent a JSON-RPC service that can process JSON-RPC calls, notifications, and batch requests.
This trait is similar to [tower::Service] but it’s specialized for JSON-RPC operations.
Required Methods§
fn call<'a>(
&self,
request: Request<'a>,
) -> impl Future<Output = MethodResponse> + Send + 'a
fn call<'a>( &self, request: Request<'a>, ) -> impl Future<Output = MethodResponse> + Send + 'a
Processes a single JSON-RPC call, which may be a subscription or regular call.
fn batch<'a>(
&self,
requests: Batch<'a>,
) -> impl Future<Output = MethodResponse> + Send + 'a
fn batch<'a>( &self, requests: Batch<'a>, ) -> impl Future<Output = MethodResponse> + Send + 'a
Processes multiple JSON-RPC calls at once, similar to RpcServiceT::call.
This method wraps RpcServiceT::call and RpcServiceT::notification,
but the root RPC service does not inherently recognize custom implementations
of these methods.
As a result, if you have custom logic for individual calls or notifications, you must duplicate that implementation in this method or no middleware will be applied for calls inside the batch.
fn notification<'a>(
&self,
n: Notification<'a, Option<Cow<'a, RawValue>>>,
) -> impl Future<Output = MethodResponse> + Send + 'a
fn notification<'a>( &self, n: Notification<'a, Option<Cow<'a, RawValue>>>, ) -> impl Future<Output = MethodResponse> + Send + 'a
Similar to RpcServiceT::call but processes a JSON-RPC notification.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".