jsonrpc_pubsub

Struct 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>

Source

pub fn new(handler: MetaIoHandler<T, S>) -> Self

Creates new PubSubHandler

Source

pub fn add_subscription<F, G>( &mut self, notification: &str, subscribe: (&str, F), unsubscribe: (&str, G), )

Adds new subscription.

Methods from Deref<Target = MetaIoHandler<T, S>>§

Source

pub fn add_alias(&mut self, alias: &str, other: &str)

Adds an alias to a method.

Source

pub fn add_sync_method<F>(&mut self, name: &str, method: F)
where F: RpcMethodSync,

Adds new supported synchronous method.

A backward-compatible wrapper.

Source

pub fn add_method<F>(&mut self, name: &str, method: F)
where F: RpcMethodSimple,

Adds new supported asynchronous method.

Source

pub fn add_notification<F>(&mut self, name: &str, notification: F)

Adds new supported notification

Source

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.

Source

pub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)
where F: RpcNotification<T>,

Adds new supported notification with metadata support.

Source

pub fn extend_with<F>(&mut self, methods: F)
where F: IntoIterator<Item = (String, RemoteProcedure<T>)>,

Extend this MetaIoHandler with methods defined elsewhere.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &RemoteProcedure<T>)>

Returns an iterator visiting all methods in arbitrary order.

Trait Implementations§

Source§

impl<T: PubSubMetadata> Default for PubSubHandler<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: PubSubMetadata, S: Middleware<T>> DerefMut for PubSubHandler<T, S>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: PubSubMetadata, S: Middleware<T>> Into<MetaIoHandler<T, S>> for PubSubHandler<T, S>

Source§

fn into(self) -> MetaIoHandler<T, S>

Converts this type into the (usually inferred) input type.
Source§

impl<T: PubSubMetadata, S: Middleware<T>> Deref for PubSubHandler<T, S>

Source§

type Target = MetaIoHandler<T, S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V