pub struct Address<A>where
A: Actor,{ /* private fields */ }Expand description
The address of an actor.
It is used to send messages to an actor.
Implementations§
Source§impl<A> Address<A>where
A: Actor,
impl<A> Address<A>where
A: Actor,
Sourcepub fn new(tx: Sender<Envelope<A>>) -> Self
pub fn new(tx: Sender<Envelope<A>>) -> Self
Constructs a new Address from a mpsc::Sender.
Triggers Actor::type_erased_recipient_fn once (if the feature
type-erased-recipient-hook is enabled) and stores the result.
Sourcepub fn closed(&self) -> impl Future<Output = ()> + Send
pub fn closed(&self) -> impl Future<Output = ()> + Send
Completes when the mailbox of the actor has been closed.
Sourcepub fn send<M, EP>(
&self,
msg: M,
) -> impl Future<Output = SendResult<M>> + Send + '_
pub fn send<M, EP>( &self, msg: M, ) -> impl Future<Output = SendResult<M>> + Send + '_
Sends a message, waiting until there is capacity, and returns a
Receiver which can be used to receive the message
response.
Sourcepub fn do_send<M, EP>(
&self,
msg: M,
) -> impl Future<Output = DoSendResult<M>> + Send + '_
pub fn do_send<M, EP>( &self, msg: M, ) -> impl Future<Output = DoSendResult<M>> + Send + '_
Sends a message, waiting until there is capacity, without expecting a response.
Sourcepub fn try_send<M, EP>(&self, msg: M) -> SendResult<M>
pub fn try_send<M, EP>(&self, msg: M) -> SendResult<M>
Attempts to immediately send a message and returns a
Receiver which can be used to receive the message
response.
Sourcepub fn try_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
pub fn try_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
Attempts to immediately send a message without expecting a response.
Sourcepub fn send_timeout<M, EP>(
&self,
msg: M,
timeout: Duration,
) -> impl Future<Output = SendResult<M>> + Send + '_
pub fn send_timeout<M, EP>( &self, msg: M, timeout: Duration, ) -> impl Future<Output = SendResult<M>> + Send + '_
Sends a message, waiting until there is capacity, but only for a limited time, and returns
a Receiver which can be used to receive the message
response.
Sourcepub fn do_send_timeout<M, EP>(
&self,
msg: M,
timeout: Duration,
) -> impl Future<Output = DoSendResult<M>> + Send + '_
pub fn do_send_timeout<M, EP>( &self, msg: M, timeout: Duration, ) -> impl Future<Output = DoSendResult<M>> + Send + '_
Sends a message, waiting until there is capacity, but only for a limited time, without expecting a response.
Sourcepub fn blocking_send<M, EP>(&self, msg: M) -> SendResult<M>
pub fn blocking_send<M, EP>(&self, msg: M) -> SendResult<M>
Blocking send to call outside of asynchronous contexts.
This method is intended for use cases where you are sending from synchronous code to asynchronous code.
§Panics
This function panics if called within an asynchronous execution context.
Sourcepub fn blocking_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
pub fn blocking_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
Blocking do_send to call outside of asynchronous contexts.
This method is intended for use cases where you are sending from synchronous code to asynchronous code.
§Panics
This function panics if called within an asynchronous execution context.
Sourcepub fn reserve(
&self,
) -> impl Future<Output = Result<SendPermit<'_, A>, SendError<()>>> + Send
pub fn reserve( &self, ) -> impl Future<Output = Result<SendPermit<'_, A>, SendError<()>>> + Send
Reserves channel capacity to send one message.
This method borrows the internal mpsc::Sender and returns a SendPermit.
Sourcepub fn try_reserve(&self) -> Result<SendPermit<'_, A>, SendError<()>>
pub fn try_reserve(&self) -> Result<SendPermit<'_, A>, SendError<()>>
Attempts to reserve channel capacity to send one message.
This method borrows the internal mpsc::Sender and returns a SendPermit.
Sourcepub fn reserve_owned(
&self,
) -> impl Future<Output = Result<OwnedSendPermit<A>, SendError<()>>> + Send
pub fn reserve_owned( &self, ) -> impl Future<Output = Result<OwnedSendPermit<A>, SendError<()>>> + Send
Reserves channel capacity to send one message.
This method clones the internal mpsc::Sender and returns a OwnedSendPermit.
Sourcepub fn try_reserve_owned(&self) -> Result<OwnedSendPermit<A>, SendError<()>>
pub fn try_reserve_owned(&self) -> Result<OwnedSendPermit<A>, SendError<()>>
Attempts to reserve channel capacity to send one message.
This method clones the internal mpsc::Sender and returns a OwnedSendPermit.
Sourcepub fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>
Available on crate feature type-erased-recipient-hook only.
pub fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>
type-erased-recipient-hook only.Returns a type-erased trait object which can be downcast into a concrete
Recipient<M>, where M is a specific message type chosen
by the user who overrides the
Actor::type_erased_recipient_fn method.
This method triggers the conversion function baked in this address at construction, and returns the resulting type-erased trait object.
Trait Implementations§
Source§impl<A, M, EP> Sender<M, EP> for Address<A>
impl<A, M, EP> Sender<M, EP> for Address<A>
Source§fn closed(&self) -> ClosedResultFuture<'_>
fn closed(&self) -> ClosedResultFuture<'_>
Source§fn send(&self, msg: M) -> SendResultFuture<'_, M>
fn send(&self, msg: M) -> SendResultFuture<'_, M>
Receiver which can be
used to receive the message response.Source§fn do_send(&self, msg: M) -> DoSendResultFuture<'_, M>
fn do_send(&self, msg: M) -> DoSendResultFuture<'_, M>
Source§fn send_timeout(&self, msg: M, timeout: Duration) -> SendResultFuture<'_, M>
fn send_timeout(&self, msg: M, timeout: Duration) -> SendResultFuture<'_, M>
Receiver which can be used to receive the message response.Source§fn do_send_timeout(
&self,
msg: M,
timeout: Duration,
) -> DoSendResultFuture<'_, M>
fn do_send_timeout( &self, msg: M, timeout: Duration, ) -> DoSendResultFuture<'_, M>
Source§fn try_send(&self, msg: M) -> SendResult<M>
fn try_send(&self, msg: M) -> SendResult<M>
Receiver which can be used to
receive the message response.Source§fn try_do_send(&self, msg: M) -> DoSendResult<M>
fn try_do_send(&self, msg: M) -> DoSendResult<M>
Source§fn blocking_send(&self, msg: M) -> SendResult<M>
fn blocking_send(&self, msg: M) -> SendResult<M>
Source§fn blocking_do_send(&self, msg: M) -> DoSendResult<M>
fn blocking_do_send(&self, msg: M) -> DoSendResult<M>
Source§fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>
fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>
type-erased-recipient-hook only.Recipient<M>, where M is a specific message type chosen
by the user who overrides the
Actor::type_erased_recipient_fn method. Read more