pub struct ActorContext<C: FluxionParams> { /* private fields */ }
Expand description

ActorContext

Provides information about an actor, as well as an interface to the system.

ActorContext implements the System trait, which means that it can be used anywhere that a Fluxion instance can. It should be noted that any message sent by actor handles returned by this struct will be detected by the receiving actor as being sent by this actor. This may cause undesired behavior, so as a rule of thumb, actor handles should not escape the actor that created them.

Generics

This struct takes a single generic which contains configuration data used by the Fluxion system, as well as other parts of fluxion.

Implementations§

source§

impl<C: FluxionParams> ActorContext<C>

source

pub fn new(id: ActorId, system: Fluxion<C>) -> Self

Creates a new ActorContext from an ActorId and Fluxion instance.

source

pub fn get_id(&self) -> ActorId

Retrieves the actor’s id

Trait Implementations§

source§

impl<C: FluxionParams> System<C> for ActorContext<C>

source§

fn add<'life0, 'life1, 'async_trait, A>( &'life0 self, actor: A, id: &'life1 str ) -> Pin<Box<dyn Future<Output = Option<LocalHandle<C, A>>> + Send + 'async_trait>>where A: 'async_trait + Actor<C>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add an actor to the system

Delegates to the Fluxion instance’s internal add function, specifying the actor that owns the context as the owner of the returned handle. See System::add for more info.

source§

fn foreign_proxy<'life0, 'life1, 'life2, 'async_trait, A, M, R>( &'life0 self, actor_id: &'life1 str, foreign_id: &'life2 str ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where A: Handler<C, M> + 'async_trait, M: Message<Response = R> + Serialize + for<'a> Deserialize<'a> + 'async_trait, R: Send + Sync + 'static + Serialize + for<'a> Deserialize<'a> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delegated directly to System::foreign_proxy, implemented on Fluxion. See System::foreign_proxy for more info.

source§

fn get_local<'life0, 'life1, 'async_trait, A>( &'life0 self, id: &'life1 str ) -> Pin<Box<dyn Future<Output = Option<LocalHandle<C, A>>> + Send + 'async_trait>>where A: 'async_trait + Actor<C>, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a local actor as a LocalHandle. Useful for running management functions like shutdown on known local actors.

Delegates to the Fluxion instance’s internal get_local function, specifying the actor that owns the context as the owner of the returned handle. See System::get_local for more info.

source§

fn get<'life0, 'async_trait, A, M>( &'life0 self, id: ActorId ) -> Pin<Box<dyn Future<Output = Option<Box<dyn MessageSender<M>>>> + Send + 'async_trait>>where M::Response: for<'a> Deserialize<'a>, A: 'async_trait + Handler<C, M>, M: 'async_trait + Message + Serialize, Self: 'async_trait, 'life0: 'async_trait,

Get an actor from its id as a Box<dyn MessageSender>. Use this for most cases, as it will also handle foreign actors.

Delegates to the Fluxion instance’s internal get function, specifying the actor that owns the context as the owner of the returned handle. See System::get for more info.

source§

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes an actor from the system, and waits for it to stop execution Delegated directly to System::remove, implemented on Fluxion. See System::remove for more info.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for ActorContext<C>

§

impl<C> Send for ActorContext<C>

§

impl<C> Sync for ActorContext<C>

§

impl<C> Unpin for ActorContext<C>where C: Unpin,

§

impl<C> !UnwindSafe for ActorContext<C>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.