Struct appliance::Appliance [−][src]
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]
S: Send + 's,
pub fn new_bounded(
executor: &'s Executor<'s>,
state: S,
size: usize
) -> Descriptor<'s, Self>
[src]
executor: &'s Executor<'s>,
state: S,
size: usize
) -> Descriptor<'s, Self>
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]
executor: &'s Executor<'s>,
state: S
) -> Descriptor<'s, Self>
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
Auto Trait Implementations
impl<'s, S> !RefUnwindSafe for Appliance<'s, S>
impl<'s, S> Send for Appliance<'s, S> where
S: Send,
S: Send,
impl<'s, S> Sync for Appliance<'s, S> where
S: Sync,
S: Sync,
impl<'s, S> Unpin for Appliance<'s, S> where
S: Unpin,
S: Unpin,
impl<'s, S> !UnwindSafe for Appliance<'s, S>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,