[−][src]Crate kay
Kay is an experimental high-performance distributed actor system framework for Rust. It is developed as a component for Citybound (a city simulation game) but aims to be general-purpose.
Kay is inspired by Erlang/OTP and similar actor-oriented approaches, since it allows you to build a distributed application from isolated actors that communicate only through message-passing, which works transparently across processor and even network boundaries.
The main abstractions are Classes of actors that live inside an Actor System, adressed by TypedIDs. Classes can implement Traits, allowing generic dynamic dispatch.
Kay lacks many higher level features and error-handling mechanisms that other actor system frameworks offer since it puts a focus on high-performance and memory efficiency. This is achieved by storing actor state and message queues in consecutive chunks of memory, inspired by the data-oriented game engine design philosophy. The Compact library is used to help with this, offering serialisation-free linear memory layouts for plain old data and nested datastructures. This does, in turn, impose the constraint that actor state and messages need to implement Compact
Structs
ActorSystem | Contains the state of a whole actor system and can be used for managing and progressing the actor system as well as for interacting with it from the outside |
External | A Marker for state of an actor instance that is not managed by the actor system.
As such it will not be compacted, nor persisted.
External implements clone, so it can be used in actor state, but you have to ensure
at runtime that only one actor or message ever holds onto an external.
Any attempt to access the external from two different places will throw (see |
MachineID | Represents an |
Networking | Represents a networking configuration, topology and state of an |
Packet | A message plus a recipient |
RawID | A raw (untyped) ID referring to an actor class instance |
World | A handle representing an |
Enums
Fate | The self-chosen fate of an actor instance it returns after handling a message |
Traits
Actor | Must be implemented by every struct to be used as actor instance state |
ActorOrActorTrait | Represents an adressable entitiy in the system: Either an actor class or an actor trait. |
Message | Must be implemented by everything that can be sent between actors |
TraitIDFrom | A marker that an actor implements a trait and thus its ID can be converted to the corresponding actor trait ID |
TypedID | Wraps a |