pub enum Value {
Utf8(String),
Bytes(Vec<u8>),
Double(f64),
Float(f32),
Uint16(u16),
Uint32(u32),
Int32(i32),
Uint64(u64),
Uint128(u128),
Bool(bool),
Array(Vec<Value>),
Map(BTreeMap<String, Value>),
}Expand description
Owned representation used by the writer and deep-merge engine.
Variants§
Utf8(String)
Owned UTF-8 string.
Bytes(Vec<u8>)
Owned byte string.
Double(f64)
IEEE-754 64-bit floating-point value.
Float(f32)
IEEE-754 32-bit floating-point value.
Uint16(u16)
Unsigned 16-bit integer.
Uint32(u32)
Unsigned 32-bit integer.
Int32(i32)
Signed 32-bit integer.
Uint64(u64)
Unsigned 64-bit integer.
Uint128(u128)
Unsigned 128-bit integer.
Bool(bool)
Boolean value.
Array(Vec<Value>)
Owned MMDB array.
Map(BTreeMap<String, Value>)
Owned MMDB map with deterministic key ordering.
Implementations§
Source§impl Value
impl Value
Sourcepub fn from_serialize<T: Serialize + ?Sized>(value: &T) -> Result<Self>
pub fn from_serialize<T: Serialize + ?Sized>(value: &T) -> Result<Self>
Converts any serde-serializable value into the writer’s generic value model.
Serialization walks the serde data model directly instead of building an
intermediate serde_json::Value, which roughly halves the per-record cost of
Writer::insert. Bools, strings, byte strings,
sequences and maps keep their shape; integral numbers become Uint64 or
Int32, floating point becomes Double, None/unit are rejected because
MMDB has no null type, and enum variants become maps.
§Examples
use libmaxminddb_rs::Value;
let value = Value::from_serialize(&serde_json::json!({"asn": 64512}))?;
assert!(matches!(value, Value::Map(_)));