[][src]Enum wasm_rpc::Value

pub enum Value {
    U64(u64),
    I64(i64),
    Bytes(Vec<u8>),
    String(String),
    Array(Vec<Value>),
    Object(BTreeMap<ObjectKey, Value>),
    F64(f64),
    Bool(bool),
    Null,
}

An enum over all possible CBOR types.

Variants

U64(u64)

Represents an unsigned integer.

I64(i64)

Represents a signed integer.

Bytes(Vec<u8>)

Represents a byte string.

String(String)

Represents an UTF-8 string.

Array(Vec<Value>)

Represents a list.

Object(BTreeMap<ObjectKey, Value>)

Represents a map.

F64(f64)

Represents a floating point value.

Bool(bool)

Represents a boolean value.

Null

Represents the absence of a value or the value undefined.

Methods

impl Value[src]

pub fn is_object(&self) -> bool[src]

Returns true if the value is an object.

pub fn as_object(&self) -> Option<&BTreeMap<ObjectKey, Value>>[src]

If the value is an object, returns the associated BTreeMap. Returns None otherwise.

pub fn as_object_mut(&mut self) -> Option<&mut BTreeMap<ObjectKey, Value>>[src]

If the value is an object, returns the associated mutable BTreeMap. Returns None otherwise.

pub fn is_array(&self) -> bool[src]

Returns true if the value is an array.

pub fn as_array(&self) -> Option<&Vec<Value>>[src]

If the value is an array, returns the associated Vec. Returns None otherwise.

pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>[src]

If the value is an array, returns the associated mutable Vec. Returns None otherwise.

pub fn is_bytes(&self) -> bool[src]

Returns true if the value is a byte string.

pub fn as_bytes(&self) -> Option<&Vec<u8>>[src]

Returns the associated byte string or None if the value has a different type.

pub fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8>>[src]

Returns the associated mutable byte string or None if the value has a different type.

pub fn is_string(&self) -> bool[src]

Returns true if the value is a string.

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

Returns the associated string or None if the value has a different type.

pub fn as_string_mut(&mut self) -> Option<&mut String>[src]

Returns the associated mutable string or None if the value has a different type.

pub fn is_number(&self) -> bool[src]

Retrns true if the value is a number.

pub fn is_i64(&self) -> bool[src]

Returns true if the Value is a i64. Returns false otherwise.

pub fn is_u64(&self) -> bool[src]

Returns true if the Value is a u64. Returns false otherwise.

pub fn is_f64(&self) -> bool[src]

Returns true if the Value is a f64. Returns false otherwise.

pub fn as_i64(&self) -> Option<i64>[src]

If the Value is a number, return or cast it to a i64. Returns None otherwise.

pub fn as_u64(&self) -> Option<u64>[src]

If the Value is a number, return or cast it to a u64. Returns None otherwise.

pub fn as_f64(&self) -> Option<f64>[src]

If the Value is a number, return or cast it to a f64. Returns None otherwise.

pub fn is_boolean(&self) -> bool[src]

Returns true if the value is a boolean.

pub fn as_boolean(&self) -> Option<bool>[src]

If the value is a Boolean, returns the associated bool. Returns None otherwise.

pub fn is_null(&self) -> bool[src]

Returns true if the value is a Null. Returns false otherwise.

pub fn as_null(&self) -> Option<()>[src]

If the value is a Null, returns (). Returns None otherwise.

Trait Implementations

impl From<bool> for Value[src]

impl From<i64> for Value[src]

impl From<f64> for Value[src]

impl From<Vec<u8>> for Value[src]

impl From<BTreeMap<ObjectKey, Value>> for Value[src]

impl From<ObjectKey> for Value[src]

impl From<Value> for ObjectKey[src]

impl From<String> for Value[src]

impl From<Vec<Value>> for Value[src]

impl From<u64> for Value[src]

impl PartialEq<Value> for Value[src]

impl Serialize for Value[src]

impl<'de> Deserialize<'de> for Value[src]

impl Debug for Value[src]

impl Clone for Value[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Value

impl Sync for Value

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]