Skip to main content

Crate iqdb_types

Crate iqdb_types 

Source
Expand description

§iqdb-types

Shared, dependency-light public types for the HiveDB iqdb vector-database spine. This crate is pure data: the vectors that get indexed, the ids that name them, the metadata attached to them, the metrics that compare them, the parameters and filters of a search, the hits it returns, and the one domain error that ties them together. It holds no engine, no storage, and no I/O — it is the vocabulary every other iqdb-* crate shares so they agree on shapes without depending on each other.

Its only runtime dependency is error_forge, whose ForgeError trait IqdbError implements.

§Feature flags

FeatureDefaultDescription
serdenoDerives Serialize/Deserialize on the public types. VectorRef is Serialize only — a borrowed view has nowhere to own decoded data.

§Example

use iqdb_types::{DistanceMetric, Filter, SearchParams, Value, Vector, VectorId};

// An embedding to index, and an id that names it. `Vector::new`
// validates the contents up front (no empty, no NaN/Inf).
let embedding = Vector::new(vec![0.1, 0.2, 0.3]).unwrap();
let id = VectorId::from(1u64);

// Query parameters: a top-3 cosine search, restricted to published records.
let params = SearchParams {
    filter: Some(Filter::eq("published", Value::Bool(true))),
    ..SearchParams::new(3, DistanceMetric::Cosine)
};

assert_eq!(embedding.dim(), 3);
assert_eq!(id, VectorId::U64(1));
assert_eq!(params.k, 3);

Structs§

Hit
One result of a similarity search: a matched record and its distance.
Metadata
An immutable, ordered map of metadata keys to Values.
SearchParams
The parameters of a nearest-neighbor search.
Vector
An owned dense vector of f32 components.
VectorRef
A borrowed dense vector of f32 components.

Enums§

DistanceMetric
The metric used to measure distance (or similarity) between two vectors.
Filter
A boolean filter expression over record metadata.
IqdbError
An error from an iqdb vector-database operation.
Value
A scalar metadata value.
VectorId
A stable identifier for a stored vector.

Constants§

VERSION
The version of this crate, taken from Cargo.toml at compile time.

Type Aliases§

Result
A specialized Result whose error is IqdbError.