Struct Context

Source
pub struct Context<A: Actor> { /* private fields */ }
Expand description

Context of a ActorRuntime that contains Address and Receiver.

Implementations§

Source§

impl<A: Actor> Context<A>

Source

pub fn address(&mut self) -> &mut Address<A>

Returns an instance of the Address.

Source

pub fn spawn_actor_with_addr<T>( &mut self, actor: T, pair: AddressPair<T>, group: A::GroupBy, )
where T: Actor + StartedBy<A> + InterruptedBy<A>, A: Eliminated<T>,

Starts and binds an Actor.

Source

pub fn spawn_actor<T>(&mut self, actor: T, group: A::GroupBy) -> Address<T>
where T: Actor + StartedBy<A> + InterruptedBy<A>, A: Eliminated<T>,

Starts and binds an Actor.

Source

pub fn spawn_task<T, M>( &mut self, task: T, tag: M, group: A::GroupBy, ) -> TaskAddress<T>
where T: LiteTask, A: TaskEliminated<T, M>, M: Tag,

Starts and binds a Task.

Source

pub fn attach<S, M>(&mut self, stream: S, tag: M, group: A::GroupBy)
where S: Stream + Unpin + Send + 'static, S::Item: Send, A: Consumer<S::Item>, M: Tag,

Spawns interaction task that forwards the result of an interaction.

Source

pub fn track_interaction<I, M>( &mut self, task: InteractionTask<I>, tag: M, group: A::GroupBy, )
where I: Interaction, A: InteractionDone<I, M>, M: Tag,

Spawns InteractionTask as a LiteTask and await the result as an Action that will call InteractionDone handler.

Source

pub fn interrupt<T>(&mut self, address: &mut Address<T>) -> Result<(), Error>
where T: Actor + InterruptedBy<A>,

Interrupts an Actor.

Source

pub fn not_terminating(&self) -> Result<(), Error>

Returns Error if the Actor is terminating. Useful for checking in handlers.

Source

pub fn stop(&mut self)

Stops the runtime of the Actor on one message will be processed after this call.

It’s recommended way to terminate Actor is the shutdown method.

Attention! Termination process will never started here and all spawned actors and tasks will be orphaned.

Source

pub fn shutdown(&mut self)

Starts graceful termination of the Actor.

Source

pub fn terminate_group(&mut self, group: A::GroupBy)

Sends interruption signal to the sepcific group of actors and tasks.

Source

pub fn is_terminating(&self) -> bool

Returns true if the shutdown process is in progress.

Auto Trait Implementations§

§

impl<A> Freeze for Context<A>

§

impl<A> !RefUnwindSafe for Context<A>

§

impl<A> Send for Context<A>

§

impl<A> !Sync for Context<A>

§

impl<A> Unpin for Context<A>
where <A as Actor>::GroupBy: Unpin,

§

impl<A> !UnwindSafe for Context<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.