Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 20 variants Null, Bool(bool), Int(i64), Uint(u64), Int128(i128), Uint128(u128), Float(f64), String(String), DateTime(String), Date(String), Time(String), Ipv4(Ipv4Addr), Ipv6(Ipv6Addr), Inet(String), Cidr(String), MacAddr(String), MacAddr8(String), Uuid(String), Array(Vec<Value>), Object(BTreeMap<String, Value>),
}
Expand description

Dynamic config value.

Variants§

§

Null

§

Bool(bool)

§

Int(i64)

§

Uint(u64)

§

Int128(i128)

128-bit signed — only from the table i128 type (never auto, which stops at i64/u64/f64).

§

Uint128(u128)

128-bit unsigned — only from the table u128 type.

§

Float(f64)

§

String(String)

§

DateTime(String)

An RFC 3339-style date or datetime, kept as its text. Produced by toml datetime literals, the table dt type and the auto guess — all gated by the datetime feature. Serializes as the string itself (so a serialize→deserialize round trip through a format without a datetime type yields a String).

§

Date(String)

YYYY-MM-DD, kept as its text (table date type, date feature).

§

Time(String)

hh:mm:ss[.fraction], kept as its text (table time type, time feature).

§

Ipv4(Ipv4Addr)

Table ipv4 type (ipv4 feature); serializes canonically. The inet type (inet feature) also produces this or Value::Ipv6, whichever family parses.

§

Ipv6(Ipv6Addr)

Table ipv6 type (ipv6 feature); serializes canonically.

§

Inet(String)

A host address with a netmask (10.0.0.1/24), kept as its validated text — PostgreSQL inet semantics, host bits below the mask may be set (table inet type, inet feature; a bare inet address maps onto Value::Ipv4/Value::Ipv6 instead).

§

Cidr(String)

A network — optional netmask defaulting to the full address length, host bits below the mask must be zero — kept as its validated text; PostgreSQL cidr semantics (table cidr type, cidr feature).

§

MacAddr(String)

6-byte MAC address, kept as its validated text (table macaddr type, macaddr feature).

§

MacAddr8(String)

8-byte MAC address, kept as its validated text (table macaddr8 type, macaddr8 feature).

§

Uuid(String)

Hyphenated 8-4-4-4-12 UUID, kept as its validated text (table uuid type, uuid feature).

§

Array(Vec<Value>)

§

Object(BTreeMap<String, Value>)

Implementations§

Source§

impl Value

Source

pub fn get(&self, key: &str) -> Option<&Value>

Object member by key; None when this is not an object or the key is absent.

Source

pub fn get_index(&self, index: usize) -> Option<&Value>

Array element by index; None when this is not an array or the index is out of bounds.

Source

pub fn is_null(&self) -> bool

Source

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

Source

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

Source

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

Source

pub fn as_i128(&self) -> Option<i128>

Any integer value as an i128.

Source

pub fn as_u128(&self) -> Option<u128>

Any integer value as a u128.

Source

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

Any numeric value as a float.

Source

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

The text of a string — or of a datetime/date/time value, which keep their text form.

Source

pub fn format_id(&self) -> Cow<'static, str>

The format id of this value — which parser produced it: null, bool, i64, u64, i128, u128, f64, str, the typed ids (dt, date, time, ipv4, ipv6, cidr, macaddr, macaddr8, uuid), arr:<t> for homogeneous scalar arrays, arr for other arrays, object for objects. Integer widths normalize to the stored type (an i8 cell stores an i64, so it reports i64), and inet reports as the family it parsed into. Shown by trace() as the format field of every serialized leaf.

Source

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

Source

pub fn as_object(&self) -> Option<&BTreeMap<String, Value>>

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<'de> Deserialize<'de> 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 Index<&str> for Value

value["key"] — yields Value::Null for missing keys or non-objects, so lookups chain without panicking: value["db"]["port"].as_u64().

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, key: &str) -> &Value

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for Value

value[0] — yields Value::Null out of bounds or on non-arrays.

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Value

Performs the indexing (container[index]) operation. 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 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 = !

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.