Trait kay::Actor [−][src]
pub trait Actor: Compact + StorageAware + 'static { type ID: TypedID; fn id(&self) -> Self::ID; unsafe fn set_id(&mut self, id: RawID); fn id_as<TargetID: TraitIDFrom<Self>>(&self) -> TargetID { ... } fn local_first(world: &mut World) -> Self::ID { ... } fn global_first(world: &mut World) -> Self::ID { ... } fn local_broadcast(world: &mut World) -> Self::ID { ... } fn global_broadcast(world: &mut World) -> Self::ID { ... } }
Trait that Actors instance have to implement for a Swarm
so their internally stored instance RawID
can be gotten and set.
Furthermore, an Actor
has to implement Compact
, so a Swarm
can compactly store each Actor
's potentially dynamically-sized state.
This trait can is auto-derived when using the
kay_codegen
build script.
Associated Types
Required Methods
fn id(&self) -> Self::ID
Get TypedID
of this actor
unsafe fn set_id(&mut self, id: RawID)
Set the full RawID (Actor type id + instance id)
of this actor (only used internally by Swarm
)
Provided Methods
fn id_as<TargetID: TraitIDFrom<Self>>(&self) -> TargetID
Get the id of this actor as an actor trait TypedID
(available if the actor implements the corresponding trait)
fn local_first(world: &mut World) -> Self::ID
Get the TypedID
of the local first actor of this kind
fn global_first(world: &mut World) -> Self::ID
Get the TypedID
of the global first actor of this kind
fn local_broadcast(world: &mut World) -> Self::ID
Get the TypedID
representing a local broadcast to actors of this type
fn global_broadcast(world: &mut World) -> Self::ID
Get the TypedID
representing a global broadcast to actors of this type