pub enum Value<'a> {
Null,
Bool(bool),
Integer(Integer),
Float(Float),
Bytes(Cow<'a, [u8]>),
String(Cow<'a, str>),
Array(VecDeque<Self>),
Map(VecDeque<(Self, Self)>),
}
Expand description
Generic value that can contain any value in our data format. It can be deserialized and serialized to be exactly as when serializing or deserializing with the given type.
Note: Cloneing this value will not borrow from owned values. For that, you need to call Value::borrow_clone.
Variants§
Null
Null / None / Unit type.
Bool(bool)
Bool value.
Integer(Integer)
Integer value.
Float(Float)
Float value.
Bytes(Cow<'a, [u8]>)
Bytes value.
String(Cow<'a, str>)
String value.
Array(VecDeque<Self>)
Sequence value.
Map(VecDeque<(Self, Self)>)
Map value (ordered).
Implementations§
source§impl<'a> Value<'a>
impl<'a> Value<'a>
sourcepub fn borrow_clone(&self) -> Value<'_>
pub fn borrow_clone(&self) -> Value<'_>
Clone this value, borrowing the owned data where possible.
sourcepub fn into_owned(self) -> OwnedValue
pub fn into_owned(self) -> OwnedValue
Make value 'static
by cloning all borrowed data.
sourcepub fn deserialize_as<'de, T>(self) -> Result<T>where
T: Deserialize<'de>,
'a: 'de,
pub fn deserialize_as<'de, T>(self) -> Result<T>where
T: Deserialize<'de>,
'a: 'de,
Use this generic Value to deserialize into the given concrete type.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether the value is empty. This is the case if:
- The value is Value::Null.
- The value is Value::Bytes or Value::String of length 0.
- The value is Value::Array or Value::Map without items.
sourcepub const fn as_bool(&self) -> Option<bool>
pub const fn as_bool(&self) -> Option<bool>
Return the inner bool if this is a Value::Bool.
sourcepub const fn as_int(&self) -> Option<Integer>
pub const fn as_int(&self) -> Option<Integer>
Return the inner int if this is a Value::Integer.
sourcepub const fn as_float(&self) -> Option<Float>
pub const fn as_float(&self) -> Option<Float>
Return the inner float if this is a Value::Float.
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Return the inner bytes if this is a Value::Bytes.
sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Return the inner string if this is a Value::String.
sourcepub const fn as_array(&self) -> Option<&VecDeque<Value<'a>>>
pub const fn as_array(&self) -> Option<&VecDeque<Value<'a>>>
Return the inner array if this is a Value::Array.
sourcepub const fn as_map(&self) -> Option<&VecDeque<(Value<'a>, Value<'a>)>>
pub const fn as_map(&self) -> Option<&VecDeque<(Value<'a>, Value<'a>)>>
Return the inner map if this is a Value::Map.
sourcepub fn into_values(self) -> Iter<Value<'static>> ⓘ
pub fn into_values(self) -> Iter<Value<'static>> ⓘ
Iterate over the inner values if this is a Value::Array or Value::Map.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Value<'de>
impl<'de> Deserialize<'de> for Value<'de>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl<'a, 'de> From<&'a Value<'de>> for Unexpected<'a>
impl<'a, 'de> From<&'a Value<'de>> for Unexpected<'a>
source§impl<'a, K, V> FromIterator<(K, V)> for Value<'a>
impl<'a, K, V> FromIterator<(K, V)> for Value<'a>
source§impl<'a, T> FromIterator<T> for Value<'a>
impl<'a, T> FromIterator<T> for Value<'a>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Auto Trait Implementations§
impl<'a> Freeze for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnwindSafe for Value<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)