Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 53 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), DecimalText(String), 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)

§

DecimalText(String)

Exact JSON numeric literal stored as decimal text

§

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>>) -> Self

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<(Self, usize), ValueError>

Deserialize value from bytes.

Delegates to super::value_codec::decode.

Source

pub fn from_bytes_with_limit( data: &[u8], limit_bytes: usize, ) -> Result<(Self, usize), ValueError>

Admit encoded input and conservative decoded allocations before parsing. The caller must separately reserve this allowance in its shared memory pool and retain that reservation for the resulting value’s lifetime.

Source

pub fn from_bytes_with_budget( data: &[u8], remaining_bytes: &mut usize, ) -> Result<(Self, usize), ValueError>

Decode against a caller-owned, conservative allocation allowance. A successful decode subtracts its preflight usage; failures leave it intact. This local allowance does not reserve memory in the runtime’s shared pool.

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.

Source§

impl Value

Source

pub fn to_json(&self) -> JsonValue

Render this value using RedDB’s canonical JSON representation.

Integers outside JavaScript’s exactly representable range and fixed-point decimals use tagged objects so no precision is lost at a JSON boundary.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Self

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 Display for Value

Source§

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

Formats the value using the given formatter. Read more
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 From<&str> for Value

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(n: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(n: i64) -> Self

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: Hasher>(&self, state: &mut H)

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: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.