Skip to main content

ActorContext

Struct ActorContext 

Source
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: ActorConfig

Implementations§

Source§

impl ActorContext

Source

pub fn new( payload: ActorPayload, outports: Port, state: Arc<Mutex<dyn ActorState>>, config: ActorConfig, load: Arc<ActorLoad>, ) -> Self

Source

pub fn get_state(&self) -> Arc<Mutex<dyn ActorState>>

Source

pub fn get_config(&self) -> &ActorConfig

Source

pub fn get_config_hashmap(&self) -> HashMap<String, Value>

Get config as HashMap for backwards compatibility

Source

pub fn get_load(&self) -> Arc<ActorLoad>

Source

pub fn get_payload(&self) -> &ActorPayload

Source

pub fn get_outports(&self) -> Port

Source

pub fn done(&self)

Source

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.

Source

pub fn pool_remove(&self, pool_name: &str, id: &str)

Remove an object from the pool by ID.

Source

pub fn get_pool(&self, pool_name: &str) -> Vec<(String, Value)>

Read all objects from a pool as a Vec. Returns (id, value) pairs.

Source

pub fn pool_count(&self, pool_name: &str) -> usize

Get the number of objects in a pool.

Source

pub fn pool_clear(&self, pool_name: &str)

Clear all objects from a pool.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,