AddrLike

Trait AddrLike 

Source
pub trait AddrLike:
    Send
    + Sync
    + Clone
    + Debug
    + 'static
    + AsAddr<Addr = Self> {
    type Actor: Actor + ?Sized;

    // Required method
    fn send_fut(&self, fut: impl Future<Output = ()> + Send + 'static);

    // Provided methods
    fn call_fut<R: Send + 'static>(
        &self,
        fut: impl Future<Output = Produces<R>> + Send + 'static,
    ) -> Produces<R>  { ... }
    fn send_fut_with<F: Future<Output = ()> + Send + 'static>(
        &self,
        f: impl FnOnce(Self) -> F,
    ) { ... }
    fn call_fut_with<R: Send + 'static, F: Future<Output = Produces<R>> + Send + 'static>(
        &self,
        f: impl FnOnce(Self) -> F,
    ) -> Produces<R>  { ... }
    fn termination(&self) -> Termination  { ... }
}
Expand description

Trait provides methods for spawning futures onto an actor. Implemented by Addr and WeakAddr alike.

Required Associated Types§

Source

type Actor: Actor + ?Sized

Type of the actor reference by this address.

Required Methods§

Source

fn send_fut(&self, fut: impl Future<Output = ()> + Send + 'static)

Spawn a future onto the actor which does not return a value.

Provided Methods§

Source

fn call_fut<R: Send + 'static>( &self, fut: impl Future<Output = Produces<R>> + Send + 'static, ) -> Produces<R>

Spawn a future onto the actor and provide the means to get back the result. The future will be cancelled if the receiver is dropped before it has completed.

Source

fn send_fut_with<F: Future<Output = ()> + Send + 'static>( &self, f: impl FnOnce(Self) -> F, )

Equivalent to send_fut but provides access to the actor’s address.

Source

fn call_fut_with<R: Send + 'static, F: Future<Output = Produces<R>> + Send + 'static>( &self, f: impl FnOnce(Self) -> F, ) -> Produces<R>

Equivalent to call_fut but provides access to the actor’s address.

Source

fn termination(&self) -> Termination

Returns a future which resolves when the actor terminates. If the actor has already terminated, or if this address is detached, the future will resolve immediately.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Actor + ?Sized> AddrLike for Addr<T>

Source§

type Actor = T

Source§

impl<T: Actor + ?Sized> AddrLike for WeakAddr<T>

Source§

type Actor = T