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: IntoFuture<Item = Value, Error = Error>, I::Future: 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: IntoFuture<Item = Value, Error = Error>, I::Future: 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§

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

Source

pub fn add_subscription<Sub, Unsub, I>( &mut self, name: &str, subscribe: (&str, Sub), unsubscribe: (&str, Unsub), )
where Sub: Fn(&T, Params, M, Subscriber) + Send + Sync + 'static, Unsub: Fn(&T, SubscriptionId, Option<M>) -> I + Send + Sync + 'static, I: IntoFuture<Item = Value, Error = Error>, I::Future: Send + 'static,

Adds subscription to the delegate.

Trait Implementations§

Source§

impl<T, M> Into<HashMap<String, RemoteProcedure<M>>> for IoDelegate<T, M>
where T: Send + Sync + 'static, M: Metadata,

Source§

fn into(self) -> HashMap<String, RemoteProcedure<M>>

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

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

impl<T> Erased for T

OSZAR »