pub enum Value {
Show 13 variants
Integer(Integer),
Float(FloatNum),
Bool(Boolean),
Str(Text),
VecInteger(Vec<Integer>, u32),
VecFloat(Vec<FloatNum>, u32),
VecBool(Vec<Boolean>, u32),
VecText(Vec<Text>, u32),
MatrixInteger(Vec<Vec<Integer>>, (u32, u32)),
MatrixFloat(Vec<Vec<FloatNum>>, (u32, u32)),
MatrixBool(Vec<Vec<Boolean>>, (u32, u32)),
MatrixText(Vec<Vec<Text>>, (u32, u32)),
Unsupported,
}Expand description
A dynamically-typed container for extended XYZ property values.
Value represents the different data types that can appear in extended
XYZ metadata or per-atom properties. It supports scalar values, vectors,
and matrices across several primitive types.
§Variants
§Scalar values
Integer: A single integer value.Float: A single floating-point value.Bool: A boolean value.Str: A string value.
§Vector values
VecInteger(Vec<Integer>, u32): A vector of integers and its length.VecFloat(Vec<FloatNum>, u32): A vector of floats and its length.VecBool(Vec<Boolean>, u32): A vector of booleans and its length.VecText(Vec<Text>, u32): A vector of strings and its length.
§Matrix values
MatrixInteger(Vec<Vec<Integer>>, (u32, u32)): A 2D array of integers with shape(rows, cols).MatrixFloat(Vec<Vec<FloatNum>>, (u32, u32)): A 2D array of floats with shape(rows, cols).MatrixBool(Vec<Vec<Boolean>>, (u32, u32)): A 2D array of booleans with shape(rows, cols).MatrixText(Vec<Vec<Text>>, (u32, u32)): A 2D array of strings with shape(rows, cols).
§Fallback
Unsupported: Represents values that could not be parsed or are not supported by the current implementation. This is also the default variant.
§Notes
- Vector variants store their length explicitly to preserve shape information from the original input.
- Matrix variants store both the data and its
(rows, cols)dimensions. - This enum is designed for flexibility when parsing loosely-typed formats such as extended XYZ.
§Derives
Debug,Clone, andDefaultare implemented.- The default value is
Value::Unsupported.
Variants§
Integer(Integer)
Float(FloatNum)
Bool(Boolean)
Str(Text)
VecInteger(Vec<Integer>, u32)
VecFloat(Vec<FloatNum>, u32)
VecBool(Vec<Boolean>, u32)
VecText(Vec<Text>, u32)
MatrixInteger(Vec<Vec<Integer>>, (u32, u32))
MatrixFloat(Vec<Vec<FloatNum>>, (u32, u32))
MatrixBool(Vec<Vec<Boolean>>, (u32, u32))
MatrixText(Vec<Vec<Text>>, (u32, u32))
Unsupported
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_integer(self) -> Option<Integer>
pub fn as_integer(self) -> Option<Integer>
Attempts to extract the underlying integer value.
Consumes self and returns the contained Integer if this is
Value::Integer, otherwise returns None.
§Examples
use extxyz_types::{Value, Integer};
let v = Value::Integer(Integer::from(42));Sourcepub fn as_float(self) -> Option<FloatNum>
pub fn as_float(self) -> Option<FloatNum>
Attempts to extract the underlying floating-point value.
Consumes self and returns the contained FloatNum if this is
Value::Float, otherwise returns None.
§Examples
use extxyz_types::{Value, FloatNum};
let v = Value::Float(FloatNum::from(3.14));Trait Implementations§
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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