Skip to main content

infinite_db/
lib.rs

1//! InfiniteDB crate root.
2//!
3//! This crate exposes core spatial data types and, via feature flags,
4//! optional embedded storage, server, and sync layers.
5//!
6//! ## Database entry point
7//!
8//! [`InfiniteDb`] is the CRCW embedded database (formats v2–v4, v4 default):
9//! concurrent reads, fire-and-forget writes, branch overlays, and merge.
10//! It is `Send`/`Sync`. Use [`OpenOptions`] to tune I/O threads and format version.
11//!
12//! ## Feature flags
13//!
14//! - `embedded` (default) — [`InfiniteDb`], storage engine
15//! - `server` — TCP API (`embedded` + tokio)
16//! - `sync` — replication, conflict queue, branch merge helpers (`server`)
17//! - `legacy-v1` — internal v1 WAL engine (compile-only reference; not exposed in the public API)
18//!
19//! ## Migrating from 0.2.0
20//!
21//! 0.3.0 replaces the single-threaded WAL [`InfiniteDb`] with a CRCW engine. Bulk write APIs
22//! (`insert_records_bulk`, hyperedge/signal bulk import) are no longer public. Hyperedge and
23//! signal types remain in [`infinitedb_core`] for upstream modeling; use record-level
24//! [`InfiniteDb::insert`] / [`InfiniteDb::query`] or stay on crate 0.2.0 if you need the old
25//! bulk surface. See the crate README and `CHANGELOG.md` for the full breaking-change list.
26//!
27//! ## Semantic Vocabulary
28//! - `Space`: named N-dimensional dataset with fixed dimensionality.
29//! - `Address`: (`SpaceId`, `DimensionVector`) coordinate key for a record.
30//! - `Node`: any domain entity represented as one or more records in a space.
31//! - `Hyperedge`: explicit relationship linking 2+ endpoint nodes.
32//! - `Signal`: scoped field/sample value over a parent hyperspace prefix.
33//! - `Scope`: fixed coordinate prefix that bounds child records.
34//! - `Revision`: monotonic logical write clock (`RevisionId`).
35//! - `Snapshot`: immutable view assembled from sealed blocks.
36//! - `Tombstone`: logical delete marker for an address/revision.
37//! - `Adapter`: optional trait-based upstream layer for typed labels and spaces.
38
39/// Core spatial and branching types.
40pub mod infinitedb_core;
41
42/// Hilbert and dimension encoding utilities.
43pub mod infinitedb_index;
44
45/// Embedded storage engine components.
46#[cfg(feature = "embedded")]
47pub mod infinitedb_storage;
48
49/// Server-facing API and session management.
50#[cfg(feature = "server")]
51pub mod infinitedb_server;
52
53/// Synchronization and replication primitives.
54#[cfg(feature = "sync")]
55pub mod infinitedb_sync;
56
57// ---------------------------------------------------------------------------
58// Top-level facade
59// ---------------------------------------------------------------------------
60
61#[cfg(feature = "embedded")]
62pub use concurrent::{InfiniteDb, IoStats, OpenOptions, ReadTxn};
63
64#[cfg(feature = "embedded")]
65pub use infinitedb_storage::format::{
66    FormatVersion, FORMAT_VERSION_V2, FORMAT_VERSION_V3, FORMAT_VERSION_V4,
67};
68
69#[cfg(feature = "server")]
70pub use infinitedb_server::api::{handle_request, ApiError, Request, Response, WireConflict};
71
72#[cfg(feature = "server")]
73pub use infinitedb_server::runtime::{admin_grants, client_roundtrip, Server, ServerConfig};
74
75#[cfg(feature = "server")]
76pub use infinitedb_server::session::{AccessLevel, Session, SessionId, SpaceGrant};
77
78#[cfg(feature = "sync")]
79pub use infinitedb_storage::cluster::ClusterMeta;
80
81#[cfg(feature = "sync")]
82pub use infinitedb_sync::conflict_queue::{
83    resolution_record, resolution_tombstone, ConflictQueue, StoredConflict,
84};
85
86#[cfg(feature = "sync")]
87pub use infinitedb_sync::replicate::{
88    branch_sync_state, converge_main_records, converge_with_branch_merge, import_branch_overlay,
89    snapshot_merkle, BranchSyncState,
90};
91
92pub use infinitedb_core::merge::{MergeConflict, MergeResult, MergeStrategy};
93
94#[cfg(feature = "embedded")]
95pub use engine::coordinator::SpaceCoordinator;
96
97#[cfg(feature = "embedded")]
98pub use engine::hilbert_coordinator::HilbertCoordinator;
99
100#[cfg(feature = "embedded")]
101pub use engine::io_thread::{IoThreadConfig, WriteRoute};
102
103#[cfg(feature = "embedded")]
104pub use engine::write_queue::WriteJob;
105
106#[cfg(feature = "embedded")]
107pub use infinitedb_storage::wal::WalDurability;
108
109#[cfg(feature = "embedded")]
110mod concurrent;
111#[cfg(feature = "embedded")]
112mod engine;
113#[cfg(all(feature = "embedded", feature = "legacy-v1"))]
114mod legacy_v1;