[][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



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


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 steal).


Represents an ActorSystem in a networking topology


Represents a networking configuration, topology and state of an ActorSystem


A message plus a recipient


A raw (untyped) ID referring to an actor class instance


A handle representing an ActorSystem that exposes a safe subset of functionality to be used within actor message handlers - for communication with other actors.



The self-chosen fate of an actor instance it returns after handling a message



Must be implemented by every struct to be used as actor instance state


Represents an adressable entitiy in the system: Either an actor class or an actor trait.


Must be implemented by everything that can be sent between actors


A marker that an actor implements a trait and thus its ID can be converted to the corresponding actor trait ID


Wraps a RawID, bringing type information regarding the referenced actor class or trait to compile time, for type safe handling of ids.