pub struct PubSubHandler<T: PubSubMetadata, S: Middleware<T> = NoopMiddleware> { /* 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)
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<FutureResult<Option<Response>, ()>, <S as Middleware<T>>::Future>, fn(Option<Response>) -> Option<String>>
pub fn handle_request( &self, request: &str, meta: T, ) -> Map<Either<FutureResult<Option<Response>, ()>, <S as Middleware<T>>::Future>, fn(Option<Response>) -> Option<String>>
Handle given request asynchronously.
Sourcepub fn handle_rpc_request(
&self,
request: Request,
meta: T,
) -> <S as Middleware<T>>::Future
pub fn handle_rpc_request( &self, request: Request, meta: T, ) -> <S as Middleware<T>>::Future
Handle deserialized RPC request.
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.
Auto Trait Implementations§
impl<T, S> Freeze for PubSubHandler<T, S>where
S: Freeze,
impl<T, S = Noop> !RefUnwindSafe for PubSubHandler<T, S>
impl<T, S> Send for PubSubHandler<T, S>
impl<T, S> Sync for PubSubHandler<T, S>
impl<T, S> Unpin for PubSubHandler<T, S>where
S: Unpin,
impl<T, S = Noop> !UnwindSafe for PubSubHandler<T, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more