pub struct SomniStruct<T: TypeSet = DefaultTypeSet> { /* private fields */ }Expand description
A struct value: a struct name plus its fields, keyed by field name.
This is the runtime representation of a Somni struct and doubles as the Rust-side boundary type. Field values are stored by name; the field order in the map reflects the struct’s declaration order.
The entire representation lives behind a single Box, so SomniStruct
(and therefore TypedValue, which embeds it by value) is only one pointer
wide. Inlining the name and the IndexMap would bloat every value the
evaluator moves and clones on its hot paths. The internals are reached through
name, fields, fields_mut
and into_parts.
Implementations§
Source§impl<T: TypeSet> SomniStruct<T>
impl<T: TypeSet> SomniStruct<T>
Sourcepub fn new(name: Box<str>, fields: IndexMap<Box<str>, TypedValue<T>>) -> Self
pub fn new(name: Box<str>, fields: IndexMap<Box<str>, TypedValue<T>>) -> Self
Creates a struct value from its name and fields.
Sourcepub fn fields(&self) -> &IndexMap<Box<str>, TypedValue<T>>
pub fn fields(&self) -> &IndexMap<Box<str>, TypedValue<T>>
Returns the struct’s fields, keyed by field name, in declaration order.
Sourcepub fn fields_mut(&mut self) -> &mut IndexMap<Box<str>, TypedValue<T>>
pub fn fields_mut(&mut self) -> &mut IndexMap<Box<str>, TypedValue<T>>
Returns a mutable reference to the struct’s fields.
Sourcepub fn into_parts(self) -> (Box<str>, IndexMap<Box<str>, TypedValue<T>>)
pub fn into_parts(self) -> (Box<str>, IndexMap<Box<str>, TypedValue<T>>)
Consumes the struct, returning its name and fields.