novakv/lib.rs
1//! `novakv` — an embedded, ordered key-value store. Crate root.
2//!
3//! The headline entry point is [`db_impl::DBImpl`] — open a DB, run
4//! `put` / `get` / `delete` / `write` / `new_iterator` /
5//! `get_snapshot`. Most callers only need [`prelude`].
6//!
7//! # Layout
8//!
9//! Each public module is a focused layer of the storage engine. Every
10//! module's `//!` doc explains what's there and when to reach for it.
11//!
12//! | Module | What's in it |
13//! |--------|--------------|
14//! | [`coding`] | varint + fixed-LE primitives |
15//! | [`status`] | `Status`, `Code`, `Result` |
16//! | [`hash`] | non-cryptographic 32-bit hash |
17//! | [`crc32c`] | CRC32C + masked variant |
18//! | [`comparator`] | `Comparator` trait + `BytewiseComparator` |
19//! | [`format`](mod@format) | internal-key format, level constants |
20//! | [`write_batch`] | `WriteBatch`, `WriteBatchHandler` |
21//! | [`block`] | data-block builder + reader |
22//! | [`filter`] | `FilterPolicy` + `BloomFilterPolicy` |
23//! | [`filter_block`] | per-block filter index |
24//! | [`two_level_iter`] | index-of-blocks iterator |
25//! | [`merging_iter`] | k-way merge iterator |
26//! | [`table`] | SSTable builder + reader + `Compressor` |
27//! | [`log`] | WAL writer + reader |
28//! | [`skiplist`] | lock-free skiplist |
29//! | [`memtable`] | in-memory write buffer |
30//! | [`filename`] | DB-directory file naming |
31//! | [`env`](mod@env) | filesystem trait + `StdEnv` + `MemEnv` |
32//! | [`cache`] | `Cache` trait + `ShardedLRUCache` |
33//! | [`table_cache`] | open-Table cache |
34//! | [`version_set`] | LSM level metadata + manifest |
35//! | [`db_impl`] | `DBImpl`, `Options`, `ReadOptions`, `WriteOptions` |
36//! | [`db_iter`] | snapshot-aware iterator |
37//! | [`repair`] | reconstruct a damaged DB |
38//! | [`destroy`] | delete a DB directory |
39//! | [`slice`](mod@slice) | `(ptr, len)` byte view |
40//!
41//! # Quickstart
42//!
43//! ```
44//! use novakv::prelude::*;
45//!
46//! let env = MemEnv::new();
47//! let db = DBImpl::open("/db", env, BytewiseComparator, Options::default()).unwrap();
48//! db.put(b"hello", b"world").unwrap();
49//! assert_eq!(db.get(b"hello").unwrap(), Some(b"world".to_vec()));
50//! ```
51//!
52//! See [`db_impl`] for the full API surface and tuning knobs.
53
54// Each engine layer is a directory module whose primary file shares the
55// directory name (`block/block.rs`); this layout is intentional.
56#![allow(clippy::module_inception)]
57
58pub mod block;
59pub mod cache;
60pub mod coding;
61pub mod comparator;
62pub mod crc32c;
63pub mod db_impl;
64pub mod db_iter;
65pub mod destroy;
66pub mod env;
67pub mod filename;
68pub mod filter;
69pub mod filter_block;
70pub mod format;
71pub mod hash;
72pub mod log;
73pub mod memtable;
74pub mod merging_iter;
75pub mod repair;
76pub mod skiplist;
77pub mod slice;
78pub mod status;
79pub mod table;
80pub mod table_cache;
81pub mod two_level_iter;
82pub mod version_set;
83pub mod write_batch;
84
85/// Built-in Snappy block compressor. Available behind the `snappy`
86/// Cargo feature.
87#[cfg(feature = "snappy")]
88pub mod snappy;
89
90pub use db_iter::DbIterator;
91
92pub use comparator::{BytewiseComparator, Comparator};
93pub use format::{
94 InternalKey, InternalKeyComparator, LookupKey, ParsedInternalKey, SequenceNumber, ValueType,
95 MAX_SEQUENCE_NUMBER, VALUE_TYPE_FOR_SEEK,
96};
97pub use status::{Code, Result, Status};
98pub use write_batch::{WriteBatch, WriteBatchHandler, WriteBatchRecord};
99
100/// Public-API surface. An embedder typically only needs the items in
101/// this prelude — concrete types for opening / using / closing a
102/// database, plus the trait that abstracts over `DBImpl`.
103///
104/// ```
105/// use novakv::prelude::*;
106/// // brings DBImpl, Options, ReadOptions, WriteOptions, Snapshot,
107/// // BytewiseComparator, Comparator, Env, MemEnv, StdEnv, Status,
108/// // Result, Code, Cache, CacheHandle, ShardedLRUCache, Compressor,
109/// // FilterPolicy, BloomFilterPolicy, Logger, WriteBatch, ...
110/// let _ = MemEnv::new();
111/// ```
112pub mod prelude {
113 pub use crate::cache::{Cache, CacheHandle, ShardedLRUCache};
114 pub use crate::comparator::{BytewiseComparator, Comparator};
115 pub use crate::db_impl::{
116 DBImpl, Logger, Options, Range, ReadOptions, Snapshot, WriteOptions, DB,
117 };
118 pub use crate::db_iter::DBIter;
119 pub use crate::destroy::destroy_db;
120 pub use crate::env::{Env, MemEnv, StdEnv, SyncMode};
121 pub use crate::filter::{BloomFilterPolicy, FilterPolicy};
122 pub use crate::repair::{repair_db, repair_db_with_options, RepairReport};
123 pub use crate::slice::Slice;
124 pub use crate::status::{Code, Result, Status};
125 pub use crate::table::Compressor;
126 pub use crate::write_batch::{Handler, WriteBatch, WriteBatchHandler};
127 pub use crate::DbIterator;
128
129 /// Built-in Snappy compressor — re-exported here when the
130 /// `snappy` feature is enabled so users don't need a separate
131 /// `use novakv::snappy::SnappyCompressor` import.
132 #[cfg(feature = "snappy")]
133 pub use crate::snappy::SnappyCompressor;
134}