pub enum CborValue {
    Null,
    Bool(bool),
    Integer(i128),
    Float(f64),
    Bytes(Vec<u8, Global>),
    Text(String),
    Array(Vec<Value, Global>),
    Map(BTreeMap<Value, Value, Global>),
    Tag(u64, Box<Value, Global>),
    // some variants omitted
}
Expand description

The Value enum, a loosely typed way of representing any valid CBOR value.

Maps are sorted according to the canonical ordering described in RFC 7049 bis. Therefore values are unambiguously serialized to a canonical form of CBOR from the same RFC.

Variants§

§

Null

Represents the absence of a value or the value undefined.

§

Bool(bool)

Represents a boolean value.

§

Integer(i128)

Integer CBOR numbers.

The biggest value that can be represented is 2^64 - 1. While the smallest value is -2^64. Values outside this range can’t be serialized and will cause an error.

§

Float(f64)

Represents a floating point value.

§

Bytes(Vec<u8, Global>)

Represents a byte string.

§

Text(String)

Represents an UTF-8 encoded string.

§

Array(Vec<Value, Global>)

Represents an array of values.

§

Map(BTreeMap<Value, Value, Global>)

Represents a map.

Maps are also called tables, dictionaries, hashes, or objects (in JSON). While any value can be used as a CBOR key it is better to use only one type of key in a map to avoid ambiguity. If floating point values are used as keys they are compared bit-by-bit for equality. If arrays or maps are used as keys the comparisons to establish canonical order may be slow and therefore insertion and retrieval of values will be slow too.

§

Tag(u64, Box<Value, Global>)

Represents a tagged value

Trait Implementations§

source§

impl CborValueGetters for Value

source§

fn as_array(&self) -> Option<&[CborValue]>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn as_object(&self) -> Option<&BTreeMap<CborValue, CborValue>>

source§

fn as_object_mut(&mut self) -> Option<&mut BTreeMap<CborValue, CborValue>>

source§

fn as_str(&self) -> Option<&str>

source§

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

source§

fn get(&self, i: impl Index) -> Option<&CborValue>

source§

fn get_mut(&mut self, i: impl Index) -> Option<&mut CborValue>

§

impl Clone for Value

§

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
§

impl Debug for Value

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

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

§

fn from(v: BTreeMap<Value, Value, Global>) -> Value

Converts to this type from the input type.
§

impl From<String> for Value

§

fn from(v: String) -> Value

Converts to this type from the input type.
§

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

§

fn from(v: Vec<Value, Global>) -> Value

Converts to this type from the input type.
§

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

§

fn from(v: Vec<u8, Global>) -> Value

Converts to this type from the input type.
§

impl From<bool> for Value

§

fn from(v: bool) -> Value

Converts to this type from the input type.
§

impl From<f32> for Value

§

fn from(v: f32) -> Value

Converts to this type from the input type.
§

impl From<f64> for Value

§

fn from(v: f64) -> Value

Converts to this type from the input type.
§

impl From<i16> for Value

§

fn from(v: i16) -> Value

Converts to this type from the input type.
§

impl From<i32> for Value

§

fn from(v: i32) -> Value

Converts to this type from the input type.
§

impl From<i64> for Value

§

fn from(v: i64) -> Value

Converts to this type from the input type.
§

impl From<i8> for Value

§

fn from(v: i8) -> Value

Converts to this type from the input type.
§

impl From<u16> for Value

§

fn from(v: u16) -> Value

Converts to this type from the input type.
§

impl From<u32> for Value

§

fn from(v: u32) -> Value

Converts to this type from the input type.
§

impl From<u64> for Value

§

fn from(v: u64) -> Value

Converts to this type from the input type.
§

impl From<u8> for Value

§

fn from(v: u8) -> Value

Converts to this type from the input type.
§

impl Ord for Value

§

fn cmp(&self, other: &Value) -> 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
§

impl PartialEq<Value> for Value

§

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

impl PartialOrd<Value> for Value

§

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

impl Serialize for Value

§

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

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

impl 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> 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<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

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<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

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

§

fn to<T>(self) -> Twhere Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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, 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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,