Struct jsonrpc_pubsub::PubSubHandler
source · [−]pub struct PubSubHandler<T: PubSubMetadata, S: Middleware<T> = Noop> { /* private fields */ }
Expand description
Publish-Subscribe extension of IoHandler
.
Implementations
sourceimpl<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_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: IntoIterator<Item = (String, RemoteProcedure<T>)>,
pub fn extend_with<F>(&mut self, methods: F) where
F: IntoIterator<Item = (String, RemoteProcedure<T>)>,
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
sourceimpl<T: PubSubMetadata> Default for PubSubHandler<T>
impl<T: PubSubMetadata> Default for PubSubHandler<T>
sourceimpl<T: PubSubMetadata, S: Middleware<T>> Deref for PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> Deref for PubSubHandler<T, S>
type Target = MetaIoHandler<T, S>
type Target = MetaIoHandler<T, S>
The resulting type after dereferencing.
sourceimpl<T: PubSubMetadata, S: Middleware<T>> DerefMut for PubSubHandler<T, S>
impl<T: PubSubMetadata, S: Middleware<T>> DerefMut for PubSubHandler<T, S>
sourceimpl<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>
sourcefn into(self) -> MetaIoHandler<T, S>
fn into(self) -> MetaIoHandler<T, S>
Performs the conversion.
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more