[][src]Struct riker::actor::Context

pub struct Context<Msg: Message> {
    pub myself: ActorRef<Msg>,
    pub system: ActorSystem<Msg>,
    pub persistence: Persistence<Msg>,
    // some fields omitted
}

Provides context, including the actor system during actor execution.

Context is passed to an actor's functions, such as receive.

Operations performed are in most cases done so from the actor's perspective. For example, creating a child actor using ctx.actor_of will create the child under the current actor within the heirarchy. In a similar manner, persistence operations such as persist_event use the current actor's persistence configuration.

Since Context is specific to an actor and its functions it is not cloneable.

Fields

Methods

impl<Msg> Context<Msg> where
    Msg: Message
[src]

Returns the ActorRef of the current actor.

Persists an event to the event store.

In an event sourcing environment state is maintained by storing the events that change the state. persist_event attempts to store the event.

State should not be modified until the event has been successfully persisted. The event store manager notifies the actor after each event is stored and the actor's state can then safely be updated. The actor's apply_event method is called after an event is stored.

While an event is persisting it is guaranteed that no other messages are processed until persistence is complete. I.e., no messages are processed between persist_event and the resulting apply_event.

When an actor starts (or restarts), if pesistence is configured the system will query the event source manager to get all the events for the actor. Each event is then replayed, in their original order, which effectively results in an actor being in the latest state.

Trait Implementations

impl<Msg> ActorRefFactory for Context<Msg> where
    Msg: Message
[src]

impl<Msg> TmpActorRefFactory for Context<Msg> where
    Msg: Message
[src]

impl<Msg> ActorSelectionFactory for Context<Msg> where
    Msg: Message
[src]

impl<Msg> Timer for Context<Msg> where
    Msg: Message
[src]

impl<Msg> ExecutionContext for Context<Msg> where
    Msg: Message
[src]

impl<'a, Msg> From<&'a ActorCell<Msg>> for Context<Msg> where
    Msg: Message
[src]

Performs the conversion.

Auto Trait Implementations

impl<Msg> Send for Context<Msg>

impl<Msg> Sync for Context<Msg>

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

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

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.