pub struct ActorRegister { /* private fields */ }
Expand description

A record will registered into REGISTER for future use (Create/Read/Update/Delete)

each record contains

  • id: usize
  • actor: the type implemented Acotr trait
  • sealed: AtomicBool, marker whether the actor is mutably borrowed or not
  • type_id: the type id of the type implemented Acotr trait
  • message_id: the type id of the type implemented Message trait
  • name: String
  • closed: AtomicBool, marker whether the actor is closed or not

Implementations§

source§

impl ActorRegister

source

pub fn new<A>(act: A) -> Selfwhere A: Actor,

create a Actor Register for an actor instance

source

pub fn id(&self) -> usize

the unqiue identity of the Actor

source

pub fn type_id(&self) -> TypeId

the TypeId of the Actor

source

pub fn message_id(&self) -> TypeId

the TypeId of the Actor::Message

source

pub fn name(&self) -> &str

the name of the Actor you can set it with set_name

source

pub fn set_name<T: Into<String>>(&mut self, name: T)

set the name of the Actor

source

pub fn is_closed(&self) -> bool

the state of the Actor you can set it with set_closed

source

pub fn set_closed(&self, state: bool)

set the actor is closed

source

pub fn is_sealed(&self) -> bool

indicator that whether the Actor is being downcasted to Actor and mutating

source

pub fn downcast_ref<A: Actor>(&self) -> Option<&A>

downcast the type Actor type &A

source

pub fn downcast_mut<A: Actor, F>(&self, f: F) -> Option<bool>where F: FnMut(&mut A) -> Result<(), ()>,

downcast the type Actor type &mut A then mutate it with the function f

and return

  • None: downcast failed
  • Some(false): downcasted and f return Err(_)
  • Some(true): downcasted and f return Ok(_)

the underlying actor will be guarded when downcasted no more mutable access is allowed during downcasted

Trait Implementations§

source§

impl Debug for ActorRegister

source§

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

Formats the value using the given formatter. Read more
source§

impl Send for ActorRegister

Safety: since it is guardted with AtomicBool for generic A: Actor

  • nothing changes to the Inner data when downcasted to &A,
  • seal the inner to deny more than one access when downcasted to &mut A

So it is safe to send &A between threads

source§

impl Sync for ActorRegister

Safety: since it is guardted with AtomicBool for generic A: Actor

  • nothing changes to the Inner data when downcasted to &A,
  • seal the inner to deny more than one access when downcasted to &mut A

So it is safe to send &A between threads

Auto Trait Implementations§

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.