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<T>,
pub fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G),
)where
F: SubscribeRpcMethod<T>,
G: UnsubscribeRpcMethod<T>,
Adds new subscription.
Methods from Deref<Target = MetaIoHandler<T, S>>§
Sourcepub fn add_sync_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSync,
pub fn add_sync_method<F>(&mut self, name: &str, method: F)where
F: RpcMethodSync,
Adds new supported synchronous method.
A backward-compatible wrapper.
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)
pub fn extend_with<F>(&mut self, methods: F)
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<Ready<Option<Response>>, Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>>, fn(_: Vec<Option<Output>>) -> Option<Response>>>>>, fn(_: Option<Response>) -> Option<String>>
pub fn handle_request( &self, request: &str, meta: T, ) -> Map<Either<Ready<Option<Response>>, Either<<S as Middleware<T>>::Future, Either<Map<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>>, fn(_: Vec<Option<Output>>) -> 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<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>>, fn(_: Vec<Option<Output>>) -> 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<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>, fn(_: Option<Output>) -> Option<Response>>, Map<JoinAll<Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>>, fn(_: Vec<Option<Output>>) -> Option<Response>>>>
Handle deserialized RPC request.
Sourcepub fn handle_call(
&self,
call: Call,
meta: T,
) -> Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>
pub fn handle_call( &self, call: Call, meta: T, ) -> Either<<S as Middleware<T>>::CallFuture, Either<Pin<Box<dyn Future<Output = Option<Output>> + Send>>, Ready<Option<Output>>>>
Handle single call asynchronously.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>
Returns an iterator visiting all methods in arbitrary order.