Struct jsonrpc_pubsub::PubSubHandler
source · pub struct PubSubHandler<T: PubSubMetadata, S: Middleware<T> = Noop> { /* private fields */ }Expand description
Publish-Subscribe extension of IoHandler.
Implementations§
source§impl<T: PubSubMetadata, S: Middleware<T>> PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> PubSubHandler<T, S>
sourcepub fn new(handler: MetaIoHandler<T, S>) -> Self
pub fn new(handler: MetaIoHandler<T, S>) -> Self
Creates new PubSubHandler
sourcepub fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G)
)where
F: SubscribeRpcMethod<T>,
G: UnsubscribeRpcMethod,
pub fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G)
)where
F: SubscribeRpcMethod<T>,
G: UnsubscribeRpcMethod,
Adds new subscription.
Methods from Deref<Target = MetaIoHandler<T, S>>§
sourcepub fn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
pub fn add_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSimple,
Adds new supported asynchronous method
sourcepub fn add_notification<F>(&mut self, name: &str, notification: F)where
F: RpcNotificationSimple,
pub fn add_notification<F>(&mut self, name: &str, notification: F)where
F: RpcNotificationSimple,
Adds new supported notification
sourcepub fn add_method_with_meta<F>(&mut self, name: &str, method: F)where
F: RpcMethod<T>,
pub fn add_method_with_meta<F>(&mut self, name: &str, method: F)where
F: RpcMethod<T>,
Adds new supported asynchronous method with metadata support.
sourcepub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)where
F: RpcNotification<T>,
pub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)where
F: RpcNotification<T>,
Adds new supported notification with metadata support.
sourcepub fn extend_with<F>(&mut self, methods: F)where
F: Into<HashMap<String, RemoteProcedure<T>, RandomState>>,
pub fn extend_with<F>(&mut self, methods: F)where
F: Into<HashMap<String, RemoteProcedure<T>, RandomState>>,
Extend this MetaIoHandler with methods defined elsewhere.
sourcepub fn handle_request_sync(&self, request: &str, meta: T) -> Option<String>
pub fn handle_request_sync(&self, request: &str, meta: T) -> Option<String>
Handle given request synchronously - will block until response is available.
If you have any asynchronous methods in your RPC it is much wiser to use
handle_request instead and deal with asynchronous requests in a non-blocking fashion.
sourcepub fn handle_request(
&self,
request: &str,
meta: T
) -> Map<Either<FutureResult<Option<Response>, ()>, Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Vec<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, Global>>, fn(_: Vec<Option<Output>, Global>) -> Option<Response>>>>>, fn(_: Option<Response>) -> Option<String>>
pub fn handle_request(
&self,
request: &str,
meta: T
) -> Map<Either<FutureResult<Option<Response>, ()>, Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Vec<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, Global>>, fn(_: Vec<Option<Output>, Global>) -> Option<Response>>>>>, fn(_: Option<Response>) -> Option<String>>
Handle given request asynchronously.
sourcepub fn handle_rpc_request(
&self,
request: Request,
meta: T
) -> Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Vec<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, Global>>, fn(_: Vec<Option<Output>, Global>) -> Option<Response>>>>
pub fn handle_rpc_request(
&self,
request: Request,
meta: T
) -> Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Vec<Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>, Global>>, fn(_: Vec<Option<Output>, Global>) -> Option<Response>>>>
Handle deserialized RPC request.
sourcepub fn handle_call(
&self,
call: Call,
meta: T
) -> Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>
pub fn handle_call(
&self,
call: Call,
meta: T
) -> Either<<S as Middleware<T>>::CallFuture, Either<Box<dyn Future<Error = (), Item = Option<Output>> + Send + 'static, Global>, FutureResult<Option<Output>, ()>>>
Handle single call asynchronously.
Trait Implementations§
source§impl<T: PubSubMetadata> Default for PubSubHandler<T>
impl<T: PubSubMetadata> Default for PubSubHandler<T>
source§impl<T: PubSubMetadata, S: Middleware<T>> Deref for PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> Deref for PubSubHandler<T, S>
source§impl<T: PubSubMetadata, S: Middleware<T>> DerefMut for PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> DerefMut for PubSubHandler<T, S>
source§impl<T: PubSubMetadata, S: Middleware<T>> Into<MetaIoHandler<T, S>> for PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> Into<MetaIoHandler<T, S>> for PubSubHandler<T, S>
source§fn into(self) -> MetaIoHandler<T, S>
fn into(self) -> MetaIoHandler<T, S>
Converts this type into the (usually inferred) input type.