Metadata

Type Alias Metadata 

Source
pub type Metadata = Value;
Expand description

Metadata type for vector payloads

Uses serde_json::Value for flexible JSON-compatible storage. Supports arbitrary nested structures, arrays, and primitive types.

§Example

use embedvec::Metadata;

let meta: Metadata = serde_json::json!({
    "doc_id": "123",
    "category": "finance",
    "timestamp": 1737400000,
    "tags": ["important", "reviewed"]
});

Aliased Type§

pub enum Metadata {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<Value>),
    Object(Map<String, Value>),
}

Variants§

§

Null

Represents a JSON null value.

let v = json!(null);
§

Bool(bool)

Represents a JSON boolean.

let v = json!(true);
§

Number(Number)

Represents a JSON number, whether integer or floating point.

let v = json!(12.5);
§

String(String)

Represents a JSON string.

let v = json!("a string");
§

Array(Vec<Value>)

Represents a JSON array.

let v = json!(["an", "array"]);
§

Object(Map<String, Value>)

Represents a JSON object.

By default the map is backed by a BTreeMap. Enable the preserve_order feature of serde_json to use IndexMap instead, which preserves entries in the order they are inserted into the map. In particular, this allows JSON data to be deserialized into a Value and serialized to a string while retaining the order of map keys in the input.

let v = json!({ "an": "object" });

Trait Implementations§

Source§

impl MetadataExt for Metadata

Source§

fn get_str(&self, key: &str) -> Option<&str>

Get a string field from metadata
Source§

fn get_i64(&self, key: &str) -> Option<i64>

Get an integer field from metadata
Source§

fn get_f64(&self, key: &str) -> Option<f64>

Get a float field from metadata
Source§

fn get_bool(&self, key: &str) -> Option<bool>

Get a boolean field from metadata
Source§

fn has_key(&self, key: &str) -> bool

Check if metadata has a specific key