Skip to main content

SymbolTable

Struct SymbolTable 

Source
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

Source

pub fn new() -> SymbolTable

Source

pub fn from_pairs<'a, I>(pairs: I) -> Result<SymbolTable, SymbolTableError>
where I: IntoIterator<Item = (&'a str, ExprValue)>,

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.

Source

pub fn set_table(&mut self, key: &str, subtable: SymbolTable)

Set a nested SymbolTable at a key (for dict-like nesting).

Source

pub fn get_table(&self, key: &str) -> Option<&SymbolTable>

Get a subtable at a key, or None.

Source

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, i64ExprValue::Int
  • boolExprValue::Bool
  • &str, StringExprValue::String
  • ExprTypeExprValue::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.

Source

pub fn set_string( &mut self, key: &str, value: &str, ) -> Result<(), SymbolTableError>

Set a string value at a dotted path (convenience).

Source

pub fn get(&self, key: &str) -> Option<&SymbolTableEntry>

Get an entry at a dotted path.

Source

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.

Source

pub fn get_string(&self, key: &str) -> Option<&str>

Get a string value at a dotted path.

Source

pub fn contains(&self, key: &str) -> bool

Source

pub fn keys(&self) -> impl Iterator<Item = &str>

Top-level keys.

Source

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.

Source

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

Source§

fn clone(&self) -> SymbolTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SymbolTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SymbolTable

Source§

fn default() -> SymbolTable

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SymbolTable

Source§

fn deserialize<D>(d: D) -> Result<SymbolTable, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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.

Source§

fn from_iter<I>(iter: I) -> SymbolTable
where I: IntoIterator<Item = (&'a str, ExprValue)>,

Creates a value from an iterator. Read more
Source§

impl Serialize for SymbolTable

Source§

fn serialize<S>( &self, s: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,