Trait witty_jsonrpc::handler::Handler
source · pub trait Handler {
type Metadata: PubSubMetadata + Unpin + Debug;
// Required methods
fn add_method<F>(&mut self, name: &str, method: F)
where F: RpcMethodSimple;
fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G)
)
where F: SubscribeRpcMethod<Self::Metadata>,
G: UnsubscribeRpcMethod<Self::Metadata>;
fn as_meta_io_handler(&self) -> MetaIoHandler<Self::Metadata>;
fn describe_api(&self) -> Vec<String>;
fn handle_request_sync(
&self,
request: &str,
meta: Self::Metadata
) -> Option<String>;
fn metadata_from_sender(sender: UnboundedSender<String>) -> Self::Metadata;
fn new() -> Self;
}Expand description
Trait that abstracts away different implementations of IO handlers.
Required Associated Types§
sourcetype Metadata: PubSubMetadata + Unpin + Debug
type Metadata: PubSubMetadata + Unpin + Debug
The type to use as the metadata for the IO handler. Especially relevant for PubSub.
Required Methods§
sourcefn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
fn add_method<F>(&mut self, name: &str, method: F)where F: RpcMethodSimple,
Add a JSON-RPC method.
sourcefn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G)
)where
F: SubscribeRpcMethod<Self::Metadata>,
G: UnsubscribeRpcMethod<Self::Metadata>,
fn add_subscription<F, G>( &mut self, notification: &str, subscribe: (&str, F), unsubscribe: (&str, G) )where F: SubscribeRpcMethod<Self::Metadata>, G: UnsubscribeRpcMethod<Self::Metadata>,
Add a JSON-RPC subscription.
sourcefn as_meta_io_handler(&self) -> MetaIoHandler<Self::Metadata>
fn as_meta_io_handler(&self) -> MetaIoHandler<Self::Metadata>
Cast this down to an instance of MetaIoHandler.
sourcefn describe_api(&self) -> Vec<String>
fn describe_api(&self) -> Vec<String>
Get a list of all the supported JSON-RPC methods.
sourcefn handle_request_sync(
&self,
request: &str,
meta: Self::Metadata
) -> Option<String>
fn handle_request_sync( &self, request: &str, meta: Self::Metadata ) -> Option<String>
Programmatically trigger the handling of a JSON-RPC message. TODO: support async
sourcefn metadata_from_sender(sender: UnboundedSender<String>) -> Self::Metadata
fn metadata_from_sender(sender: UnboundedSender<String>) -> Self::Metadata
Derive an instance of the Self::Metadata associated type from an UnboundedSender.