pub enum Value {
Float(f64),
Int(i64),
Str(String),
KeyVal((Box<Value>, Box<Value>)),
Array(Vec<Value>),
Null,
}
artemis
only.Expand description
Represents a value in LUA table
Variants§
Float(f64)
Float number
Int(i64)
Integer number
Str(String)
String value
KeyVal((Box<Value>, Box<Value>))
Key value pair
Array(Vec<Value>)
Array of values
Null
Null(nli) value
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a reference to the string if the value is a string, otherwise returns None.
Sourcepub fn as_string(&self) -> Option<String>
pub fn as_string(&self) -> Option<String>
Returns a string if the value is a string, otherwise returns None.
Sourcepub fn find_array(&self, key: &str) -> &Value
pub fn find_array(&self, key: &str) -> &Value
Find a nested array by key (first value of nested array).
If the key is not found, it returns a reference to NULL
.
§Example
{
{"save", text="test"},
}
for above array, calling find_array("save")
will return the entire array {"save", text="test"}
.
Sourcepub fn find_array_mut(&mut self, key: &str) -> &mut Value
pub fn find_array_mut(&mut self, key: &str) -> &mut Value
Find a nested array by key (first value of nested array). If the key is not found, it creates a new array with the key and returns a mutable reference to it.
§Example
{
{"save", text="test"},
}
for above array, calling find_array_mut("save")
will return a mutable reference to the array {"save", text="test"}
.
Sourcepub fn kv_key(&self) -> Option<&Value>
pub fn kv_key(&self) -> Option<&Value>
Returns the key of a key-value pair if it exists, otherwise returns None.
Sourcepub fn kv_keys<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Value> + 'a>
pub fn kv_keys<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Value> + 'a>
Returns the keys in a lua table.
Sourcepub fn last_member(&self) -> &Value
pub fn last_member(&self) -> &Value
Returns the last member of the array if it exists, otherwise returns a reference to NULL
.
Sourcepub fn last_member_mut(&mut self) -> &mut Value
pub fn last_member_mut(&mut self) -> &mut Value
Returns a mutable reference to the last member of the array.
If the array is empty, it creates a new member with NULL
and returns it.
If the value is not an array, it converts it to an array with a single NULL
member.
Sourcepub fn insert_member(&mut self, index: usize, value: Value)
pub fn insert_member(&mut self, index: usize, value: Value)
Inserts a member at the specified index in the array.
If the index is out of bounds, it appends the value to the end of the array. If the value is not an array, it converts it to an array with a single member.
Sourcepub fn members_mut<'a>(&'a mut self) -> IterMut<'a> ⓘ
pub fn members_mut<'a>(&'a mut self) -> IterMut<'a> ⓘ
Returns a mutable iterator over the members of the array.
Sourcepub fn new_kv<K: Into<Value>, V: Into<Value>>(key: K, value: V) -> Self
pub fn new_kv<K: Into<Value>, V: Into<Value>>(key: K, value: V) -> Self
Creates a new key-value pair.
Sourcepub fn push_member(&mut self, value: Value)
pub fn push_member(&mut self, value: Value)
Pushes a member to the end of the array.
Sourcepub fn set_string<S: Into<String>>(&mut self, value: S)
pub fn set_string<S: Into<String>>(&mut self, value: S)
Sets the value to a string.
Trait Implementations§
Source§impl PartialOrd<f64> for Box<Value>
impl PartialOrd<f64> for Box<Value>
Source§impl PartialOrd<f64> for Value
impl PartialOrd<f64> for Value
Source§impl PartialOrd<i64> for Box<Value>
impl PartialOrd<i64> for Box<Value>
Source§impl PartialOrd<i64> for Value
impl PartialOrd<i64> for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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