pub enum Value {
U64(u64),
I64(i64),
Bytes(Vec<u8, Global>),
String(String),
Array(Vec<Value, Global>),
Object(BTreeMap<ObjectKey, Value, Global>),
F64(f64),
Bool(bool),
Null,
}
Expand description
An enum over all possible CBOR types.
Variants§
U64(u64)
Represents an unsigned integer.
I64(i64)
Represents a signed integer.
Bytes(Vec<u8, Global>)
Represents a byte string.
String(String)
Represents an UTF-8 string.
Array(Vec<Value, Global>)
Represents a list.
Object(BTreeMap<ObjectKey, Value, Global>)
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.
Implementations§
source§impl Value
impl Value
sourcepub fn as_object(&self) -> Option<&BTreeMap<ObjectKey, Value, Global>>
pub fn as_object(&self) -> Option<&BTreeMap<ObjectKey, Value, Global>>
If the value is an object, returns the associated BTreeMap. Returns None otherwise.
sourcepub fn as_object_mut(
&mut self
) -> Option<&mut BTreeMap<ObjectKey, Value, Global>>
pub fn as_object_mut(
&mut self
) -> Option<&mut BTreeMap<ObjectKey, Value, Global>>
If the value is an object, returns the associated mutable BTreeMap. Returns None otherwise.
sourcepub fn as_array(&self) -> Option<&Vec<Value, Global>>
pub fn as_array(&self) -> Option<&Vec<Value, Global>>
If the value is an array, returns the associated Vec. Returns None otherwise.
sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value, Global>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value, Global>>
If the value is an array, returns the associated mutable Vec. Returns None otherwise.
sourcepub fn as_bytes(&self) -> Option<&Vec<u8, Global>>
pub fn as_bytes(&self) -> Option<&Vec<u8, Global>>
Returns the associated byte string or None
if the value has a different type.
sourcepub fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8, Global>>
pub fn as_bytes_mut(&mut self) -> Option<&mut Vec<u8, Global>>
Returns the associated mutable byte string or None
if the value has a different type.
sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
Returns the associated string or None
if the value has a different type.
sourcepub fn as_string_mut(&mut self) -> Option<&mut String>
pub fn as_string_mut(&mut self) -> Option<&mut String>
Returns the associated mutable string or None
if the value has a different type.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
If the Value
is a number, return or cast it to a i64. Returns None otherwise.
sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
If the Value
is a number, return or cast it to a u64. Returns None otherwise.
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
If the Value
is a number, return or cast it to a f64. Returns None otherwise.
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if the value is a boolean.
sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
If the value is a Boolean, returns the associated bool. Returns None otherwise.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
source§fn deserialize<D>(
deserializer: D
) -> Result<Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Serialize for Value
impl Serialize for Value
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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<'a, T> DefaultFeatures<'a> for Twhere
T: 'a + Send + Sync + Clone,
impl<'a, T> DefaultFeatures<'a> for Twhere
T: 'a + Send + Sync + Clone,
source§fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
Box
behind a trait object of this trait. Read moresource§impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
source§fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
Box
behind a trait object of this trait. Read more