Skip to main content

Sender

Trait Sender 

Source
pub trait Sender<M, EP = DefaultEnvelopeProxy<M>>: SenderIndex
where M: Message<EP>, EP: 'static,
{ // Required methods fn is_closed(&self) -> bool; fn capacity(&self) -> usize; fn send( &self, msg: M, ) -> Pin<Box<dyn Future<Output = Result<Receiver<M::Result>, SendError<M>>> + Send + '_>>; fn do_send( &self, msg: M, ) -> Pin<Box<dyn Future<Output = Result<(), SendError<M>>> + Send + '_>>; fn try_send(&self, msg: M) -> Result<Receiver<M::Result>, TrySendError<M>>; fn try_do_send(&self, msg: M) -> Result<(), TrySendError<M>>; fn blocking_send(&self, msg: M) -> Result<Receiver<M::Result>, SendError<M>>; fn blocking_do_send(&self, msg: M) -> Result<(), SendError<M>>; fn boxed(&self) -> Box<dyn Sender<M, EP> + Send + Sync>; }
Expand description

Describes how to send a message.

Required Methods§

Source

fn is_closed(&self) -> bool

Checks if the channel is closed.

Source

fn capacity(&self) -> usize

Returns the capacity of the channel.

Source

fn send( &self, msg: M, ) -> Pin<Box<dyn Future<Output = Result<Receiver<M::Result>, SendError<M>>> + Send + '_>>

Sends a message and returns a oneshot::Receiver which could be used to receive the response.

Source

fn do_send( &self, msg: M, ) -> Pin<Box<dyn Future<Output = Result<(), SendError<M>>> + Send + '_>>

Sends a message without expecting a response.

Source

fn try_send(&self, msg: M) -> Result<Receiver<M::Result>, TrySendError<M>>

Attempts to send a message and returns a oneshot::Receiver which could be used to receive the response.

Source

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

Attempts to send a message without expecting a response.

Source

fn blocking_send(&self, msg: M) -> Result<Receiver<M::Result>, SendError<M>>

Sends a message and returns a oneshot::Receiver which could be used to receive the response.

This method is intended for use cases where you are sending from synchronous code.

Source

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

Sends a message to an actor without expecting a response.

This method is intended for use cases where you are sending from synchronous code.

Source

fn boxed(&self) -> Box<dyn Sender<M, EP> + Send + Sync>

Returns the sender as a boxed trait object.

Implementors§

Source§

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

Source§

impl<M, EP> Sender<M, EP> for Recipient<M, EP>
where M: Message<EP>, EP: 'static,