Struct quickwit_actors::Mailbox
source · [−]pub struct Mailbox<A: Actor> { /* private fields */ }
Expand description
A mailbox is the object that makes it possible to send a message to an actor.
It is lightweight to clone.
The actor holds its Inbox
counterpart.
The mailbox can accept:
- Regular messages wrapped in envelopes. Their type depend on the actor and is defined when
implementing the actor trait. (See [
Envelope
]) - Commands (See
Command
). Commands have a higher priority than messages: whenever a command is available, it is guaranteed to be processed as soon as possible regardless of the presence of pending regular messages.
If all mailboxes are dropped, the actor will process all of the pending messages
and gracefully exit with crate::actor::ActorExitStatus::Success
.
Implementations
sourceimpl<A: Actor> Mailbox<A>
impl<A: Actor> Mailbox<A>
pub fn actor_instance_id(&self) -> &str
sourcepub async fn send_message<M>(
&self,
message: M
) -> Result<Receiver<A::Reply>, SendError> where
A: Handler<M>,
M: 'static + Send + Sync + Debug,
pub async fn send_message<M>(
&self,
message: M
) -> Result<Receiver<A::Reply>, SendError> where
A: Handler<M>,
M: 'static + Send + Sync + Debug,
Sends a message to the actor owning the associated inbox.
From an actor context, use the ActorContext::send_message
method instead.
SendError is returned if the actor has already exited.
pub async fn send_command(&self, command: Command) -> Result<(), SendError>
sourcepub async fn ask<M, T>(&self, message: M) -> Result<T, AskError<Infallible>> where
A: Handler<M, Reply = T>,
M: 'static + Send + Sync + Debug,
pub async fn ask<M, T>(&self, message: M) -> Result<T, AskError<Infallible>> where
A: Handler<M, Reply = T>,
M: 'static + Send + Sync + Debug,
Similar to send_message
, except this method
waits asynchronously for the actor reply.
From an actor context, use the ActorContext::ask
method instead.
sourcepub async fn ask_for_res<M, T, E: Debug>(
&self,
message: M
) -> Result<T, AskError<E>> where
A: Handler<M, Reply = Result<T, E>>,
M: 'static + Send + Sync + Debug,
pub async fn ask_for_res<M, T, E: Debug>(
&self,
message: M
) -> Result<T, AskError<E>> where
A: Handler<M, Reply = Result<T, E>>,
M: 'static + Send + Sync + Debug,
Similar to send_message
, except this method
waits asynchronously for the actor reply.
From an actor context, use the ActorContext::ask
method instead.
Trait Implementations
impl<A: Actor> Eq for Mailbox<A>
Auto Trait Implementations
impl<A> RefUnwindSafe for Mailbox<A>
impl<A> Send for Mailbox<A>
impl<A> Sync for Mailbox<A>
impl<A> Unpin for Mailbox<A>
impl<A> UnwindSafe for Mailbox<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more