[][src]Struct herbert::ActorContext

pub struct ActorContext {
    pub id: String,
    pub req: Receiver<Message>,
    pub ctl: Receiver<ActorCtl>,
    pub router_req: Sender<RouterRequest>,
    pub router_ctl: Sender<RouterCtl>,
    pub stat: Sender<ActorStatus>,
}

A handle to communication channels provided to an actor function.

Actor functions spawned through the router are passed an ActorContext that provides the Receviers over which the actor receives messages and control messages from the router and Senders the actor can use to communicate back with the router.

This is typically only used by the router.

Fields

id: Stringreq: Receiver<Message>ctl: Receiver<ActorCtl>router_req: Sender<RouterRequest>router_ctl: Sender<RouterCtl>stat: Sender<ActorStatus>

Methods

impl ActorContext[src]

pub fn new(
    id: String,
    req: Receiver<Message>,
    ctl: Receiver<ActorCtl>,
    router_req: Sender<RouterRequest>,
    router_ctl: Sender<RouterCtl>,
    stat: Sender<ActorStatus>
) -> Self
[src]

Construct an ActorContext. This is typically used only by the router.

pub fn spawn(&self, id: &str, f: Box<ActorFn>) -> Result<()>[src]

Spawn a new actor.

pub fn has(&self, id: &str) -> Result<bool>[src]

Determine whether the router has a route to another actor, at the time of inspection.

pub fn get(&self, id: &str) -> Result<Sender<Message>>[src]

Retrieve a copy of another actor's request channel Sender.

pub fn send(&self, id: &str, msg: Message) -> Result<()>[src]

Send a message to another actor.

pub fn stop(&self, id: &str) -> Result<()>[src]

Stop another actor.

Warning: if attempting to stop another actor while in the process of being stopped, the router will be blocked awaiting a response. The router will not receive the stop request until after you have completed stopping and a deadlock will occur.

pub fn stop_async(&self, id: &str) -> Result<()>[src]

Stop another actor without waiting for it to stop.

This should be used when stopping an actor from within an actor that is currently in the process of being stopped.

pub fn report_stopped(&self) -> Result<()>[src]

Inform the router that we are stopping.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.