pub struct Mailbox { /* private fields */ }
Expand description
A mailbox coordinates message delivery to actors through typed
[Port
]s associated with the mailbox.
Implementations§
Source§impl Mailbox
impl Mailbox
Sourcepub fn new(actor_id: ActorId, forwarder: BoxedMailboxSender) -> Self
pub fn new(actor_id: ActorId, forwarder: BoxedMailboxSender) -> Self
Create a new mailbox associated with the provided actor ID, using the provided forwarder for external destinations.
Sourcepub fn new_detached(actor_id: ActorId) -> Self
pub fn new_detached(actor_id: ActorId) -> Self
Create a new detached mailbox associated with the provided actor ID.
Sourcepub fn open_port<M: Message>(&self) -> (PortHandle<M>, PortReceiver<M>)
pub fn open_port<M: Message>(&self) -> (PortHandle<M>, PortReceiver<M>)
Open a new port that accepts M-typed messages. The returned port may be freely cloned, serialized, and passed around. The returned receiver should only be retained by the actor responsible for processing the delivered messages.
Sourcepub fn open_accum_port<A>(
&self,
accum: A,
) -> (PortHandle<A::Update>, PortReceiver<A::State>)
pub fn open_accum_port<A>( &self, accum: A, ) -> (PortHandle<A::Update>, PortReceiver<A::State>)
Open a new port with an accumulator. This port accepts A::Update type messages, accumulate them into A::State with the given accumulator. The latest changed state can be received from the returned receiver as a single A::State message. If there is no new update, the receiver will not receive any message.
Sourcepub fn open_once_port<M: Message>(
&self,
) -> (OncePortHandle<M>, OncePortReceiver<M>)
pub fn open_once_port<M: Message>( &self, ) -> (OncePortHandle<M>, OncePortReceiver<M>)
Open a new one-shot port that accepts M-typed messages. The returned port may be used to send a single message; ditto the receiver may receive a single message.
Sourcepub fn bound_return_handle(
&self,
) -> Option<PortHandle<Undeliverable<MessageEnvelope>>>
pub fn bound_return_handle( &self, ) -> Option<PortHandle<Undeliverable<MessageEnvelope>>>
Retrieve the bound undeliverable message port handle.
Trait Implementations§
Source§impl MailboxSender for Mailbox
impl MailboxSender for Mailbox
Source§fn post(
&self,
envelope: MessageEnvelope,
return_handle: PortHandle<Undeliverable<MessageEnvelope>>,
)
fn post( &self, envelope: MessageEnvelope, return_handle: PortHandle<Undeliverable<MessageEnvelope>>, )
Deliver a serialized message to the provided port ID. This method fails if the message does not deserialize into the expected type.
Auto Trait Implementations§
impl Freeze for Mailbox
impl !RefUnwindSafe for Mailbox
impl Send for Mailbox
impl Sync for Mailbox
impl Unpin for Mailbox
impl !UnwindSafe for Mailbox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BoxableMailboxSender for Twhere
T: MailboxSender + Clone + 'static,
impl<T> BoxableMailboxSender for Twhere
T: MailboxSender + Clone + 'static,
Source§fn boxed(&self) -> BoxedMailboxSender
fn boxed(&self) -> BoxedMailboxSender
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoBoxedMailboxSender for Twhere
T: MailboxSender + 'static,
impl<T> IntoBoxedMailboxSender for Twhere
T: MailboxSender + 'static,
Source§fn into_boxed(self) -> BoxedMailboxSender
fn into_boxed(self) -> BoxedMailboxSender
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more