Skip to main content

TypedMailbox

Struct TypedMailbox 

Source
pub struct TypedMailbox<A: Actor + Send + Sync> { /* private fields */ }
Expand description

Concrete Mailbox for a specific actor type A. Holds the channel sender to the actor’s run loop and performs the type-safe downcast on each send. Constructed in Actor::run_actor and erased to Arc<dyn Mailbox> for storage in the system’s actor map.

Implementations§

Source§

impl<A: Actor + Send + Sync> TypedMailbox<A>

Source

pub fn new(tx: Sender<Message<A>>) -> Self

Wrap an mpsc sender. Only called from Actor::run_actor.

Trait Implementations§

Source§

impl<A> Mailbox for TypedMailbox<A>
where A: Actor + Send + Sync + 'static, A::Message: Any + Send + Sync + 'static, A::Result: Any + Send + 'static,

Source§

fn send<'life0, 'async_trait>( &'life0 self, msg: Arc<dyn Any + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<(), ActorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fire-and-forget send. Downcast the payload to A::Message and push it onto the actor’s mpsc channel.
Source§

fn send_and_recv<'life0, 'async_trait>( &'life0 self, msg: Arc<dyn Any + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send>, ActorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send and await the actor’s reply. The reply is returned as a boxed Any; the caller downcasts to A::Result.

Auto Trait Implementations§

§

impl<A> Freeze for TypedMailbox<A>

§

impl<A> RefUnwindSafe for TypedMailbox<A>

§

impl<A> Send for TypedMailbox<A>

§

impl<A> Sync for TypedMailbox<A>

§

impl<A> Unpin for TypedMailbox<A>

§

impl<A> UnsafeUnpin for TypedMailbox<A>

§

impl<A> UnwindSafe for TypedMailbox<A>

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> MaybeCodec for T
where T: ?Sized,

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.