Struct tonari_actor::Recipient

source ·
pub struct Recipient<M> { /* private fields */ }
Expand description

Similar to Addr, but rather than pointing to a specific actor, it is typed for any actor that handles a given message-response type.

Implementations§

source§

impl<M> Recipient<M>

source

pub fn send(&self, message: M) -> Result<(), SendError>

Send a message to an actor. Returns SendError if the channel is full; does not block. See SendResultExt trait for convenient handling of errors.

source§

impl<M: 'static> Recipient<M>

source

pub fn recipient<N: Into<M>>(&self) -> Recipient<N>

Convert a Recipient<M> (or Addr<A> through Deref, where A::Message = M) into Recipient<N>, where message N can be converted into M.

In case of converting from Addr, this erases the type of the actor and only preserves type of the message, allowing you to make actors more independent of each other.

Trait Implementations§

source§

impl<M> Clone for Recipient<M>

source§

fn clone(&self) -> Self

Returns a copy 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<M> RecipientExt<M> for Recipient<TimedMessage<M>>

source§

fn send_now(&self, message: M) -> Result<(), SendError>

Send a message now. Convenience to wrap message in TimedMessage::Instant.
source§

fn send_timed(&self, message: M, fire_at: Instant) -> Result<(), SendError>

Send a message to be delivered later at a certain instant.
source§

fn send_recurring( &self, factory: impl FnMut() -> M + Send + 'static, fire_at: Instant, interval: Duration ) -> Result<(), SendError>

Schedule sending of message at fire_at plus at regular intervals from that point on.
source§

fn send_delayed(&self, message: M, delay: Duration) -> Result<(), SendError>

Send a message to be delivered later after some time from now.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Recipient<M>

§

impl<M> Send for Recipient<M>

§

impl<M> Sync for Recipient<M>

§

impl<M> Unpin for Recipient<M>

§

impl<M> !UnwindSafe for Recipient<M>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.