1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Copyright 2026 James Gober.
// Licensed under Apache-2.0 OR MIT.
//! # iqdb — embedded vector database for Rust
//!
//! `iqdb` is a single-process, in-application similarity-search engine
//! designed for high-dimensional workloads where every microsecond on
//! the query path matters. It targets the same operational shape as
//! [`sqlite`] or [`redb`]: no daemon, no network hop, no separate
//! runtime. Open a handle, write vectors, query nearest neighbours —
//! all from inside your binary.
//!
//! The `0.3.0` release adds **exact top-`k` similarity search** on
//! top of the v0.2.0 primitives: [`Iqdb::search`], [`Iqdb::search_with`]
//! (predicate-filtered), [`Iqdb::search_batch`], and
//! [`Iqdb::search_batch_with`], all returning ordered
//! [`SearchResult`]s. The kernel is a brute-force flat scan with a
//! bounded top-`k` heap; approximate indices (IVF, HNSW) follow in
//! v0.5.0 and will sit alongside the flat kernel rather than
//! replacing it.
//!
//! Durable file-backed storage lands in v0.4.0. Until then,
//! [`Iqdb::open(path)`] and [`Iqdb::flush`] return
//! [`Error::NotImplemented`] so call sites can be wired against the
//! final API shape today.
//!
//! Enable the optional `serde` Cargo feature to derive
//! `Serialize` / `Deserialize` on [`Vector`], [`Payload`],
//! [`PayloadValue`], [`RecordId`], [`Record`], and [`DistanceMetric`].
//! The default build pulls no runtime dependencies.
//!
//! [`sqlite`]: https://www.sqlite.org/
//! [`redb`]: https://crates.io/crates/redb
//! [`Iqdb::open(path)`]: Iqdb::open
//!
//! # Examples
//!
//! Open an in-memory instance, upsert a record, look it up, and close
//! the handle:
//!
//! ```
//! use iqdb::{Iqdb, Record, RecordId, Result, Vector};
//!
//! fn run() -> Result<()> {
//! let db = Iqdb::open_in_memory();
//!
//! db.upsert(Record::new(
//! RecordId::new(1),
//! Vector::new(vec![0.1, 0.2, 0.3])?,
//! ))?;
//!
//! let hit = db.get(RecordId::new(1))?.expect("record present");
//! assert_eq!(hit.vector().as_slice(), &[0.1, 0.2, 0.3]);
//!
//! db.close()?;
//! Ok(())
//! }
//! # run().unwrap();
//! ```
//!
//! Run a filtered top-`k` similarity search — the filter narrows the
//! candidate set before the bounded heap admit decision, so payload
//! predicates compose cleanly with the distance metric:
//!
//! ```
//! use iqdb::{DistanceMetric, Iqdb, Payload, PayloadValue, Record, RecordId, Result, Vector};
//!
//! fn run() -> Result<()> {
//! let db = Iqdb::open_in_memory();
//!
//! let mut doc = Payload::new();
//! doc.insert("kind", "doc");
//! db.upsert(Record::with_payload(
//! RecordId::new(1),
//! Vector::new(vec![1.0, 0.0, 0.0])?,
//! doc,
//! ))?;
//!
//! let mut image = Payload::new();
//! image.insert("kind", "image");
//! db.upsert(Record::with_payload(
//! RecordId::new(2),
//! Vector::new(vec![1.0, 0.01, 0.0])?,
//! image,
//! ))?;
//!
//! let probe = Vector::new(vec![1.0, 0.0, 0.0])?;
//! let hits = db.search_with(&probe, 5, DistanceMetric::Cosine, |rec| {
//! rec.payload()
//! .and_then(|p| p.get("kind"))
//! .and_then(PayloadValue::as_text)
//! == Some("doc")
//! })?;
//!
//! assert_eq!(hits.len(), 1);
//! assert_eq!(hits[0].id, RecordId::new(1));
//! Ok(())
//! }
//! # run().unwrap();
//! ```
//!
//! Branch on [`Error::NotImplemented`] when wiring methods whose
//! engine path lands in a later milestone — the `Err` arm disappears
//! when the corresponding release ships:
//!
//! ```
//! use iqdb::{Error, Iqdb, Result};
//!
//! fn flush_if_supported(db: &Iqdb) -> Result<()> {
//! match db.flush() {
//! Ok(()) => Ok(()),
//! Err(Error::NotImplemented) => Ok(()),
//! Err(err) => Err(err),
//! }
//! }
//!
//! let db = Iqdb::open_in_memory();
//! flush_if_supported(&db).unwrap();
//! ```
// Test code is allowed to use the convenience panickers — the strict
// lint profile above is for production library code, not assertion
// scaffolding inside `#[cfg(test)] mod tests` blocks.
pub
pub use Iqdb;
pub use ;
pub use ;
pub use ;
pub use SearchResult;
pub use ;