DynamicValue

Enum DynamicValue 

Source
pub enum DynamicValue {
    String(String),
    Integer(i64),
    Float(f64),
    Bool(bool),
    Array(Vec<DynamicValue>),
    Object(HashMap<String, DynamicValue>),
    Null,
}
Expand description

Dynamic value wrapper that supports Python-like operations

Variants§

§

String(String)

String value

§

Integer(i64)

Integer value

§

Float(f64)

Float value

§

Bool(bool)

Boolean value

§

Array(Vec<DynamicValue>)

Array value

§

Object(HashMap<String, DynamicValue>)

Object value

§

Null

Null value

Implementations§

Source§

impl DynamicValue

Source

pub fn from_unity_value(value: &UnityValue) -> Self

Convert from UnityValue

Source

pub fn to_unity_value(&self) -> UnityValue

Convert to UnityValue

Source

pub fn as_string(&self) -> Option<&str>

Get as string

Source

pub fn as_integer(&self) -> Option<i64>

Get as integer

Source

pub fn as_float(&self) -> Option<f64>

Get as float

Source

pub fn as_bool(&self) -> Option<bool>

Get as boolean

Source

pub fn as_array(&self) -> Option<&Vec<DynamicValue>>

Get as array

Source

pub fn as_array_mut(&mut self) -> Option<&mut Vec<DynamicValue>>

Get as mutable array

Source

pub fn as_object(&self) -> Option<&HashMap<String, DynamicValue>>

Get as object

Source

pub fn as_object_mut(&mut self) -> Option<&mut HashMap<String, DynamicValue>>

Get as mutable object

Source

pub fn is_null(&self) -> bool

Check if value is null

Source

pub fn get_index(&self, index: usize) -> Option<&DynamicValue>

Array indexing (similar to Python list access)

Source

pub fn get_index_mut(&mut self, index: usize) -> Option<&mut DynamicValue>

Mutable array indexing

Source

pub fn get_property(&self, key: &str) -> Option<&DynamicValue>

Object property access (similar to Python dict access)

Source

pub fn get_property_mut(&mut self, key: &str) -> Option<&mut DynamicValue>

Mutable object property access

Source

pub fn set_property(&mut self, key: String, value: DynamicValue) -> Result<()>

Set object property

Source

pub fn push(&mut self, value: DynamicValue) -> Result<()>

Add to array

Source

pub fn concat_string(&mut self, other: &str) -> Result<()>

String concatenation (Python-like += for strings)

Source

pub fn add_numeric(&mut self, other: f64) -> Result<()>

Numeric addition (Python-like += for numbers)

Trait Implementations§

Source§

impl Clone for DynamicValue

Source§

fn clone(&self) -> DynamicValue

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 DynamicValue

Source§

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

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

impl Display for DynamicValue

Source§

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

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

impl PartialEq for DynamicValue

Source§

fn eq(&self, other: &DynamicValue) -> 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 StructuralPartialEq for DynamicValue

Auto Trait Implementations§

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.