Enum Value

Source
pub enum Value {
    Float(f64),
    Int(i64),
    Str(String),
    KeyVal((Box<Value>, Box<Value>)),
    Array(Vec<Value>),
    Null,
}
Available on crate feature 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

Source

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

Returns a reference to the string if the value is a string, otherwise returns None.

Source

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

Returns a string if the value is a string, otherwise returns None.

Source

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"}.

Source

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"}.

Source

pub fn is_array(&self) -> bool

Returns true if the value is an array.

Source

pub fn is_str(&self) -> bool

Returns true if the value is a string.

Source

pub fn is_kv(&self) -> bool

Returns true if the value is a key-value pair.

Source

pub fn is_null(&self) -> bool

Returns true if the value is null.

Source

pub fn kv_key(&self) -> Option<&Value>

Returns the key of a key-value pair if it exists, otherwise returns None.

Source

pub fn kv_keys<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Value> + 'a>

Returns the keys in a lua table.

Source

pub fn last_member(&self) -> &Value

Returns the last member of the array if it exists, otherwise returns a reference to NULL.

Source

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.

Source

pub fn len(&self) -> usize

Returns the length of the array.

Source

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.

Source

pub fn members<'a>(&'a self) -> Iter<'a>

Returns an iterator over the members of the array.

Source

pub fn members_mut<'a>(&'a mut self) -> IterMut<'a>

Returns a mutable iterator over the members of the array.

Source

pub fn new_array() -> Self

Creates a new empty array.

Source

pub fn new_kv<K: Into<Value>, V: Into<Value>>(key: K, value: V) -> Self

Creates a new key-value pair.

Source

pub fn push_member(&mut self, value: Value)

Pushes a member to the end of the array.

Source

pub fn set_str<S: AsRef<str> + ?Sized>(&mut self, value: &S)

Sets the value to a string.

Source

pub fn set_string<S: Into<String>>(&mut self, value: S)

Sets the value to a string.

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

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

impl<'a> From<&'a str> for Value

Source§

fn from(s: &'a str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl<'a> Index<&'a Box<Value>> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &'a Box<Value>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, 'b> Index<&'b Key<'a>> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &'b Key<'a>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<&'a String> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &'a String) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<&'a Value> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &'a Value) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<&'a str> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &'a str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> Index<Key<'a>> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: Key<'a>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<NumKey<f64>> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: NumKey<f64>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<NumKey<i64>> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: NumKey<i64>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<String> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: String) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, 'b> IndexMut<&'b Key<'a>> for Value

Source§

fn index_mut(&mut self, key: &'b Key<'a>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<&'a String> for Value

Source§

fn index_mut(&mut self, index: &'a String) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<&'a Value> for Value

Source§

fn index_mut(&mut self, index: &'a Value) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<&'a str> for Value

Source§

fn index_mut(&mut self, index: &'a str) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IndexMut<Key<'a>> for Value

Source§

fn index_mut(&mut self, key: Key<'a>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<NumKey<f64>> for Value

Source§

fn index_mut(&mut self, key: NumKey<f64>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<NumKey<i64>> for Value

Source§

fn index_mut(&mut self, key: NumKey<i64>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<String> for Value

Source§

fn index_mut(&mut self, index: String) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for Value

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq<String> for Box<Value>

Source§

fn eq(&self, other: &String) -> 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 PartialEq<String> for Value

Source§

fn eq(&self, other: &String) -> 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 PartialEq<Value> for Box<Value>

Source§

fn eq(&self, other: &Value) -> 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<'a> PartialEq<f64> for &'a Box<Value>

Source§

fn eq(&self, other: &f64) -> 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 PartialEq<f64> for Box<Value>

Source§

fn eq(&self, other: &f64) -> 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 PartialEq<f64> for Value

Source§

fn eq(&self, other: &f64) -> 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<'a> PartialEq<i64> for &'a Box<Value>

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<i64> for Box<Value>

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<i64> for Value

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<str> for Box<Value>

Source§

fn eq(&self, other: &str) -> 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 PartialEq<str> for Value

Source§

fn eq(&self, other: &str) -> 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 PartialEq for Value

Source§

fn eq(&self, other: &Value) -> 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 PartialOrd<f64> for Box<Value>

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for Value

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i64> for Box<Value>

Source§

fn partial_cmp(&self, other: &i64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<i64> for Value

Source§

fn partial_cmp(&self, other: &i64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AnyDebug for T
where T: Debug + Any,

Source§

impl<T> ErasedDestructor for T
where T: 'static,