Skip to main content

Crate taladb

Crate taladb 

Source
Expand description

TalaDB — an embedded, local-first document database with built-in vector search, for Rust apps. It runs inside your process and stores everything in one file; the same engine powers TalaDB in the browser, Node.js, React Native, Android and iOS.

§Getting started

use serde::{Deserialize, Serialize};
use serde_json::json;

#[derive(Serialize, Deserialize)]
struct Book {
    title: String,
    year: i64,
}

let db = taladb::Database::open_in_memory()?; // or taladb::open("app.db")
let books = db.typed::<Book>("books")?;

books.insert(&Book { title: "Noli Me Tángere".into(), year: 1887 })?;
let found = books.find(json!({ "year": { "$gte": 1800 } }))?;
assert_eq!(found.len(), 1);

Database::typed gives a TypedCollection of your own serde types, queried with the JSON filter language every TalaDB platform shares. The untyped Collection underneath works with Values and typed Filters directly.

§What’s in here

§Scope

TalaDB is an embedded database: it owns on-device storage and retrieval, and deliberately does not replicate. Applications that need to notify a backend of local writes use the change webhook in the taladb TypeScript client, which works identically on every runtime.

§Runtime targets

Native Rust, the browser (via wasm32-unknown-unknown), Node.js, React Native, Android and iOS all run this crate. Anything that would bloat a WASM bundle is feature-gated — see the config-yaml, encryption and legacy-migration features.

Re-exports§

pub use aggregate::Accumulator;
pub use aggregate::GroupKey;
pub use aggregate::Pipeline;
pub use aggregate::Stage;
pub use audit::AuditEntry;
pub use audit::AuditOp;
pub use audit::read_audit_log;
pub use audit::read_audit_log_since;
pub use collection::Collection;
pub use collection::CollectionIndexInfo;
pub use collection::Update;
pub use config::DurabilityConfig;
pub use config::TalaDbConfig;
pub use config::load_auto;
pub use config::load_from_path;
pub use document::Document;
pub use document::Value;
pub use document::derive_doc_id;
pub use engine::RedbBackend;
pub use engine::StorageBackend;
pub use error::TalaDbError;
pub use migration::BUILTIN_MIGRATIONS;
pub use migration::CURRENT_SCHEMA_VERSION;
pub use migration::Migration;
pub use migration::run_migrations;
pub use query::Filter;
pub use query::options::FindOptions;
pub use query::options::SortDirection;
pub use query::options::SortSpec;
pub use time::now_ms;
pub use typed::Scored;
pub use typed::TypedCollection;
pub use typed::TypedWatch;
pub use vector::HnswOptions;
pub use vector::VectorMetric;
pub use vector::VectorSearchResult;
pub use collection::VectorBuildProgress;
pub use collection::VectorExecution;
pub use collection::VectorIndexStatus;
pub use collection::VectorQueryOptions;
pub use collection::VectorQueryResult;
pub use collection::VectorSearchMode;
pub use redb;
pub use redb2;
pub use serde_json;

Modules§

aggregate
Aggregation pipeline for TalaDB.
audit
Append-only audit log for TalaDB.
bm25
BM25 relevance scoring for the full-text index.
collection
config
TalaDB config loader.
crypto
Encryption at rest for TalaDB.
document
engine
error
The crate-wide error type.
fts
Full-text search index for TalaDB.
index
Secondary index key encoding.
json
TalaDB’s JSON query language: documents, filters and updates as JSON.
json_depth
Depth guard for untrusted JSON, applied before any recursive parser walks it.
migrate
Bringing a pre-redb-4 database file forward.
migration
query
time
Wall-clock helpers.
typed
Serde-typed collections: store and load your own structs, query with JSON.
vector
Exact vector storage and scoring. Persistent HNSW lives in vector_graph.
watch
Live queries / reactive subscriptions for TalaDB.

Structs§

Database
The main TalaDB database handle.
GraphOptions
Ulid
Re-exported so bindings can parse and construct document ids without taking a direct ulid dependency (and risking a version skew against the engine’s). A Ulid is a unique 128-bit lexicographically sortable identifier
VectorCacheStats
Estimated decoded search allocations. Reservations conservatively charge the full allowance of active graph loans (including large-filter bitmaps) and vector-block construction. Capped filter ID sets, page windows/group keys, result documents, storage and build scratch are outside these estimates.

Enums§

MemoryPressure
Host-reported pressure, independent of the configured normal budget. Recovery is explicit: a timer or app foreground event does not prove that memory pressure has ended.
Quantization
VectorCachePolicy

Functions§

open
Open (or create) the database file at path. Shorthand for Database::open.