Module behavior

Module behavior 

Source
Expand description

🦹 Behavior module

Behavior instances are identified through a densely packed identifier called BehaviorInstanceId.

BehaviorInstanceId uniquely identifies a triple of:

  • An external behavior module handle
  • A behavior type in this behavior module
  • A behavior instance of this behavior type in this module

Different users of this identifier need different parts:

  • BehaviorModuleHandle, while internal to Ark, consists of the high 16 bits of this id, and can be used to index into an array of behavior modules
  • BehaviorTypeId consists of the module handle as well as the local type id, that is, the high 32-bits. It is used to create new behavior instances, through explicit creation or deserialization.
  • ForeignBehaviorInstanceId consists of the parts that are local to a behavior module. Ark will complete it together with a BehaviorModuleHandle into a BehaviorInstanceId.

/––––– ForeignBehaviorInstanceId β€”β€”β€”β€”
/
LocalBehaviorInstanceId LocalBehaviorTypeId BehaviorModuleHandle 0…………………….31 32………………….47 48…………………….63 \ / -––––––– BehaviorTypeId β€”β€”β€”β€”β€”β€”/ \ / -––––––––––––– BehaviorInstanceId ––––––––––––––/

MacrosΒ§

impl_behavior_module
By passing a type that implements the BehaviorEntry trait, this macro will hook up and route the behavior module’s raw entry points to the trait methods.

StructsΒ§

ForeignBehaviorInstanceId
A unique identifier of a couple comprising a local behavior type id within a behavior module as well as a local instance id.
IncomingMessage
An incoming message from a controller module
IncomingMessageRaw
An incoming message sent from the controller module
LocalBehaviorInstanceId
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.
LocalBehaviorRegistration
Describes a behavior local to a behavior module
LocalBehaviorTypeId
An index of the behavior type, local to a behavior module.
LocalModuleRegistration
Contains all registration info for an external behavior module

EnumsΒ§

ErrorCode
Error return codes for API functions.
IncomingMessageAddr
Target address of an incoming message.

TraitsΒ§

BehaviorEntry
Ergonomic wrapper around a behavior module’s entry points.

Type AliasesΒ§

ActorId