logo
pub struct BehaviorController {}
Expand description

The BehaviorController API provides functionality for interacting with external behavior modules

Implementations

Returns a serialized JSON vector of bytes with a list of external registration info.

Only registration info from behavior modules listed in a Cargo.toml’s Ark annotation will be returned

Example

At a bare minimum, the JSON vector can be deserialized into a vector of BehaviorModuleRegistration:

use ark_api::behavior_controller::BehaviorModuleRegistration;

let list: Vec<BehaviorModuleRegistration> = serde_json::from_slice(behavior_controller().list_modules()).unwrap();

If behavior modules were registered with a custom registration format they can be deserialized similarly:

use ark_api::behavior_controller::BehaviorModuleRegistration;

// Custom data format used in behavior module registration
#[derive(serde::Deserialize)]
pub struct CustomBehaviorInfo {
   #[serde(flatten)]
   pub info: BehaviorModuleRegistration,

   pub port_names: Vec<String>,
   pub tag_names: Vec<String>,
}

let list: Vec<CustomBehaviorInfo> = serde_json::from_slice(behavior_controller().list_modules()).unwrap();

Have the specified instances process the provided messages

This is key functionality of the Behavior Controller API as it will kick off processing of messages for behavior instances in external behavior modules.

The following will happen after a call to instances_handle_messages:

  1. In order, Ark will extract the IncomingMessage’s address and send the message data to the correct behavior instance owned by some external behavior module.
  2. A behavior instance will then process the just received message.
  3. During the processing of a message, a behavior instance can create new OutgoingMessages that will be returned to the user of this API.

The user can then turn outgoing messages into incoming messages and repeat the above process.

Requests multiple insertions or updates in aspect stores; if an aspect doesn’t exist, it’s seamlessly created on the host

Requests multiple aspect removals. If the aspect store doesn’t exist, nothing happens

Reset all existing aspect stores to their initial states

Publishes the module with the given ID and returns a possibly different ID of the published version.

If the module is already published nothing will happen and the function will return the same ID as the one provided as an argument.

Loads the module with the given ID.

Returns a serialized JSON vector of bytes containing the external registration info for the loaded module.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.