Skip to main content

Context

Struct Context 

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

The default implementation of an actor context.

Implementations§

Source§

impl<A> Context<A>
where A: Actor<Context = Self>,

Source

pub fn with_capacity(label: String, capacity: usize) -> Self

Constructs a new Context with a specific capacity.

Source

pub fn with_channel( label: String, tx: Sender<Envelope<A>>, rx: Receiver<Envelope<A>>, ) -> Self

Constructs a new Context with a specific channel.

Trait Implementations§

Source§

impl<A> ActorContext<A> for Context<A>
where A: Actor<Context = Self>,

Source§

fn new(label: String) -> Self

Constructs a new context.
Source§

fn index(&self) -> usize

Returns the index of the actor.
Source§

fn label(&self) -> &str

Returns the label of the actor.
Source§

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

Returns the address of the actor.
Source§

fn take_mailbox(&mut self) -> Option<Mailbox<A>>

Returns the mailbox of the actor.
Source§

fn state(&self) -> ActorState

Returns the state of the actor.
Source§

fn set_state(&mut self, state: ActorState)

Sets the state of the actor.
Source§

fn supervisor(&self) -> Option<&Recipient<SupervisionEvent<A>>>

Returns the address of the supervisor.
Source§

fn set_supervisor(&mut self, supervisor: Option<Recipient<SupervisionEvent<A>>>)

Sets a supervisor.
Source§

async fn processing( &mut self, actor: &mut A, mailbox: Mailbox<A>, ) -> Result<(), A::Error>

Runs the main processing loop of the actor. Read more
Source§

fn set_error(&mut self, error: A::Error)

Sets an error during message processing.
Source§

fn drain_mailbox(&mut self)

Drains the mailbox of the actor. Read more
Source§

fn stop(&mut self)

Stops the actor. Read more
Source§

fn stop_with_error(&mut self, error: A::Error)

Stops the actor and save the error for reporting. Read more
Source§

fn terminate(&mut self)

Terminates the actor. Read more
Source§

fn terminate_with_error(&mut self, error: A::Error)

Terminates the actor and save the error for reporting. Read more
Source§

fn notify_supervisor( &mut self, event: SupervisionEvent<A>, ) -> impl Future<Output = ()> + Send

Notifies the supervisor for an event. Read more
Source§

fn try_notify_supervisor(&mut self, event: SupervisionEvent<A>)

Notifies the supervisor for an event. Read more
Source§

fn run( self, actor: A, span: Span, ) -> Result<(Address<A>, JoinHandle<()>), A::Error>

Starts the actor and returns its address and a join handle. Read more
Source§

impl<A> Debug for Context<A>
where A: Actor<Context = Self> + Debug, A::Error: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Context<A>
where <A as Actor>::Error: Freeze,

§

impl<A> !RefUnwindSafe for Context<A>

§

impl<A> Send for Context<A>

§

impl<A> Sync for Context<A>
where <A as Actor>::Error: Sync,

§

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

§

impl<A> UnsafeUnpin for Context<A>
where <A as Actor>::Error: UnsafeUnpin,

§

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<A, C, M> FromEnvelope<A, M> for C
where A: Actor<Context = C> + Handler<M>, C: ActorContext<A>, M: Message,

Source§

fn unpack(envelope: Envelope<A>) -> M

Unpacks the message from the envelope.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<A, C, M> ToEnvelope<A, M> for C
where A: Actor<Context = C> + Handler<M>, C: ActorContext<A>, M: Message,

Source§

fn pack(msg: M, tx: Option<Sender<<M as Message>::Result>>) -> Envelope<A>

Packs the message and the optional response sender into an envelope.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more