Enum dust_lib::Value

source ·
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

source

pub fn value_type(&self) -> ValueType

source

pub fn is_table(&self) -> bool

source

pub fn is_string(&self) -> bool

source

pub fn is_integer(&self) -> bool

source

pub fn is_float(&self) -> bool

source

pub fn is_number(&self) -> bool

source

pub fn is_boolean(&self) -> bool

source

pub fn is_list(&self) -> bool

source

pub fn is_empty(&self) -> bool

source

pub fn is_map(&self) -> bool

source

pub fn is_function(&self) -> bool

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn as_time(&self) -> Result<&Time>

Borrows the value stored in self as Time, or returns Err if self is not a Value::Time.

source

pub fn as_empty(&self) -> Result<()>

Returns (), or returnsErr if self is not a Value::Tuple.

source

pub fn to_table(&self) -> Result<Table>

Returns an owned table, either by cloning or converting the inner value..

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy 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 Default for Value

source§

fn default() -> Value

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Value

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

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

impl From<&Value> for Table

source§

fn from(value: &Value) -> Self

Converts to this type from the input type.
source§

impl From<&Value> for ValueType

source§

fn from(value: &Value) -> Self

Converts to this type from the input type.
source§

impl From<&mut Value> for ValueType

source§

fn from(value: &mut Value) -> Self

Converts to this type from the input type.
source§

impl From<&str> for Value

source§

fn from(string: &str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Value

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(string: String) -> Self

Converts to this type from the input type.
source§

impl From<Value> for Result<Value>

source§

fn from(value: Value) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Value, Global>> for Value

source§

fn from(tuple: Vec<Value>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(boolean: bool) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(float: f64) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(int: i64) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for Value

§

type Item = Value

The type of the elements being iterated over.
§

type IntoIter = Iter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl Ord for Value

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Value> for Value

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Value> for Value

source§

fn partial_cmp(&self, other: &Self) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Value

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<&JsonValue> for Value

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(json_value: &JsonValue) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<JsonValue> for Value

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(json_value: JsonValue) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<Value> for String

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for bool

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for f64

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Value> for i64

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Value

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> NoneValue for Twhere T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> SerializableAny for Twhere T: 'static + Any + Clone + Send + Sync,