Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 52 variants Null, Integer(i64), UnsignedInteger(u64), Float(f64), Text(Arc<str>), Blob(Vec<u8>), Boolean(bool), Timestamp(i64), Duration(i64), IpAddr(IpAddr), MacAddr([u8; 6]), Vector(Vec<f32>), Json(Vec<u8>), Uuid([u8; 16]), NodeRef(String), EdgeRef(String), VectorRef(String, u64), RowRef(String, u64), Color([u8; 3]), Email(String), Url(String), Phone(u64), Semver(u32), Cidr(u32, u8), Date(i32), Time(u32), Decimal(i64), EnumValue(u8), Array(Vec<Value>), TimestampMs(i64), Ipv4(u32), Ipv6([u8; 16]), Subnet(u32, u32), Port(u16), Latitude(i32), Longitude(i32), GeoPoint(i32, i32), Country2([u8; 2]), Country3([u8; 3]), Lang2([u8; 2]), Lang5([u8; 5]), Currency([u8; 3]), AssetCode(String), Money { asset_code: String, minor_units: i64, scale: u8, }, ColorAlpha([u8; 4]), BigInt(i64), KeyRef(String, String), DocRef(String, u64), TableRef(String), PageRef(u32), Secret(Vec<u8>), Password(String),
}
Expand description

A typed value that can be stored in RedDB

Variants§

§

Null

Null value

§

Integer(i64)

Signed 64-bit integer

§

UnsignedInteger(u64)

Unsigned 64-bit integer

§

Float(f64)

64-bit floating point

§

Text(Arc<str>)

UTF-8 text

§

Blob(Vec<u8>)

Binary data

§

Boolean(bool)

Boolean

§

Timestamp(i64)

Unix timestamp (seconds)

§

Duration(i64)

Duration in milliseconds

§

IpAddr(IpAddr)

IP address (v4 or v6)

§

MacAddr([u8; 6])

MAC address

§

Vector(Vec<f32>)

Float vector for similarity search

§

Json(Vec<u8>)

JSON-like structured data (stored as bytes)

§

Uuid([u8; 16])

UUID

§

NodeRef(String)

Graph node reference (node ID string)

§

EdgeRef(String)

Graph edge reference (edge ID string)

§

VectorRef(String, u64)

Vector store reference (collection, vector ID)

§

RowRef(String, u64)

Table row reference (table name, row ID)

§

Color([u8; 3])

RGB color

§

Email(String)

Email (stored lowercase, validated)

§

Url(String)

URL (validated)

§

Phone(u64)

Phone as digits (e.g., +5511999 -> 5511999u64)

§

Semver(u32)

Semantic version packed as u32

§

Cidr(u32, u8)

CIDR (ip as u32, prefix as u8)

§

Date(i32)

Date as days since Unix epoch

§

Time(u32)

Time as milliseconds since midnight

§

Decimal(i64)

Fixed-point decimal (value * 10^precision)

§

EnumValue(u8)

Enum variant index

§

Array(Vec<Value>)

Homogeneous array

§

TimestampMs(i64)

Timestamp in milliseconds since epoch

§

Ipv4(u32)

IPv4 as u32

§

Ipv6([u8; 16])

IPv6 as 16 bytes

§

Subnet(u32, u32)

Subnet: ip(u32) + mask(u32)

§

Port(u16)

Port number

§

Latitude(i32)

Latitude in microdegrees (degrees * 1_000_000)

§

Longitude(i32)

Longitude in microdegrees

§

GeoPoint(i32, i32)

GeoPoint (lat, lon) in microdegrees

§

Country2([u8; 2])

ISO country code 2-letter

§

Country3([u8; 3])

ISO country code 3-letter

§

Lang2([u8; 2])

Language code 2-letter

§

Lang5([u8; 5])

Language tag 5-char (e.g., “pt-BR”)

§

Currency([u8; 3])

Currency code 3-letter

§

AssetCode(String)

General asset code, normalized uppercase text

§

Money

Monetary amount stored as integer minor units plus explicit scale and asset code

Fields

§asset_code: String
§minor_units: i64
§scale: u8
§

ColorAlpha([u8; 4])

RGBA color with alpha

§

BigInt(i64)

Big integer (same as Integer but with distinct type for schema clarity)

§

KeyRef(String, String)

Reference to a KV pair (collection, key)

§

DocRef(String, u64)

Reference to a document (collection, entity_id)

§

TableRef(String)

Reference to a table/collection by name

§

PageRef(u32)

Reference to a physical storage page (page_id)

§

Secret(Vec<u8>)

Encrypted secret (AES-256-GCM ciphertext bytes: nonce + ciphertext + tag)

§

Password(String)

Argon2id password hash string

Implementations§

Source§

impl Value

Source

pub fn text(s: impl Into<Arc<str>>) -> Value

Construct a Value::Text from anything that can produce an Arc<str>String, &str, or an existing Arc<str>. The drop-in migration helper for the old Value::Text(String) constructor style.

Source

pub fn data_type(&self) -> DataType

Get the data type of this value

Source

pub fn is_null(&self) -> bool

Check if value is null

Source

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

Serialize value to bytes.

Delegates to super::value_codec::encode — the registry module owns every variant’s byte layout. See value_codec for the full format spec.

Source

pub fn from_bytes(data: &[u8]) -> Result<(Value, usize), ValueError>

Deserialize value from bytes.

Delegates to super::value_codec::decode.

Source

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

Try to convert to i64

Source

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

Try to convert to f64

Source

pub fn as_text(&self) -> Option<&str>

Try to convert to string reference

Source

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

Try to convert to bool

Source

pub fn as_ip_addr(&self) -> Option<IpAddr>

Try to convert to IpAddr

Source

pub fn as_vector(&self) -> Option<&[f32]>

Try to convert to vector reference

Source

pub fn display_string(&self) -> String

Human-readable display string for rich types

Source

pub fn plain_text(&self) -> String

Plain text coercion for string-producing SQL operators.

Unlike Display, this does not render Text as a SQL literal.

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<(), Error>

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

impl Display for Value

Source§

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

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

impl From<&str> for Value

Source§

fn from(s: &str) -> Value

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Value

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Value

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(n: f32) -> Value

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(n: f64) -> Value

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(n: i32) -> Value

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(n: i64) -> Value

Converts to this type from the input type.
Source§

impl Hash for Value

Manual Hash impl for Value.

  • Floats: use f64.to_bits() so the invariant a == b → hash(a) == hash(b) holds.
  • Arrays / nested values: hash each element recursively.
  • All other variants: delegate to the byte-level representation.
Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
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 Eq for Value

Manual Eq impl: consistent with the manual Hash impl below. Float NaN is treated as equal to itself (bit-level equality) so that Value can be used in HashSet<Value> for IN-list optimizations. This diverges from IEEE 754 but is safe for SQL query evaluation.

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<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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more