jsonrpc_core::delegates

Struct IoDelegate

Source
pub struct IoDelegate<T, M = ()>
where T: Send + Sync + 'static, M: Metadata,
{ /* private fields */ }
Expand description

A set of RPC methods and notifications tied to single delegate struct.

Implementations§

Source§

impl<T, M> IoDelegate<T, M>
where T: Send + Sync + 'static, M: Metadata,

Source

pub fn new(delegate: Arc<T>) -> Self

Creates new IoDelegate

Source

pub fn add_alias(&mut self, from: &str, to: &str)

Adds an alias to existing method. NOTE: Aliases are not transitive, i.e. you cannot create alias to an alias.

Source

pub fn add_method<F, I>(&mut self, name: &str, method: F)
where F: Fn(&T, Params) -> I + Send + Sync + 'static, I: Future<Output = Result<Value, Error>> + Send + 'static,

Adds async method to the delegate.

Source

pub fn add_method_with_meta<F, I>(&mut self, name: &str, method: F)
where F: Fn(&T, Params, M) -> I + Send + Sync + 'static, I: Future<Output = Result<Value, Error>> + Send + 'static,

Adds async method with metadata to the delegate.

Source

pub fn add_notification<F>(&mut self, name: &str, notification: F)
where F: Fn(&T, Params) + Send + Sync + 'static,

Adds notification to the delegate.

Source

pub fn add_notification_with_meta<F>(&mut self, name: &str, notification: F)
where F: Fn(&T, Params, M) + Send + Sync + 'static,

Adds notification with metadata to the delegate.

Trait Implementations§

Source§

impl<T, M> IntoIterator for IoDelegate<T, M>
where T: Send + Sync + 'static, M: Metadata,

Source§

type Item = (String, RemoteProcedure<M>)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<String, RemoteProcedure<M>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, M> IoHandlerExtension<M> for IoDelegate<T, M>
where T: Send + Sync + 'static, M: Metadata,

Source§

fn augment<S: Middleware<M>>(self, handler: &mut MetaIoHandler<M, S>)

Extend given handler with additional methods.

Auto Trait Implementations§

§

impl<T, M> Freeze for IoDelegate<T, M>

§

impl<T, M = ()> !RefUnwindSafe for IoDelegate<T, M>

§

impl<T, M> Send for IoDelegate<T, M>

§

impl<T, M> Sync for IoDelegate<T, M>

§

impl<T, M> Unpin for IoDelegate<T, M>

§

impl<T, M = ()> !UnwindSafe for IoDelegate<T, M>

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