pub struct VariablePool { /* private fields */ }Expand description
Variable storage for one execution frame.
Implementations§
Source§impl VariablePool
impl VariablePool
pub fn new() -> Self
Sourcepub fn get(&self, selector: &Selector) -> Option<Value>
pub fn get(&self, selector: &Selector) -> Option<Value>
Resolve a selector, descending into nested values. Missing values return None.
Sourcepub fn get_or_null(&self, selector: &Selector) -> Value
pub fn get_or_null(&self, selector: &Selector) -> Value
Resolve a selector, returning Value::Null when absent.
Sourcepub fn set(&mut self, selector: &Selector, value: Value)
pub fn set(&mut self, selector: &Selector, value: Value)
Set namespace.name. Any path in the selector is ignored; use VariablePool::set_path
for nested writes.
Sourcepub fn insert(&mut self, namespace: &str, name: &str, value: Value)
pub fn insert(&mut self, namespace: &str, name: &str, value: Value)
Set a variable by namespace and name.
Sourcepub fn set_path(
&mut self,
selector: &Selector,
value: Value,
) -> Result<(), PathError>
pub fn set_path( &mut self, selector: &Selector, value: Value, ) -> Result<(), PathError>
Write into a nested path, creating intermediate objects as needed. Array elements are addressed by index; writing past the end of an array is an error (nothing is written).
Sourcepub fn remove_namespace(&mut self, namespace: &str)
pub fn remove_namespace(&mut self, namespace: &str)
Drop a whole namespace (e.g. a node’s outputs before a loop round re-runs it).
Sourcepub fn set_outputs(&mut self, namespace: &str, outputs: &Variables)
pub fn set_outputs(&mut self, namespace: &str, outputs: &Variables)
Bulk-insert a node’s outputs. Into an empty namespace this shares
outputs instead of copying it.
pub fn contains(&self, selector: &Selector) -> bool
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str, &Value)>
Iterate (namespace, name, value).
Sourcepub fn to_snapshot(&self) -> PoolSnapshot
pub fn to_snapshot(&self) -> PoolSnapshot
Serializable form for snapshots. The ENV namespace is excluded: the host
must supply environment variables again on resume. Secrets in other
namespaces are stored as {"$secret": "redacted"} markers and restored as
redacted secrets (see Value::redacted_secret).
Sourcepub fn from_snapshot(snapshot: PoolSnapshot) -> Self
pub fn from_snapshot(snapshot: PoolSnapshot) -> Self
Restore from a snapshot (env variables must be re-applied by the caller).
Sourcepub fn insert_typed(
&mut self,
namespace: &str,
name: &str,
ty: ValueType,
value: Value,
) -> Result<(), TypeMismatch>
pub fn insert_typed( &mut self, namespace: &str, name: &str, ty: ValueType, value: Value, ) -> Result<(), TypeMismatch>
Insert a typed declared variable, validating it against its declared type.