pub enum FoamValue {
Scalar(f64),
Word(String),
Str(String),
List(Vec<FoamValue>),
Dict(FoamDict),
}Expand description
A leaf value inside a list or a bare token sequence.
Variants§
Scalar(f64)
A numeric scalar.
Word(String)
A bare identifier / keyword-like word (e.g. ascii, Gauss, PCG,
or a function-style grad(U)).
Str(String)
A "…" quoted string (stored without the surrounding quotes).
List(Vec<FoamValue>)
A parenthesised ( … ) list of values (may nest).
Dict(FoamDict)
A { … } sub-dictionary appearing as a list element.
OpenFOAM lists routinely carry dictionaries: constant/polyMesh/boundary
and cellZones are N ( name { … } name { … } ), and GeN-Foam’s
nuclearData writes its states and zones the same way. Without this
variant the braces tokenise into stray Words and the
entry silently flattens into nonsense rather than failing.
The name preceding each such dictionary is a separate
Word element in the enclosing list — this variant holds
only the braced body, exactly as the grammar has it.
Implementations§
Source§impl FoamValue
impl FoamValue
Sourcepub fn as_vector3(&self) -> Option<Vector3>
pub fn as_vector3(&self) -> Option<Vector3>
Interpret a List of exactly three scalars as a Vector3; returns
None for any other shape.
Sourcepub fn as_scalar(&self) -> Option<f64>
pub fn as_scalar(&self) -> Option<f64>
The scalar value, if this is a FoamValue::Scalar.
Sourcepub fn as_word(&self) -> Option<&str>
pub fn as_word(&self) -> Option<&str>
The word text, if this is a FoamValue::Word.