logo
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:

  1. The controller module creates messages and sends them to Ark
  2. Ark owns the actual behavior modules and will, in order, send these messages to the correct behaviors inside external behavior modules
  3. A behavior will then process the just received message

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.

Type Definitions