Struct appliance::Appliance[][src]

pub struct Appliance<'s, S> { /* fields omitted */ }

A stateful entity that only allows to interact with via sending messages.

The appliance itself is not directly available. Messages must be sent to it using its descriptor which is returned by the Appliance::new_bounded and Appliance::new_unbounded methods, and can also be obtained from &Appliance using Appliance::descriptor method. Note that the latter route is generally available only for message handler Handler implementations.

Implementations

impl<'s, S> Appliance<'s, S> where
    S: Send + 's, 
[src]

pub fn new_bounded(
    executor: &'s Executor<'s>,
    state: S,
    size: usize
) -> Descriptor<'s, Self>
[src]

Creates a new appliance with a bounded message buffer, a state, and a handler.

pub fn new_unbounded(
    executor: &'s Executor<'s>,
    state: S
) -> Descriptor<'s, Self>
[src]

Creates a new appliance with an unbounded message buffer, a state, and a handler. It’s not recommended to use this version of appliance in production just like any other memory unbounded contruct.

pub fn descriptor(&'s self) -> Option<Descriptor<'s, Self>>[src]

Returns a descriptor object of the appliance.

Any descriptor is a cloneable object which allows to send messages to the appliance.

This function will return None if all appliance descriptors have already been dropped. In this case the appliance becomes unusable.

pub fn state(&mut self) -> &mut S[src]

The mutable inner state of the appliance.

Note that this function requires mutable access to the appliance itself (not its descriptor), but the appliance object is never returned by the API. The only place where the appliance can be accessed is the implementation of Handler and HandledBy traits for the message types, which is thus also the only place where one can (and should) mutate its state.

Trait Implementations

impl<'s, S: Debug + 's> Debug for Appliance<'s, S>[src]

Auto Trait Implementations

impl<'s, S> !RefUnwindSafe for Appliance<'s, S>

impl<'s, S> Send for Appliance<'s, S> where
    S: Send

impl<'s, S> Sync for Appliance<'s, S> where
    S: Sync

impl<'s, S> Unpin for Appliance<'s, S> where
    S: Unpin

impl<'s, S> !UnwindSafe for Appliance<'s, S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.