Expand description
šØ Behavior API
This API provides functionality for a behavior to communicate with the rest of the world and is mainly used when a behavior is processing an incoming message. Incoming messages are sent from a ācontroller moduleā, which is a different Ark module type like an Applet or Cmdlet.
Message passing
Messages are the protocols through which behaviors communicate. At the lowest level they are serializable Rust structures.
The entire message passing flow between the controller module and behavior modules goes as follows:
- The controller module creates messages and sends them to Ark
- Ark owns the actual behavior modules and will, in order, send these messages to the correct behaviors inside external behavior modules
- A behavior will then process the just received message
- This is where the Behavior API comes in. During the processing of a message the behavior
can create
OutgoingMessage
s and send them back to the controller module throughBehavior::send_outgoing_messages
.
- This is where the Behavior API comes in. During the processing of a message the behavior
can create
Aspects
Aspects are used to associate data with actors, and share it between behaviors. Aspects are just data and donāt implement any logic. From the point of view of a behavior, aspects can be used to eagerly publish information/state, so that it doesnāt need to be asynchronously queried via message passing.
Aspect data can be retrieved through Behavior::aspect_get
given a valid AspectAddr
.
Structs
Collection of actors with a specific aspect
An aspectās address, comprising an aspect guid and an actor id
The Behavior
API provides behavior modules functionality for interacting with the world
Address of a single behavior.
A unique identifier of a couple comprising a local behavior type id within a behavior module as well as a local instance id.
An incoming message from a controller module
A behavior instance index. May not be unique overall, but must form unique pairs with the
corresponding LocalBehaviorTypeId
of the instanceās type, resulting in a ForeignBehaviorInstanceId
.
Describes a behavior local to a behavior module
An index of the behavior type, local to a behavior module.
Contains all registration info for an external behavior module
An outgoing message that can be send from a behavior instance to the controller module
An outgoing messageās address, targeting either an entire actor or a specific behavior
Enums
Target address of an incoming message.