pub struct SymbolicContext { /* private fields */ }
Expand description
SymbolicContext for SOMA: variable memory and path resolution
Implementations§
Source§impl SymbolicContext
impl SymbolicContext
pub fn new() -> Self
pub fn set(&mut self, key: &str, value: &str)
pub fn set_with_meta(&mut self, key: &str, value: &str, meta: SymbolicKeyMeta)
pub fn merge(&mut self, other: &SymbolicContext)
pub fn get(&self, key: &str) -> Option<&String>
pub fn set_child(&mut self, name: &str, ctx: SymbolicContext)
pub fn get_child(&self, name: &str) -> Option<&SymbolicContext>
Sourcepub fn resolve_path(&self, path: &str) -> Option<String>
pub fn resolve_path(&self, path: &str) -> Option<String>
Resolves a nested dotted path, traversing children if needed
pub fn enter_scope(&mut self, scope: &str) -> &mut SymbolicContext
pub fn set_ttl(&mut self, key: &str, ttl: StdDuration)
pub fn cleanup_expired(&mut self)
Sourcepub fn flatten(&self) -> HashMap<String, String>
pub fn flatten(&self) -> HashMap<String, String>
Returns a flattened HashMap with dot notation keys
Sourcepub fn diff(&self, other: &Self) -> SymbolicDiff
pub fn diff(&self, other: &Self) -> SymbolicDiff
Computes the diff between two SymbolicContexts
Sourcepub fn resolve_as_type<T: DeserializeOwned>(&self, path: &str) -> Option<T>
pub fn resolve_as_type<T: DeserializeOwned>(&self, path: &str) -> Option<T>
Resolves a path and deserializes the value as type T
Sourcepub fn interpolate(&self, input: &str) -> String
pub fn interpolate(&self, input: &str) -> String
Interpolates variables like “${goal_1.location}” in a string
Sourcepub fn resolve_or_default(&self, path: &str, default: &str) -> String
pub fn resolve_or_default(&self, path: &str, default: &str) -> String
Returns the resolved value or a default if not found
Sourcepub fn restore(&mut self, snapshot: HashMap<String, String>)
pub fn restore(&mut self, snapshot: HashMap<String, String>)
Optional: restore memory from a snapshot
Sourcepub fn to_symbolic_ir(&self) -> Value
pub fn to_symbolic_ir(&self) -> Value
Exports the context and its children as a symbolic IR (intermediate representation)
Trait Implementations§
Source§impl Clone for SymbolicContext
impl Clone for SymbolicContext
Source§fn clone(&self) -> SymbolicContext
fn clone(&self) -> SymbolicContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SymbolicContext
impl Debug for SymbolicContext
Source§impl<'de> Deserialize<'de> for SymbolicContext
impl<'de> Deserialize<'de> for SymbolicContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SymbolicContext
impl RefUnwindSafe for SymbolicContext
impl Send for SymbolicContext
impl Sync for SymbolicContext
impl Unpin for SymbolicContext
impl UnwindSafe for SymbolicContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more