Skip to main content

Address

Struct Address 

Source
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,

Source

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.

Source

pub fn index(&self) -> ActorId

Returns the index of the address.

Source

pub fn closed(&self) -> impl Future<Output = ()> + Send

Completes when the mailbox of the actor has been closed.

Source

pub fn is_closed(&self) -> bool

Checks if the mailbox of the actor is closed.

Source

pub fn capacity(&self) -> usize

Returns the current capacity of the mailbox of the actor.

Source

pub fn send<M, EP>( &self, msg: M, ) -> impl Future<Output = SendResult<M>> + Send + '_
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Sends a message, waiting until there is capacity, and returns a Receiver which can be used to receive the message response.

Source

pub fn do_send<M, EP>( &self, msg: M, ) -> impl Future<Output = DoSendResult<M>> + Send + '_
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Sends a message, waiting until there is capacity, without expecting a response.

Source

pub fn try_send<M, EP>(&self, msg: M) -> SendResult<M>
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Attempts to immediately send a message and returns a Receiver which can be used to receive the message response.

Source

pub fn try_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Attempts to immediately send a message without expecting a response.

Source

pub fn send_timeout<M, EP>( &self, msg: M, timeout: Duration, ) -> impl Future<Output = SendResult<M>> + Send + '_
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

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.

Source

pub fn do_send_timeout<M, EP>( &self, msg: M, timeout: Duration, ) -> impl Future<Output = DoSendResult<M>> + Send + '_
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Sends a message, waiting until there is capacity, but only for a limited time, without expecting a response.

Source

pub fn blocking_send<M, EP>(&self, msg: M) -> SendResult<M>
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

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.

Source

pub fn blocking_do_send<M, EP>(&self, msg: M) -> DoSendResult<M>
where A: Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>

Available on crate feature 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> Clone for Address<A>
where A: Actor,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A> Debug for Address<A>
where A: Actor,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A, M, EP> From<Address<A>> for Recipient<M, EP>
where A: Actor + Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Source§

fn from(addr: Address<A>) -> Self

Converts to this type from the input type.
Source§

impl<A> Hash for Address<A>
where A: Actor,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A> PartialEq for Address<A>
where A: Actor,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A, M, EP> Sender<M, EP> for Address<A>
where A: Actor + Handler<M> + ToEnvelope<A, M, EP> + FromEnvelope<A, M, EP>, M: Message,

Source§

fn closed(&self) -> ClosedResultFuture<'_>

Completes when the receiver has been closed.
Source§

fn is_closed(&self) -> bool

Checks if the channel has been closed.
Source§

fn capacity(&self) -> usize

Returns the current capacity of the channel.
Source§

fn send(&self, msg: M) -> SendResultFuture<'_, M>

Sends a message, waiting until there is capacity, and returns a Receiver which can be used to receive the message response.
Source§

fn do_send(&self, msg: M) -> DoSendResultFuture<'_, M>

Sends a message, waiting until there is capacity, without expecting a response.
Source§

fn send_timeout(&self, msg: M, timeout: Duration) -> SendResultFuture<'_, M>

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.
Source§

fn do_send_timeout( &self, msg: M, timeout: Duration, ) -> DoSendResultFuture<'_, M>

Sends a message, waiting until there is capacity, but only for a limited time, without expecting a response.
Source§

fn try_send(&self, msg: M) -> SendResult<M>

Attempts to immediately send a message and returns a Receiver which can be used to receive the message response.
Source§

fn try_do_send(&self, msg: M) -> DoSendResult<M>

Attempts to immediately send a message without expecting a response.
Source§

fn blocking_send(&self, msg: M) -> SendResult<M>

Blocking send to call outside of asynchronous contexts. Read more
Source§

fn blocking_do_send(&self, msg: M) -> DoSendResult<M>

Blocking do_send to call outside of asynchronous contexts. Read more
Source§

fn type_erased_recipient(&self) -> Option<TypeErasedRecipient>

Available on crate feature 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. Read more
Source§

impl<A> SenderId for Address<A>
where A: Actor,

Source§

fn index(&self) -> ActorId

Returns the index of the sender.
Source§

fn is_remote(&self) -> bool

Available on crate feature ipc only.
Returns true if this sender refers to an actor in another process. Read more
Source§

impl<A> Eq for Address<A>
where A: Actor,

Auto Trait Implementations§

§

impl<A> Freeze for Address<A>

§

impl<A> RefUnwindSafe for Address<A>

§

impl<A> Send for Address<A>

§

impl<A> Sync for Address<A>

§

impl<A> Unpin for Address<A>

§

impl<A> UnsafeUnpin for Address<A>

§

impl<A> UnwindSafe for Address<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more