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,

§

type Item = (String, RemoteProcedure<M>)

The type of the elements being iterated over.
§

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 = ()> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.