[][src]Trait xtra::AddressExt

pub trait AddressExt<A: Actor> {
    fn is_connected(&self) -> bool;
fn do_send<M>(&self, message: M) -> Result<(), Disconnected>
    where
        M: Message,
        A: Handler<M> + Send
;
fn send<M>(&self, message: M) -> MessageResponseFuture<M>
    where
        M: Message,
        A: Handler<M> + Send,
        M::Result: Send
; fn attach_stream<S, M>(self, stream: S)
    where
        M: Message,
        A: Handler<M> + Send,
        S: Stream<Item = M> + Send + Unpin + 'static,
        Self: Sized + Send + Sink<M, Error = Disconnected> + 'static
, { ... } }

General trait for any kind of address to an actor, be it strong or weak. This trait contains all functions of the address.

Required methods

fn is_connected(&self) -> bool

Returns whether the actor referred to by this address is running and accepting messages.

fn do_send<M>(&self, message: M) -> Result<(), Disconnected> where
    M: Message,
    A: Handler<M> + Send

Sends a Message to the actor, and does not wait for a response. If this returns Err(Disconnected), then the actor is stopped and not accepting messages. If this returns Ok(()), the will be delivered, but may not be handled in the event that the actor stops itself (by calling Context::stop) before it was handled.

fn send<M>(&self, message: M) -> MessageResponseFuture<M> where
    M: Message,
    A: Handler<M> + Send,
    M::Result: Send

Sends a Message to the actor, and waits for a response. If this returns Err(Disconnected), then the actor is stopped and not accepting messages.

Loading content...

Provided methods

fn attach_stream<S, M>(self, stream: S) where
    M: Message,
    A: Handler<M> + Send,
    S: Stream<Item = M> + Send + Unpin + 'static,
    Self: Sized + Send + Sink<M, Error = Disconnected> + 'static, 

This is supported on feature="with-tokio-0_2" and feature="with-async_std-1" only.

Attaches a stream to this actor such that all messages produced by it are forwarded to the actor. This could, for instance, be used to forward messages from a socket to the actor (after the messages have been appropriately mapped). This is a convenience method over explicitly forwarding a stream to this address, spawning that future onto the executor, and mapping the error away (because disconnects are expected and will simply mean that the stream is no longer being forwarded).

Note: if this stream's continuation should prevent the actor from being dropped, this method should be called on Address. Otherwise, it should be called on WeakAddress.

Loading content...

Implementors

impl<A: Actor> AddressExt<A> for Address<A>[src]

impl<A: Actor> AddressExt<A> for WeakAddress<A>[src]

Loading content...