pub enum Value {
List(List),
Map(Map),
Function(Function),
String(Arc<RwLock<String>>),
Float(f64),
Integer(i64),
Boolean(bool),
Option(Option<Box<Value>>),
}Expand description
Dust value representation.
Every dust variable has a key and a Value. Variables are represented by storing them in a VariableMap. This means the map of variables is itself a value that can be treated as any other.
Variants§
List(List)
Map(Map)
Function(Function)
String(Arc<RwLock<String>>)
Float(f64)
Integer(i64)
Boolean(bool)
Option(Option<Box<Value>>)
Implementations§
source§impl Value
impl Value
pub fn string<T: Into<String>>(string: T) -> Self
pub fn type(&self) -> Type
pub fn none() -> Self
pub fn some(value: Value) -> Self
pub fn option(option: Option<Value>) -> Self
pub fn is_string(&self) -> bool
pub fn is_integer(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_list(&self) -> bool
pub fn is_option(&self) -> bool
pub fn is_none(&self) -> bool
pub fn is_map(&self) -> bool
pub fn is_function(&self) -> bool
sourcepub fn as_string(&self) -> Result<RwLockReadGuard<'_, String>>
pub fn as_string(&self) -> Result<RwLockReadGuard<'_, String>>
Borrows the value stored in self as &str, or returns Err if self is not a Value::String.
sourcepub fn as_string_mut(&self) -> Result<RwLockWriteGuard<'_, String>>
pub fn as_string_mut(&self) -> Result<RwLockWriteGuard<'_, String>>
Borrows the value stored in self as String, or returns Err if self is not a Value::String.
sourcepub fn as_integer(&self) -> Result<i64>
pub fn as_integer(&self) -> Result<i64>
Copies the value stored in self as i64, or returns Err if self is not a Value::Int.
sourcepub fn as_float(&self) -> Result<f64>
pub fn as_float(&self) -> Result<f64>
Copies the value stored in self as f64, or returns Err if self is not a Primitive::Float.
sourcepub fn as_number(&self) -> Result<f64>
pub fn as_number(&self) -> Result<f64>
Copies the value stored in self as f64, or returns Err if self is not a Primitive::Float or Value::Int.
Note that this method silently converts i64 to f64, if self is a Value::Int.
sourcepub fn as_boolean(&self) -> Result<bool>
pub fn as_boolean(&self) -> Result<bool>
Copies the value stored in self as bool, or returns Err if self is not a Primitive::Boolean.
sourcepub fn as_list(&self) -> Result<&List>
pub fn as_list(&self) -> Result<&List>
Borrows the value stored in self as Vec<Value>, or returns Err if self is not a Value::List.
sourcepub fn into_inner_list(self) -> Result<List>
pub fn into_inner_list(self) -> Result<List>
Takes ownership of the value stored in self as Vec<Value>, or returns Err if self is not a Value::List.
sourcepub fn as_map(&self) -> Result<&Map>
pub fn as_map(&self) -> Result<&Map>
Borrows the value stored in self as Vec<Value>, or returns Err if self is not a Value::Map.
sourcepub fn as_function(&self) -> Result<&Function>
pub fn as_function(&self) -> Result<&Function>
Borrows the value stored in self as Function, or returns Err if
self is not a Value::Function.
Trait Implementations§
source§impl AddAssign for Value
impl AddAssign for Value
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moresource§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl SubAssign for Value
impl SubAssign for Value
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read moreimpl Eq for Value
Auto Trait Implementations§
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.