Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 19 variants Null, Bool(bool), I32(i32), I64(i64), F64(f64), Decimal(Decimal), DateTime(NaiveDateTime), Uuid(Uuid), Json(Value), Hstore(BTreeMap<String, Option<String>>), Geometry(String), Geography(String), Vector(Vec<f32>), String(String), Bytes(Vec<u8>), Array(Vec<Value>), Array2D(Vec<Vec<Value>>), Enum { value: String, type_name: String, }, Composite { type_name: String, fields: Vec<Value>, },
}
Expand description

Database value type.

Implements custom JSON serialization for cross-language compatibility:

  • Decimal -> string (avoid precision loss)
  • DateTime -> RFC3339 string
  • Uuid -> hyphenated lowercase string
  • Bytes -> base64 string

Variants§

§

Null

NULL value.

§

Bool(bool)

Boolean.

§

I32(i32)

32-bit integer.

§

I64(i64)

64-bit integer.

§

F64(f64)

64-bit float.

§

Decimal(Decimal)

Decimal number with arbitrary precision.

§

DateTime(NaiveDateTime)

Date and time (without timezone).

§

Uuid(Uuid)

UUID.

§

Json(Value)

JSON value.

§

Hstore(BTreeMap<String, Option<String>>)

PostgreSQL hstore key/value map.

§

Geometry(String)

PostgreSQL PostGIS geometry value.

§

Geography(String)

PostgreSQL PostGIS geography value.

§

Vector(Vec<f32>)

PostgreSQL pgvector dense embedding vector.

§

String(String)

String.

§

Bytes(Vec<u8>)

Byte array.

§

Array(Vec<Value>)

Array of values (PostgreSQL native arrays).

§

Array2D(Vec<Vec<Value>>)

2D array of values (PostgreSQL multi-dimensional arrays).

§

Enum

A database enum value with its PostgreSQL type name.

Carries the variant string (e.g. "ADMIN") together with the lowercase PG type name (e.g. "role") so that the PostgreSQL dialect can emit the required explicit cast ($1::role). All other backends treat this identically to Value::String.

Fields

§value: String

The enum variant string sent to / received from the DB.

§type_name: String

Lowercase PostgreSQL type name (e.g. "role", "poststatus").

§

Composite

A PostgreSQL native composite type value.

Carries the lowercase PG type name (e.g. "championstats") together with the field values in their declared order. The PostgreSQL dialect emits the required explicit cast ($1::championstats) and the connector encodes the fields as a record literal (("0","0",…)). Backends that store composites as JSON never receive this variant.

Fields

§type_name: String

Lowercase PostgreSQL type name (e.g. "championstats").

§fields: Vec<Value>

Field values in the composite type’s declared order.

Implementations§

Source§

impl Value

Source

pub fn to_json_plain(&self) -> Value

Convert this value into the plain JSON shape used on transport/wire paths.

Unlike the serde representation of Value itself, this helper intentionally mirrors the historic untagged encoding used by the engine and generated raw-query helpers.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl<'de> Deserialize<'de> for Value

Deserializes a Value from the tagged serde representation emitted by Serialize for Value.

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&str> for Value

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<String, Option<String>>> for Value

Source§

fn from(v: BTreeMap<String, Option<String>>) -> Self

Converts to this type from the input type.
Source§

impl From<Decimal> for Value

Source§

fn from(v: Decimal) -> Self

Converts to this type from the input type.
Source§

impl From<Geography> for Value

Source§

fn from(v: Geography) -> Self

Converts to this type from the input type.
Source§

impl From<Geometry> for Value

Source§

fn from(v: Geometry) -> Self

Converts to this type from the input type.
Source§

impl From<NaiveDateTime> for Value

Source§

fn from(v: NaiveDateTime) -> Self

Converts to this type from the input type.
Source§

impl From<Option<&str>> for Value

Source§

fn from(v: Option<&str>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<BTreeMap<String, Option<String>>>> for Value

Source§

fn from(v: Option<BTreeMap<String, Option<String>>>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Decimal>> for Value

Source§

fn from(v: Option<Decimal>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Geography>> for Value

Source§

fn from(v: Option<Geography>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Geometry>> for Value

Source§

fn from(v: Option<Geometry>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<NaiveDateTime>> for Value

Source§

fn from(v: Option<NaiveDateTime>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<String>> for Value

Source§

fn from(v: Option<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Uuid>> for Value

Source§

fn from(v: Option<Uuid>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<Vec<f32>>> for Value

Source§

fn from(v: Option<Vec<f32>>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<bool>> for Value

Source§

fn from(v: Option<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<f64>> for Value

Source§

fn from(v: Option<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i32>> for Value

Source§

fn from(v: Option<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<i64>> for Value

Source§

fn from(v: Option<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<Uuid> for Value

Source§

fn from(v: Uuid) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for Value

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<BTreeMap<String, Option<String>>>> for Value

Source§

fn from(v: Vec<BTreeMap<String, Option<String>>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Decimal>> for Value

Source§

fn from(v: Vec<Decimal>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Geography>> for Value

Source§

fn from(v: Vec<Geography>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Geometry>> for Value

Source§

fn from(v: Vec<Geometry>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<NaiveDateTime>> for Value

Source§

fn from(v: Vec<NaiveDateTime>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<String>> for Value

Source§

fn from(v: Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Uuid>> for Value

Source§

fn from(v: Vec<Uuid>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Value

Source§

fn from(v: Vec<Value>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<BTreeMap<String, Option<String>>>>> for Value

Source§

fn from(v: Vec<Vec<BTreeMap<String, Option<String>>>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<Decimal>>> for Value

Source§

fn from(v: Vec<Vec<Decimal>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<Geography>>> for Value

Source§

fn from(v: Vec<Vec<Geography>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<Geometry>>> for Value

Source§

fn from(v: Vec<Vec<Geometry>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<NaiveDateTime>>> for Value

Source§

fn from(v: Vec<Vec<NaiveDateTime>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<String>>> for Value

Source§

fn from(v: Vec<Vec<String>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<Uuid>>> for Value

Source§

fn from(v: Vec<Vec<Uuid>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<Value>>> for Value

Source§

fn from(v: Vec<Vec<Value>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<bool>>> for Value

Source§

fn from(v: Vec<Vec<bool>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<f64>>> for Value

Source§

fn from(v: Vec<Vec<f64>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<i32>>> for Value

Source§

fn from(v: Vec<Vec<i32>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<i64>>> for Value

Source§

fn from(v: Vec<Vec<i64>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<bool>> for Value

Source§

fn from(v: Vec<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Value

Source§

fn from(v: Vec<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for Value

Source§

fn from(v: Vec<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<i32>> for Value

Source§

fn from(v: Vec<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<i64>> for Value

Source§

fn from(v: Vec<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Value

Source§

fn from(v: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for Value

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, 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.