Struct theatre::prelude::Addr[][src]

pub struct Addr<A> where
    A: 'static + Actor
{ /* fields omitted */ }

An Address to an Actor. Actor addresses allow for messages to be sent to actors.

A message must implement Messageand the actor that should receive it needs to implement Handler<M> where M is the message type.

Addresses are parametrized over the Actor they point to. To obtain an address that is parametrized over the message type call recipient().

Addresses keep actors running. Once all addresses are dropped the actor will stop. To obtain an address to an actor without keeping it alive call downgrade() to get a WeakAddr (similar to Arc & WeakArc).

Implementations

impl<A> Addr<A> where
    A: Actor + Send
[src]

pub async fn send<M>(&mut self, msg: M) -> Result<M::Return, TheatreError> where
    A: Handler<M>,
    M: Message + 'static, 
[src]

Send a message and wait for the response. If the mailbox is full wait until there is capacity.

pub async fn try_send<M>(&mut self, msg: M) -> Result<M::Return, TheatreError> where
    A: Handler<M>,
    M: Message + 'static, 
[src]

Try send a message and wait for the response. If the mailbox is full or dropped return an error.

pub fn try_send_and_forget<M>(&mut self, msg: M) -> Result<(), TheatreError> where
    A: Handler<M>,
    M: Message + 'static, 
[src]

Try to send a message and discard the result. If the mailbox is full or dropped return an error.

pub fn recipient<M>(self) -> Recipient<M> where
    A: Handler<M>,
    M: 'static + Message
[src]

Obtain a recipient to the actor.

pub fn downgrade(&self) -> WeakAddr<A>[src]

Downgrade the address into a WeakAddr

Trait Implementations

impl<A> Clone for Addr<A> where
    A: Actor
[src]

impl<A> Debug for Addr<A> where
    A: Actor
[src]

impl<A> Drop for Addr<A> where
    A: Actor
[src]

Auto Trait Implementations

impl<A> !RefUnwindSafe for Addr<A>

impl<A> Send for Addr<A>

impl<A> Sync for Addr<A>

impl<A> Unpin for Addr<A>

impl<A> !UnwindSafe for Addr<A>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.