pub trait PubSubRpcHandler:
Clone
+ Send
+ Sync
+ Unpin
+ 'static {
type Request: DeserializeOwned + Send + Sync + Debug;
type SubscriptionId: Hash + PartialEq + Eq + Send + Sync + Debug;
type Subscription: Stream<Item = Value> + Send + Sync + Unpin;
// Required method
fn on_request(
&self,
request: Self::Request,
cx: PubSubContext<Self>,
) -> impl Future<Output = ResponseResult> + Send;
// Provided methods
fn on_request_error(
&self,
_method: &str,
_id: &Id,
_params: &Value,
_error: &RpcError,
) { ... }
fn close_on_subscription_end(
&self,
_subscription: &Self::Subscription,
) -> bool { ... }
}Expand description
The general purpose trait for handling RPC requests and subscriptions
Required Associated Types§
Required Methods§
Sourcefn on_request(
&self,
request: Self::Request,
cx: PubSubContext<Self>,
) -> impl Future<Output = ResponseResult> + Send
fn on_request( &self, request: Self::Request, cx: PubSubContext<Self>, ) -> impl Future<Output = ResponseResult> + Send
Invoked when the request was received
Provided Methods§
Sourcefn on_request_error(
&self,
_method: &str,
_id: &Id,
_params: &Value,
_error: &RpcError,
)
fn on_request_error( &self, _method: &str, _id: &Id, _params: &Value, _error: &RpcError, )
Invoked when a deserialized request returns an error from Self::on_request.
Parameters retain their original shape with fork URL credentials redacted.
Deserialization errors are excluded because their messages can contain request parameters.
Sourcefn close_on_subscription_end(&self, _subscription: &Self::Subscription) -> bool
fn close_on_subscription_end(&self, _subscription: &Self::Subscription) -> bool
Whether an ended subscription requires closing the client connection.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".