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
impl FieldValue
Sourcepub const fn is_null(&self) -> bool
pub const fn is_null(&self) -> bool
Returns true if the value is FieldValue::Null.
Sourcepub fn to_json_value(&self) -> JsonValue
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.
Sourcepub fn to_json(&self) -> JsonValue
pub fn to_json(&self) -> JsonValue
Converts to a serde_json::Value.
Kept for backward compatibility; delegates to to_json_value.
Sourcepub fn from_json(value: &JsonValue) -> Self
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.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns the string contents if this is a FieldValue::String variant.
Sourcepub const fn as_i64(&self) -> Option<i64>
pub const fn as_i64(&self) -> Option<i64>
Returns the integer value if this is a FieldValue::Integer variant.
Sourcepub const fn as_u64(&self) -> Option<u64>
pub const fn as_u64(&self) -> Option<u64>
Returns the unsigned integer value if this is a FieldValue::UInteger variant.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the float value if this is a numeric variant.
Coerces Integer and UInteger to f64 automatically.
Sourcepub const fn as_bool(&self) -> Option<bool>
pub const fn as_bool(&self) -> Option<bool>
Returns the boolean value if this is a FieldValue::Bool variant.
Sourcepub fn as_blob(&self) -> Option<&[u8]>
pub fn as_blob(&self) -> Option<&[u8]>
Returns the byte slice if this is a FieldValue::Blob variant.
Sourcepub const fn as_date(&self) -> Option<Date>
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
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more