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
// src/lib.rs — FuseDB crate root
// ──────────────────────────────────────────────────────────────────────────────
//
// Module layout
// ─────────────
// crate::api The public Rust API. What `cargo add fusedb` gives you.
// ::reader FuseReader, PrefixIter
// ::writer FuseWriter
// ::merge merge, merge_into
// ::watch ReloadableReader, FuseWatcher, WatcherBuilder
// ::stats Stats
//
// crate::core Format engine — raw bytes only, zero PyO3.
// ::error FuseError, FuseResult
// ::format Binary format constants, Header, Index, read_raw, crc32
// ::reader ReaderCore
// ::writer WriterCore, BuildReport
//
// crate::python PyO3 shims, behind the `python` feature. The only
// place pyo3 is imported, enabled only by maturin.
//
// The rule: `core` and `api` never import `pyo3`. `python` never contains logic.
//! A read-optimised binary database where many keys share one object — with
//! zero duplication on disk.
//!
//! FuseDB stores each payload once and lets any number of keys point at it.
//! Reads are memory-mapped: opening a database is a `mmap` plus an index parse,
//! and a lookup is a hash probe followed by a single page read.
//!
//! # Quick start
//!
//! ```no_run
//! use fusedb::{FuseReader, FuseWriter};
//! use std::collections::BTreeMap;
//!
//! let mut w = FuseWriter::new();
//!
//! let mut google = BTreeMap::new();
//! google.insert("company", "Google");
//!
//! let oid = w.add_object(&google)?; // stored once…
//! w.add_key("google.com", oid)?; // …reached by three keys
//! w.add_key("8.8.8.8", oid)?;
//! w.add_key("8.8.4.4", oid)?;
//! w.build("db.fsdb")?;
//!
//! let db = FuseReader::open("db.fsdb")?;
//! let hit: Option<BTreeMap<String, String>> = db.get("8.8.8.8")?;
//! assert_eq!(hit.unwrap()["company"], "Google");
//! # Ok::<(), fusedb::FuseError>(())
//! ```
//!
//! # One format, two languages
//!
//! There is no "Rust format" and no "Python format" — only the FuseDB format.
//! A file written by this crate opens in the [`fusedb` Python package] and vice
//! versa, with no conversion step: same magic and version, same big-endian
//! header, same CRC32 placement, same sorted index layout, and — with the
//! default `msgpack` feature — the same MessagePack value encoding.
//!
//! ```no_run
//! # use fusedb::FuseReader;
//! // reads a file `FuseWriter().build("db.fsdb")` produced in Python
//! let db = FuseReader::open("db.fsdb")?;
//! # Ok::<(), fusedb::FuseError>(())
//! ```
//!
//! [`fusedb` Python package]: https://pypi.org/project/fusedb/
//!
//! # Live updates
//!
//! `.fsdb` files are immutable once built; you update one by rebuilding it and
//! swapping. [`ReloadableReader`] does the swap on demand, [`FuseWatcher`] does
//! it from a background thread. Either way you read them exactly like a
//! [`FuseReader`] — every call resolves the current file, so there is no swap
//! bookkeeping and no way to keep reading a replaced database.
//!
//! ```no_run
//! use std::time::Duration;
//! use fusedb::FuseWatcher;
//!
//! let watcher = FuseWatcher::builder("live.fsdb")
//! .interval(Duration::from_secs(30))
//! .on_reload(|db| eprintln!("reloaded: {} keys", db.len()))
//! .spawn()?;
//!
//! println!("{:?}", watcher.get_raw("8.8.8.8")?); // always the newest build
//!
//! // For a batch, resolve the reader once with load() and reuse it.
//! let db = watcher.load();
//! for key in ["8.8.8.8", "8.8.4.4"] {
//! println!("{:?}", db.get_raw(key)?);
//! }
//! # Ok::<(), fusedb::FuseError>(())
//! ```
//!
//! # Features
//!
//! - **`msgpack`** *(default)* — the typed [`FuseWriter::add`] /
//! [`FuseReader::get`] API, encoding values exactly the way the Python
//! package does. Disable it (`default-features = false`) for a
//! dependency-light build that speaks only raw bytes.
//! - **`python`** — PyO3 bindings. Enabled by maturin when building the Python
//! wheel; Rust consumers never need it.
pub use ;
pub use ;
pub use ;
pub use ;
/// Version of this crate, as published on crates.io.
pub const CRATE_VERSION: &str = env!;
/// fusedb._fusedb — native extension module entry-point