Enum serde_cbor::value::Value [] [src]

pub enum Value {
    U64(u64),
    I64(i64),
    Bytes(Vec<u8>),
    String(String),
    Array(Vec<Value>),
    Object(HashMap<ObjectKeyValue>),
    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(HashMap<ObjectKeyValue>)

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]

fn is_object(&self) -> bool

Returns true if the value is an object.

fn as_object(&self) -> Option<&HashMap<ObjectKeyValue>>

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

fn as_object_mut(&mut self) -> Option<&mut HashMap<ObjectKeyValue>>

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

fn is_array(&self) -> bool

Returns true if the value is an array.

fn as_array(&self) -> Option<&Vec<Value>>

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

fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>

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

fn is_bytes(&self) -> bool

Returns true if the value is a byte string.

fn as_bytes(&self) -> Option<&Vec<u8>>

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

fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8>>

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

fn is_string(&self) -> bool

Returns true if the value is a string.

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

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

fn as_string_mut(&mut self) -> Option<&mut String>

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

fn is_number(&self) -> bool

Retrns true if the value is a number.

fn is_i64(&self) -> bool

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

fn is_u64(&self) -> bool

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

fn is_f64(&self) -> bool

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

fn as_i64(&self) -> Option<i64>

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

fn as_u64(&self) -> Option<u64>

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

fn as_f64(&self) -> Option<f64>

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

fn is_boolean(&self) -> bool

Returns true if the value is a boolean.

fn as_boolean(&self) -> Option<bool>

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

fn is_null(&self) -> bool

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

fn as_null(&self) -> Option<()>

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

Trait Implementations

impl PartialEq for Value
[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Value) -> bool

This method tests for !=.

impl Debug for Value
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Value
[src]

fn clone(&self) -> Value

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Deserialize for Value
[src]

fn deserialize<D>(deserializer: &mut D) -> Result<Value, D::Error> where D: Deserializer

Deserialize this value given this Deserializer.

impl Serialize for Value
[src]

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

Serializes this value into this serializer.

impl From<ObjectKey> for Value
[src]

fn from(key: ObjectKey) -> Value

Performs the conversion.