pub struct SymbolTable { /* private fields */ }Expand description
Hierarchical symbol table mapping names to values or nested tables.
Supports dotted paths: table.set("Param.Frame", 42)
creates a nested structure Param -> Frame -> 42.
Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn new() -> Self
Sourcepub fn from_pairs<'a, I>(pairs: I) -> Result<Self, SymbolTableError>
pub fn from_pairs<'a, I>(pairs: I) -> Result<Self, SymbolTableError>
Construct from a list of (dotted_key, value) pairs.
Build a SymbolTable from any iterable of (dotted_key, value) pairs.
Accepts any IntoIterator, so callers can pass Vec, arrays, iterators
(e.g., from map/filter chains), or other containers without collecting first.
Sourcepub fn set_table(&mut self, key: &str, subtable: SymbolTable)
pub fn set_table(&mut self, key: &str, subtable: SymbolTable)
Set a nested SymbolTable at a key (for dict-like nesting).
Sourcepub fn get_table(&self, key: &str) -> Option<&SymbolTable>
pub fn get_table(&self, key: &str) -> Option<&SymbolTable>
Get a subtable at a key, or None.
Sourcepub fn set(
&mut self,
key: &str,
value: impl Into<ExprValue>,
) -> Result<(), SymbolTableError>
pub fn set( &mut self, key: &str, value: impl Into<ExprValue>, ) -> Result<(), SymbolTableError>
Set a value at a dotted path, creating intermediate tables as needed.
Accepts anything convertible to ExprValue via Into:
i32,i64→ExprValue::Intbool→ExprValue::Bool&str,String→ExprValue::StringExprType→ExprValue::Unresolved(for type-checking symbol tables)ExprValue→ used directly
For floats, construct ExprValue::Float(Float64::new(v)?) explicitly.
Returns an error if an intermediate path component is already set to a
value (not a table). For example, setting "A.B.C" fails if "A.B" is
already a scalar value.
Sourcepub fn set_string(
&mut self,
key: &str,
value: &str,
) -> Result<(), SymbolTableError>
pub fn set_string( &mut self, key: &str, value: &str, ) -> Result<(), SymbolTableError>
Set a string value at a dotted path (convenience).
Sourcepub fn get(&self, key: &str) -> Option<&SymbolTableEntry>
pub fn get(&self, key: &str) -> Option<&SymbolTableEntry>
Get an entry at a dotted path.
Sourcepub fn get_value(&self, key: &str) -> Option<&ExprValue>
pub fn get_value(&self, key: &str) -> Option<&ExprValue>
Get a value at a dotted path, returning None if not found or if it’s a table.
Sourcepub fn get_string(&self, key: &str) -> Option<&str>
pub fn get_string(&self, key: &str) -> Option<&str>
Get a string value at a dotted path.
pub fn contains(&self, key: &str) -> bool
Sourcepub fn all_paths(&self, prefix: &str) -> Vec<String>
pub fn all_paths(&self, prefix: &str) -> Vec<String>
Collect all leaf symbol paths (dotted names) in this table.
If prefix is non-empty, each returned path is prefixed with
"{prefix}.". Use "" for a top-level walk.
Sourcepub fn merge_from(&mut self, other: &SymbolTable)
pub fn merge_from(&mut self, other: &SymbolTable)
Merge all entries from other into this table, overwriting on conflict.
Trait Implementations§
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§fn default() -> SymbolTable
fn default() -> SymbolTable
Source§impl<'de> Deserialize<'de> for SymbolTable
impl<'de> Deserialize<'de> for SymbolTable
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl<'a> FromIterator<(&'a str, ExprValue)> for SymbolTable
Collect (&str, ExprValue) pairs into a SymbolTable.
impl<'a> FromIterator<(&'a str, ExprValue)> for SymbolTable
Collect (&str, ExprValue) pairs into a SymbolTable.
§Panics
Panics if a dotted path conflicts with an existing non-table entry.
Use SymbolTable::set directly if you need error handling.
Auto Trait Implementations§
impl Freeze for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnsafeUnpin for SymbolTable
impl UnwindSafe for SymbolTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more