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
impl DynamicValue
Sourcepub fn from_unity_value(value: &UnityValue) -> Self
pub fn from_unity_value(value: &UnityValue) -> Self
Convert from UnityValue
Sourcepub fn to_unity_value(&self) -> UnityValue
pub fn to_unity_value(&self) -> UnityValue
Convert to UnityValue
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Get as integer
Sourcepub fn as_array(&self) -> Option<&Vec<DynamicValue>>
pub fn as_array(&self) -> Option<&Vec<DynamicValue>>
Get as array
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<DynamicValue>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<DynamicValue>>
Get as mutable array
Sourcepub fn as_object_mut(&mut self) -> Option<&mut HashMap<String, DynamicValue>>
pub fn as_object_mut(&mut self) -> Option<&mut HashMap<String, DynamicValue>>
Get as mutable object
Sourcepub fn get_index(&self, index: usize) -> Option<&DynamicValue>
pub fn get_index(&self, index: usize) -> Option<&DynamicValue>
Array indexing (similar to Python list access)
Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<&mut DynamicValue>
pub fn get_index_mut(&mut self, index: usize) -> Option<&mut DynamicValue>
Mutable array indexing
Sourcepub fn get_property(&self, key: &str) -> Option<&DynamicValue>
pub fn get_property(&self, key: &str) -> Option<&DynamicValue>
Object property access (similar to Python dict access)
Sourcepub fn get_property_mut(&mut self, key: &str) -> Option<&mut DynamicValue>
pub fn get_property_mut(&mut self, key: &str) -> Option<&mut DynamicValue>
Mutable object property access
Sourcepub fn set_property(&mut self, key: String, value: DynamicValue) -> Result<()>
pub fn set_property(&mut self, key: String, value: DynamicValue) -> Result<()>
Set object property
Sourcepub fn push(&mut self, value: DynamicValue) -> Result<()>
pub fn push(&mut self, value: DynamicValue) -> Result<()>
Add to array
Sourcepub fn concat_string(&mut self, other: &str) -> Result<()>
pub fn concat_string(&mut self, other: &str) -> Result<()>
String concatenation (Python-like += for strings)
Sourcepub fn add_numeric(&mut self, other: f64) -> Result<()>
pub fn add_numeric(&mut self, other: f64) -> Result<()>
Numeric addition (Python-like += for numbers)
Trait Implementations§
Source§impl Clone for DynamicValue
impl Clone for DynamicValue
Source§fn clone(&self) -> DynamicValue
fn clone(&self) -> DynamicValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DynamicValue
impl Debug for DynamicValue
Source§impl Display for DynamicValue
impl Display for DynamicValue
Source§impl PartialEq for DynamicValue
impl PartialEq for DynamicValue
impl StructuralPartialEq for DynamicValue
Auto Trait Implementations§
impl Freeze for DynamicValue
impl RefUnwindSafe for DynamicValue
impl Send for DynamicValue
impl Sync for DynamicValue
impl Unpin for DynamicValue
impl UnwindSafe for DynamicValue
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