Value

Enum Value 

Source
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>

Source

pub fn is_scalar(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn as_object(&self) -> Option<&Object<'a>>

Source

pub fn is_array(&self) -> bool

Source

pub fn as_array(&self) -> Option<&Vec<Value<'a>>>

Source

pub fn is_string(&self) -> bool

Source

pub fn as_str(&self) -> Option<&Cow<'_, str>>

Source

pub fn is_number(&self) -> bool

Source

pub fn as_number(&self) -> Option<&Number>

Source

pub fn is_i64(&self) -> bool

Source

pub fn is_u64(&self) -> bool

Source

pub fn is_f64(&self) -> bool

Source

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

Source

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

Source

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

Source

pub fn is_boolean(&self) -> bool

Source

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

Source

pub fn is_null(&self) -> bool

Source

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

Source

pub fn is_binary(&self) -> bool

Source

pub fn as_binary(&self) -> Option<&[u8]>

Source

pub fn is_date(&self) -> bool

Source

pub fn as_date(&self) -> Option<&Date>

Source

pub fn is_timestamp(&self) -> bool

Source

pub fn as_timestamp(&self) -> Option<&Timestamp>

Source

pub fn is_timestamp_tz(&self) -> bool

Source

pub fn as_timestamp_tz(&self) -> Option<&TimestampTz>

Source

pub fn is_interval(&self) -> bool

Source

pub fn as_interval(&self) -> Option<&Interval>

Source

pub fn write_to_vec(&self, buf: &mut Vec<u8>)

Serialize the JSONB Value into a byte stream.

Source

pub fn to_vec(&self) -> Vec<u8>

Serialize the JSONB Value into a byte stream.

Source

pub fn get_by_name_ignore_case(&self, name: &str) -> Option<&Value<'a>>

Source

pub fn array_length(&self) -> Option<usize>

Source

pub fn object_keys(&self) -> Option<Value<'a>>

Source

pub fn eq_variant(&self, other: &Value<'_>) -> bool

Source

pub fn rand_value() -> Value<'static>

generate random JSONB value

Trait Implementations§

Source§

impl<'a> Clone for Value<'a>

Source§

fn clone(&self) -> Value<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value<'_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Value<'a>

Source§

fn default() -> Value<'a>

Returns the “default value” for a type. Read more
Source§

impl Display for Value<'_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, T: Clone + Into<Value<'a>>> From<&'a [T]> for Value<'a>

Source§

fn from(f: &'a [T]) -> Self

Converts to this type from the input type.
Source§

impl From<&Value> for Value<'_>

Source§

fn from(value: &JsonValue) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for Value<'a>

Source§

fn from(f: &'a str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for Value<'_>

Source§

fn from((): ()) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<BTreeMap<String, Value<'a>>> for Value<'a>

Source§

fn from(o: Object<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, str>> for Value<'a>

Source§

fn from(f: Cow<'a, str>) -> Self

Converts to this type from the input type.
Source§

impl From<OrderedFloat<f32>> for Value<'_>

Source§

fn from(f: OrderedFloat<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<OrderedFloat<f64>> for Value<'_>

Source§

fn from(f: OrderedFloat<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value<'_>

Source§

fn from(f: String) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Value<'a>> for Value

Source§

fn from(value: Value<'a>) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for Value<'_>

Source§

fn from(value: JsonValue) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: Into<Value<'a>>> From<Vec<T>> for Value<'a>

Source§

fn from(f: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value<'_>

Source§

fn from(f: bool) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<f32> for Value<'a>

Source§

fn from(n: f32) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<f64> for Value<'a>

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<i16> for Value<'a>

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<i32> for Value<'a>

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<i64> for Value<'a>

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<i8> for Value<'a>

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<isize> for Value<'a>

Source§

fn from(n: isize) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<u16> for Value<'a>

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<u32> for Value<'a>

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<u64> for Value<'a>

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<u8> for Value<'a>

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<usize> for Value<'a>

Source§

fn from(n: usize) -> Self

Converts to this type from the input type.
Source§

impl<'a, K: Into<String>, V: Into<Value<'a>>> FromIterator<(K, V)> for Value<'a>

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, T: Into<Value<'a>>> FromIterator<T> for Value<'a>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> PartialEq for Value<'a>

Source§

fn eq(&self, other: &Value<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Value<'a>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V