Skip to main content

Value

Enum Value 

Source
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

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

Source

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));
Source

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));
Source

pub fn as_bool(self) -> Option<Boolean>

Attempts to extract the underlying boolean value.

Consumes self and returns the contained Boolean if this is Value::Bool, otherwise returns None.

Source

pub fn as_text(self) -> Option<Text>

Attempts to extract the underlying string value.

Consumes self and returns the contained Text if this is Value::Str, otherwise returns None.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl Default for Value

Source§

fn default() -> Value

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

impl Display for Value

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.