Skip to main content

FieldValue

Enum FieldValue 

Source
pub enum FieldValue {
    Null,
    Bool(bool),
    Integer(i64),
    UInteger(u64),
    Float(f64),
    String(String),
    Array(Vec<FieldValue>),
    Object(HashMap<String, FieldValue>),
    Date(Date),
    Blob(Vec<u8>),
}
Expand description

A typed field value for feature attributes.

This enum covers all primitive and composite types that can appear as vector feature properties. It replaces the former PropertyValue type and extends it with FieldValue::Date and FieldValue::Blob variants.

§Variant ordering and serde

The enum is tagged with #[serde(untagged)], so deserialization probes variants in declaration order. Array is declared before Blob so that JSON arrays whose elements happen to fit in 0..=255 are still decoded as Array, not accidentally as Blob.

Variants§

§

Null

Null value

§

Bool(bool)

Boolean value

§

Integer(i64)

Signed integer value (i64)

§

UInteger(u64)

Unsigned integer value (u64)

§

Float(f64)

Floating-point value (f64)

§

String(String)

UTF-8 string value

§

Array(Vec<FieldValue>)

Array of field values

§

Object(HashMap<String, FieldValue>)

JSON object (nested key-value mapping)

§

Date(Date)

Calendar date

Only available when the std feature is enabled.

§

Blob(Vec<u8>)

Raw binary blob

Implementations§

Source§

impl FieldValue

Source

pub const fn is_null(&self) -> bool

Returns true if the value is FieldValue::Null.

Source

pub fn to_json_value(&self) -> JsonValue

Converts to a serde_json::Value.

This is an alias for to_json and produces identical output. Prefer to_json_value in new code for clarity.

Source

pub fn to_json(&self) -> JsonValue

Converts to a serde_json::Value.

Kept for backward compatibility; delegates to to_json_value.

Source

pub fn from_json(value: &JsonValue) -> Self

Creates a FieldValue from a serde_json::Value.

JSON arrays are decoded as FieldValue::Array; raw blobs must be constructed directly. JSON strings are decoded as FieldValue::String without attempting date parsing.

Source

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

Returns the string contents if this is a FieldValue::String variant.

Source

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

Returns the integer value if this is a FieldValue::Integer variant.

Source

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

Returns the unsigned integer value if this is a FieldValue::UInteger variant.

Source

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

Returns the float value if this is a numeric variant.

Coerces Integer and UInteger to f64 automatically.

Source

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

Returns the boolean value if this is a FieldValue::Bool variant.

Source

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

Returns the byte slice if this is a FieldValue::Blob variant.

Source

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

Returns the time::Date if this is a FieldValue::Date variant.

Trait Implementations§

Source§

impl Clone for FieldValue

Source§

fn clone(&self) -> FieldValue

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 FieldValue

Source§

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

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

impl<'de> Deserialize<'de> for FieldValue

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

Source§

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

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

impl From<&str> for FieldValue

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for FieldValue

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for FieldValue

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for FieldValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for FieldValue

Source§

fn from(f: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for FieldValue

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for FieldValue

Source§

fn from(i: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for FieldValue

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for FieldValue

Source§

fn from(u: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for FieldValue

Source§

fn from(u: u64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for FieldValue

Source§

fn eq(&self, other: &FieldValue) -> 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 Serialize for FieldValue

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 FieldValue

Auto Trait Implementations§

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