Data

Enum Data 

Source
pub enum Data {
Show 14 variants Boolean(Boolean), Integer(Integer), Real(Real), String(String), Color(Color), Vector2(Vector2), Matrix3(Matrix3), BooleanVec(BooleanVec), IntegerVec(IntegerVec), RealVec(RealVec), ColorVec(ColorVec), StringVec(StringVec), Vector2Vec(Vector2Vec), Matrix3Vec(Matrix3Vec),
}
Expand description

A variant enum containing all supported data types.

Data can hold scalar values (Boolean, Integer, Real, String), vector types (Vector2, [Vector3], Color, Matrix3), and collections of these types (BooleanVec, IntegerVec, etc.).

Variants§

§

Boolean(Boolean)

A boolean value.

§

Integer(Integer)

A 64-bit signed integer.

§

Real(Real)

A 64-bit floating-point number.

§

String(String)

A UTF-8 string.

§

Color(Color)

A 4-component RGBA color.

§

Vector2(Vector2)

A 2D vector.

§

Matrix3(Matrix3)

A 3×3 transformation matrix.

§

BooleanVec(BooleanVec)

A vector of boolean values.

§

IntegerVec(IntegerVec)

A vector of integer values.

§

RealVec(RealVec)

A vector of real values.

§

ColorVec(ColorVec)

A vector of color values.

§

StringVec(StringVec)

A vector of string values.

§

Vector2Vec(Vector2Vec)

A vector of 2D vectors.

§

Matrix3Vec(Matrix3Vec)

A vector of matrices.

Implementations§

Source§

impl Data

Source

pub fn len(&self) -> usize

Get the length of a vector value, or 1 for scalar values

Source

pub fn try_len(&self) -> Option<usize>

Get the length of a vector value, or None for scalar values

Source

pub fn is_vec(&self) -> bool

If this is a vector value.

Source

pub fn to_bool(&self) -> Result<bool>

Source

pub fn to_f32(&self) -> Result<f32>

Source

pub fn to_f64(&self) -> Result<f64>

Source

pub fn to_i32(&self) -> Result<i32>

Source

pub fn to_i64(&self) -> Result<i64>

Source

pub fn as_slice_f64(&self) -> Result<&[f64]>

Source

pub fn as_slice_f32(&self) -> Result<&[f32]>

Source

pub fn as_slice_i64(&self) -> Result<&[i64]>

Source

pub fn as_vector2_ref(&self) -> Result<&[f32; 2]>

Source

pub fn as_vector3_ref(&self) -> Result<&[f32; 3]>

Source

pub fn as_matrix3_ref(&self) -> Result<&[f32; 9]>

Source

pub fn as_color_ref(&self) -> Result<&[f32; 4]>

Source

pub fn as_str(&self) -> Result<&str>

Source

pub fn as_slice_string(&self) -> Result<&[String]>

Source§

impl Data

Source

pub fn pad_to_length(&mut self, target_len: usize)

Ensure a vector value has at least the specified length by padding with defaults

Source

pub fn try_convert(&self, to: DataType) -> Result<Data>

Try to convert this value to another type

Trait Implementations§

Source§

impl Add for Data

Source§

type Output = Data

The resulting type after applying the + operator.
Source§

fn add(self, other: Data) -> Data

Performs the + operation. Read more
Source§

impl AsRef<str> for Data

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Data

Source§

fn clone(&self) -> Data

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 DataTypeOps for Data

Source§

fn data_type(&self) -> DataType

Returns the DataType variant for this value.
Source§

fn type_name(&self) -> &'static str

Returns a string name for this data type.
Source§

impl Debug for Data

Source§

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

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

impl Div<f32> for Data

Source§

type Output = Data

The resulting type after applying the / operator.
Source§

fn div(self, scalar: f32) -> Data

Performs the / operation. Read more
Source§

impl Div<f64> for Data

Source§

type Output = Data

The resulting type after applying the / operator.
Source§

fn div(self, scalar: f64) -> Data

Performs the / operation. Read more
Source§

impl<'_enum> From<&'_enum Data> for DataType

Source§

fn from(val: &'_enum Data) -> DataType

Converts to this type from the input type.
Source§

impl From<&str> for Data

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<[[f32; 3]; 3]> for Data

Available on crate feature matrix3 only.
Source§

fn from(v: [[f32; 3]; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 2]> for Data

Available on crate feature vector2 only.
Source§

fn from(v: [f32; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 4]> for Data

Source§

fn from(v: [f32; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 9]> for Data

Available on crate feature matrix3 only.
Source§

fn from(v: [f32; 9]) -> Self

Converts to this type from the input type.
Source§

impl From<Data> for Boolean

Source§

fn from(data: Data) -> Self

Converts to this type from the input type.
Source§

impl From<Data> for Color

Source§

fn from(data: Data) -> Self

Converts to this type from the input type.
Source§

impl From<Data> for DataType

Source§

fn from(val: Data) -> DataType

Converts to this type from the input type.
Source§

impl From<Data> for Integer

Source§

fn from(data: Data) -> Self

Converts to this type from the input type.
Source§

impl From<Data> for Real

Source§

fn from(data: Data) -> Self

Converts to this type from the input type.
Source§

impl From<Data> for String

Source§

fn from(data: Data) -> Self

Converts to this type from the input type.
Source§

impl From<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>> for Data

Available on crate feature vector2 only.
Source§

fn from(v: Vector2<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Matrix<f32, Const<3>, Const<3>, ArrayStorage<f32, 3, 3>>> for Data

Available on crate feature matrix3 only.
Source§

fn from(v: Matrix3<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Data

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Data

Source§

fn from(v: Vec<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u32>> for Data

Source§

fn from(v: Vec<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Data

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Data

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Data

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Data

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Data

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Data

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Data

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Data

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Data

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Data

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl Hash for Data

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoDiscriminant for Data

Source§

type Discriminant = DataType

Enum listing the same variants as this enum but without any data fields
Source§

fn discriminant(&self) -> Self::Discriminant

Source§

impl Mul<f32> for Data

Source§

type Output = Data

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f32) -> Data

Performs the * operation. Read more
Source§

impl Mul<f64> for Data

Source§

type Output = Data

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f64) -> Data

Performs the * operation. Read more
Source§

impl PartialEq for Data

Source§

fn eq(&self, other: &Data) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for Data

Source§

type Output = Data

The resulting type after applying the - operator.
Source§

fn sub(self, other: Data) -> Data

Performs the - operation. Read more
Source§

impl TryFrom<&Data> for [f32; 4]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vector2<f32>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Matrix3<f32>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for String

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<[f32; 4]>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<Vector2<f32>>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<Matrix3<f32>>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<String>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<bool>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<f64>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for Vec<i64>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for bool

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for f64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Data> for i64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for [f32; 4]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vector2<f32>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Matrix3<f32>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for String

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<[f32; 4]>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<Vector2<f32>>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<Matrix3<f32>>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<String>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<bool>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<f64>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for Vec<i64>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for bool

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for f64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Data> for i64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Data) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<&str>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<&str>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<[f32; 4]>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<[f32; 4]>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>>> for Data

Available on crate features vector2 and vec_variants only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<Vector2<f32>>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<Matrix<f32, Const<3>, Const<3>, ArrayStorage<f32, 3, 3>>>> for Data

Available on crate features matrix3 and vec_variants only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<Matrix3<f32>>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<String>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<String>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<bool>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<bool>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<f64>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<f64>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<i64>> for Data

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<i64>) -> Result<Self>

Performs the conversion.
Source§

impl Eq for Data

Source§

impl StructuralPartialEq for Data

Auto Trait Implementations§

§

impl Freeze for Data

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnwindSafe for Data

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> Scalar for T
where T: 'static + Clone + PartialEq + Debug,