pub enum Value<'a> {
Null,
Bool(bool),
String(Cow<'a, str>),
Number(Number),
Binary(&'a [u8]),
Date(Date),
Timestamp(Timestamp),
TimestampTz(TimestampTz),
Interval(Interval),
Array(Vec<Value<'a>>),
Object(Object<'a>),
}Expand description
Represents a JSON or extended JSON value.
This enum supports both standard JSON types (Null, Bool, String, Number, Array, Object) and extended types for specialized data representation (Binary, Date, Timestamp, etc.). The extended types provide additional functionality beyond the JSON specification, making this implementation more suitable for database applications and other systems requiring richer data type support.
Variants§
Null
Represents a JSON null value
Bool(bool)
Represents a JSON boolean value (true or false)
String(Cow<'a, str>)
Represents a JSON string value
Number(Number)
Represents a JSON number value with various internal representations
Binary(&'a [u8])
Extended type: Represents binary data not supported in standard JSON Useful for storing raw bytes, images, or other binary content
Date(Date)
Extended type: Represents a calendar date (year, month, day) Stored as days since epoch for efficient comparison and manipulation
Timestamp(Timestamp)
Extended type: Represents a timestamp without timezone information Stored as microseconds since epoch
TimestampTz(TimestampTz)
Extended type: Represents a timestamp with timezone information Includes both timestamp and timezone offset
Interval(Interval)
Extended type: Represents a time interval or duration Useful for time difference calculations and scheduling
Array(Vec<Value<'a>>)
Represents a JSON array of values
Object(Object<'a>)
Represents a JSON object as key-value pairs
Implementations§
Source§impl<'a> Value<'a>
impl<'a> Value<'a>
pub fn is_scalar(&self) -> bool
pub fn is_object(&self) -> bool
pub fn as_object(&self) -> Option<&Object<'a>>
pub fn is_array(&self) -> bool
pub fn as_array(&self) -> Option<&Vec<Value<'a>>>
pub fn is_string(&self) -> bool
pub fn as_str(&self) -> Option<&Cow<'_, str>>
pub fn is_number(&self) -> bool
pub fn as_number(&self) -> Option<&Number>
pub fn is_i64(&self) -> bool
pub fn is_u64(&self) -> bool
pub fn is_f64(&self) -> bool
pub fn as_i64(&self) -> Option<i64>
pub fn as_u64(&self) -> Option<u64>
pub fn as_f64(&self) -> Option<f64>
pub fn is_boolean(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn is_null(&self) -> bool
pub fn as_null(&self) -> Option<()>
pub fn is_binary(&self) -> bool
pub fn as_binary(&self) -> Option<&[u8]>
pub fn is_date(&self) -> bool
pub fn as_date(&self) -> Option<&Date>
pub fn is_timestamp(&self) -> bool
pub fn as_timestamp(&self) -> Option<&Timestamp>
pub fn is_timestamp_tz(&self) -> bool
pub fn as_timestamp_tz(&self) -> Option<&TimestampTz>
pub fn is_interval(&self) -> bool
pub fn as_interval(&self) -> Option<&Interval>
Sourcepub fn write_to_vec(&self, buf: &mut Vec<u8>)
pub fn write_to_vec(&self, buf: &mut Vec<u8>)
Serialize the JSONB Value into a byte stream.
pub fn get_by_name_ignore_case(&self, name: &str) -> Option<&Value<'a>>
pub fn array_length(&self) -> Option<usize>
pub fn object_keys(&self) -> Option<Value<'a>>
pub fn eq_variant(&self, other: &Value<'_>) -> bool
Sourcepub fn rand_value() -> Value<'static>
pub fn rand_value() -> Value<'static>
generate random JSONB value
Trait Implementations§
Source§impl From<OrderedFloat<f32>> for Value<'_>
impl From<OrderedFloat<f32>> for Value<'_>
Source§fn from(f: OrderedFloat<f32>) -> Self
fn from(f: OrderedFloat<f32>) -> Self
Source§impl From<OrderedFloat<f64>> for Value<'_>
impl From<OrderedFloat<f64>> for Value<'_>
Source§fn from(f: OrderedFloat<f64>) -> Self
fn from(f: OrderedFloat<f64>) -> Self
Source§impl<'a, T: Into<Value<'a>>> FromIterator<T> for Value<'a>
impl<'a, T: Into<Value<'a>>> 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
impl<'a> Eq for Value<'a>
impl<'a> StructuralPartialEq for Value<'a>
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.