Trait near_async::messaging::CanSend
source · pub trait CanSend<M>: Send + Sync + 'static {
// Required method
fn send(&self, message: M);
}
Expand description
Trait for sending a typed message.
Required Methods§
Implementations on Foreign Types§
source§impl<M, A> CanSend<M> for Addr<A>where
M: Message + Send + 'static,
M::Result: Send,
A: Actor + Handler<M>,
A::Context: ToEnvelope<A, M>,
impl<M, A> CanSend<M> for Addr<A>where M: Message + Send + 'static, M::Result: Send, A: Actor + Handler<M>, A::Context: ToEnvelope<A, M>,
An actix Addr implements CanSend for any message type that the actor handles.
Implementors§
impl<A: AsRef<Sender<M>> + Send + Sync + 'static, M: 'static> CanSend<M> for A
Anything that contains a Sender also implements CanSend. This is useful for implementing APIs that require multiple sender interfaces, so that the multi-sender API can be used to send individual message types directly.
For example:
#[derive(Clone, derive_more::AsRef)]
pub struct MyAPI {
client: Sender
fn something(api: &MyAPI) { // There’s no need to do api.client.send() or api.network.send_async() here. api.send(ClientMessage::Something); api.send_async(NetworkMessage::Something).then(…); }
impl<M, S> CanSend<M> for AddrWithAutoSpanContext<S>where M: Message + 'static, S: Actor, Addr<S>: CanSend<WithSpanContext<M>>,
impl<M, S: CanSend<M>> CanSend<M> for LateBoundSender<S>
Allows LateBoundSender to be convertible to a Sender as long as the inner object could be.
impl<Message, Event: From<Message> + 'static> CanSend<Message> for DelaySender<Event>
Allows DelaySender to be used in contexts where we don’t need a delay, such as being given to something that expects an actix recipient.