pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Binary(Binary),
Timestamp(Timestamp),
List(Vec<Value>),
Map(BTreeMap<String, Value>),
}Expand description
Represents a valid JASN value.
Variants§
Null
Null value.
Bool(bool)
Boolean value (true or false).
Int(i64)
64-bit signed integer.
Float(f64)
64-bit floating-point number.
String(String)
UTF-8 string.
Binary(Binary)
Binary data (byte array).
Timestamp(Timestamp)
Timestamp with timezone (ISO8601/RFC3339 compatible).
List(Vec<Value>)
Ordered list of values.
Map(BTreeMap<String, Value>)
Map of string keys to values.
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true if the value is Self::Null.
Sourcepub fn is_bool(&self) -> bool
pub fn is_bool(&self) -> bool
Returns true if the value is Self::Bool.
Sourcepub fn is_float(&self) -> bool
pub fn is_float(&self) -> bool
Returns true if the value is Self::Float.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns true if the value is Self::String.
Sourcepub fn is_binary(&self) -> bool
pub fn is_binary(&self) -> bool
Returns true if the value is Self::Binary.
Sourcepub fn is_timestamp(&self) -> bool
pub fn is_timestamp(&self) -> bool
Returns true if the value is Self::Timestamp.
Sourcepub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
Returns true if the value is Self::List.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool value if this is a Self::Bool, otherwise None.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
Returns the f64 value if this is a Self::Float, otherwise None.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns the str if this is a Self::String, otherwise None.
Sourcepub fn as_binary(&self) -> Option<&Binary>
pub fn as_binary(&self) -> Option<&Binary>
Returns the Binary if this is a Self::Binary, otherwise None.
Sourcepub fn as_timestamp(&self) -> Option<&Timestamp>
pub fn as_timestamp(&self) -> Option<&Timestamp>
Returns the Timestamp value if this is a Self::Timestamp, otherwise None.
Sourcepub fn as_list(&self) -> Option<&[Value]>
pub fn as_list(&self) -> Option<&[Value]>
Returns the list of values if this is a Self::List, otherwise None.
Sourcepub fn as_map(&self) -> Option<&BTreeMap<String, Value>>
pub fn as_map(&self) -> Option<&BTreeMap<String, Value>>
Returns the map of key-value pairs if this is a Self::Map, otherwise None.
Sourcepub fn as_list_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_list_mut(&mut self) -> Option<&mut Vec<Value>>
Returns a mutable reference to the list of values if this is a Self::List, otherwise None.
Sourcepub fn as_map_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
pub fn as_map_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
Returns a mutable reference to the map of key-value pairs if this is a Self::Map, otherwise None.
Sourcepub fn take(&mut self) -> Value
pub fn take(&mut self) -> Value
Takes the value, leaving Self::Null in its place.
Trait Implementations§
Source§impl Display for Value
Display implementation for Value using debug formatting.
impl Display for Value
Display implementation for Value using debug formatting.
For proper JASN formatting, use the jasn crate’s formatting functions.