pub enum Value {
String(String),
Float(f64),
Integer(i64),
Boolean(bool),
List(Vec<Value>),
Map(VariableMap),
Table(Table),
Time(Time),
Function(Function),
Empty,
}Expand description
Whale value representation.
Every whale 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§
String(String)
Float(f64)
Integer(i64)
Boolean(bool)
List(Vec<Value>)
Map(VariableMap)
Table(Table)
Time(Time)
Function(Function)
Empty
Implementations§
source§impl Value
impl Value
pub fn value_type(&self) -> ValueType
pub fn is_table(&self) -> bool
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_empty(&self) -> bool
pub fn is_map(&self) -> bool
pub fn is_function(&self) -> bool
sourcepub fn as_string(&self) -> Result<&String>
pub fn as_string(&self) -> Result<&String>
Borrows the value stored in self as String, or returns Err if self is not a Value::String.
sourcepub fn as_int(&self) -> Result<i64>
pub fn as_int(&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 Value::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 Value::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 Value::Boolean.
sourcepub fn as_list(&self) -> Result<&Vec<Value>>
pub fn as_list(&self) -> Result<&Vec<Value>>
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<Vec<Value>>
pub fn into_inner_list(self) -> Result<Vec<Value>>
Borrows the value stored in self as Vec<Value>, or returns Err if self is not a Value::List.
sourcepub fn as_fixed_len_list(&self, len: usize) -> Result<&Vec<Value>>
pub fn as_fixed_len_list(&self, len: usize) -> Result<&Vec<Value>>
Borrows the value stored in self as Vec<Value> or returns Err if self is not a Value::Map of the required length.
sourcepub fn as_map(&self) -> Result<&VariableMap>
pub fn as_map(&self) -> Result<&VariableMap>
Borrows the value stored in self as Vec<Value>, or returns Err if self is not a Value::Map.
sourcepub fn as_table(&self) -> Result<&Table>
pub fn as_table(&self) -> Result<&Table>
Borrows the value stored in self as Vec<Value>, or returns Err if self is not a Value::Table.
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<'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 IntoIterator for Value
impl IntoIterator for Value
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
source§impl PartialOrd<Value> for Value
impl PartialOrd<Value> 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 moreimpl Eq for Value
impl StructuralPartialEq 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> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.