pub struct ActorContext {
pub payload: ActorPayload,
pub outports: Port,
pub state: Arc<Mutex<dyn ActorState>>,
pub config: ActorConfig,
/* private fields */
}Fields§
§payload: ActorPayload§outports: Port§state: Arc<Mutex<dyn ActorState>>§config: ActorConfigImplementations§
Source§impl ActorContext
impl ActorContext
pub fn new( payload: ActorPayload, outports: Port, state: Arc<Mutex<dyn ActorState>>, config: ActorConfig, load: Arc<ActorLoad>, ) -> Self
pub fn get_state(&self) -> Arc<Mutex<dyn ActorState>>
pub fn get_config(&self) -> &ActorConfig
Sourcepub fn get_config_hashmap(&self) -> HashMap<String, Value>
pub fn get_config_hashmap(&self) -> HashMap<String, Value>
Get config as HashMap for backwards compatibility
pub fn get_load(&self) -> Arc<ActorLoad>
pub fn get_payload(&self) -> &ActorPayload
pub fn get_outports(&self) -> Port
pub fn done(&self)
Sourcepub fn pool_upsert(&self, pool_name: &str, id: &str, value: Value)
pub fn pool_upsert(&self, pool_name: &str, id: &str, value: Value)
Upsert an object into the actor’s state pool by ID.
Multiple connections can feed into the same port. Each call
adds or updates an entry keyed by id. The actor reads the
full pool via get_pool() on each invocation.
// Each connected instance sends its data:
context.pool_upsert("objects", "tree_01", json!({ "mesh": ..., "pos": [1,0,0] }));
// Later, read all:
let all_objects = context.get_pool("objects"); // Vec<Value>Pool helpers are native-only — the wasm MemoryState exposes a
JS-shaped API (get(key) -> JsValue) instead of the
Option<&Value> shape these helpers were written against.
Browser actors can implement equivalent logic on top of
MemoryState::get / set directly.
Sourcepub fn pool_remove(&self, pool_name: &str, id: &str)
pub fn pool_remove(&self, pool_name: &str, id: &str)
Remove an object from the pool by ID.
Sourcepub fn get_pool(&self, pool_name: &str) -> Vec<(String, Value)>
pub fn get_pool(&self, pool_name: &str) -> Vec<(String, Value)>
Read all objects from a pool as a Vec.
Returns (id, value) pairs.
Sourcepub fn pool_count(&self, pool_name: &str) -> usize
pub fn pool_count(&self, pool_name: &str) -> usize
Get the number of objects in a pool.
Sourcepub fn pool_clear(&self, pool_name: &str)
pub fn pool_clear(&self, pool_name: &str)
Clear all objects from a pool.
Sourcepub fn create_stream(
&self,
port_name: &str,
content_type: Option<String>,
size_hint: Option<u64>,
buffer_size: Option<usize>,
) -> (Sender<StreamFrame>, StreamHandle)
pub fn create_stream( &self, port_name: &str, content_type: Option<String>, size_hint: Option<u64>, buffer_size: Option<usize>, ) -> (Sender<StreamFrame>, StreamHandle)
Create a new outbound data stream.
Returns a (sender, StreamHandle) pair. The actor pushes
StreamFrames into the sender and includes the StreamHandle
in its output HashMap (via Message::stream_handle).
The downstream actor will use [take_stream_receiver] to consume.
buffer_size controls backpressure — when the bounded channel is
full, sender.send_async().await will suspend the producer.
Sourcepub fn take_stream_receiver(
&self,
port_name: &str,
) -> Option<Receiver<StreamFrame>>
pub fn take_stream_receiver( &self, port_name: &str, ) -> Option<Receiver<StreamFrame>>
Take the receiver for a stream that arrived on an inport.
Looks up the StreamHandle in the payload for port_name and
extracts the bounded channel receiver from the global registry.
Returns None if the port doesn’t contain a StreamHandle or
the receiver has already been taken.