pub struct PubSubHandler<T, S = Noop>where
T: PubSubMetadata,
S: Middleware<T>,{ /* private fields */ }
Expand description
Publish-Subscribe extension of IoHandler
.
Implementations§
Source§impl<T, S> PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
impl<T, S> PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
Sourcepub fn new(handler: MetaIoHandler<T, S>) -> PubSubHandler<T, S>
pub fn new(handler: MetaIoHandler<T, S>) -> PubSubHandler<T, S>
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.
Trait Implementations§
Source§impl<T> Default for PubSubHandler<T>where
T: PubSubMetadata,
impl<T> Default for PubSubHandler<T>where
T: PubSubMetadata,
Source§fn default() -> PubSubHandler<T>
fn default() -> PubSubHandler<T>
Source§impl<T, S> Deref for PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
impl<T, S> Deref for PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
Source§type Target = MetaIoHandler<T, S>
type Target = MetaIoHandler<T, S>
Source§impl<T, S> DerefMut for PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
impl<T, S> DerefMut for PubSubHandler<T, S>where
T: PubSubMetadata,
S: Middleware<T>,
Source§impl<M> Handler for PubSubHandler<M>
impl<M> Handler for PubSubHandler<M>
Source§type Metadata = M
type Metadata = M
Source§fn 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,
Source§fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G),
)where
F: SubscribeRpcMethod<M>,
G: UnsubscribeRpcMethod<M>,
fn add_subscription<F, G>(
&mut self,
notification: &str,
subscribe: (&str, F),
unsubscribe: (&str, G),
)where
F: SubscribeRpcMethod<M>,
G: UnsubscribeRpcMethod<M>,
Source§fn as_meta_io_handler(&self) -> MetaIoHandler<Self::Metadata>
fn as_meta_io_handler(&self) -> MetaIoHandler<Self::Metadata>
MetaIoHandler
.Source§fn describe_api(&self) -> Vec<String>
fn describe_api(&self) -> Vec<String>
Source§fn handle_request_sync(
&self,
request: &str,
meta: Self::Metadata,
) -> Option<String>
fn handle_request_sync( &self, request: &str, meta: Self::Metadata, ) -> Option<String>
Source§fn metadata_from_sender(sender: UnboundedSender<String>) -> Self::Metadata
fn metadata_from_sender(sender: UnboundedSender<String>) -> Self::Metadata
Self::Metadata
associated type from an UnboundedSender
.