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
// Copyright 2026 James Gober.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//! # emdb
//!
//! A high-performance embedded key-value database for Rust.
//!
//! ## Architecture
//!
//! emdb is an **mmap-backed append-only KV** with a sharded in-memory
//! hash index. Writes go through `pwrite` at a single tail offset;
//! reads slice directly into the kernel-managed memory map (zero-copy).
//! Crash safety comes from per-record CRC32 framing — recovery scan
//! truncates at the first bad CRC. This is the Bitcask family of
//! storage engines, the same shape used by Riak, HaloDB, and others.
//!
//! ## Examples
//!
//! Persistent usage:
//!
//! ```no_run
//! use emdb::Emdb;
//!
//! let path = std::env::temp_dir().join("emdb-doc-example.emdb");
//! {
//! let db = Emdb::open(&path)?;
//! db.insert("name", "emdb")?;
//! db.flush()?;
//! }
//! let db = Emdb::open(&path)?;
//! assert_eq!(db.get("name")?, Some(b"emdb".to_vec()));
//! # let _cleanup = std::fs::remove_file(path);
//! # Ok::<(), emdb::Error>(())
//! ```
//!
//! TTL usage:
//!
//! ```no_run
//! # #[cfg(feature = "ttl")]
//! # {
//! use std::time::Duration;
//!
//! use emdb::{Emdb, Ttl};
//!
//! let path = std::env::temp_dir().join("emdb-doc-ttl.emdb");
//! let db = Emdb::builder()
//! .path(&path)
//! .default_ttl(Duration::from_secs(60))
//! .build()?;
//! db.insert_with_ttl("session", "token", Ttl::Default)?;
//! assert!(db.ttl("session")?.is_some());
//! # let _cleanup = std::fs::remove_file(path);
//! # }
//! # Ok::<(), emdb::Error>(())
//! ```
//!
//! ## Storage Path Resolution
//!
//! emdb does not pick a default path for you. You either pass an
//! explicit path, or opt into OS-aware resolution via the builder.
//!
//! ```no_run
//! use emdb::Emdb;
//!
//! // Resolves to:
//! // Linux: $XDG_DATA_HOME/hivedb-kv/sessions.emdb
//! // macOS: ~/Library/Application Support/hivedb-kv/sessions.emdb
//! // Windows: %LOCALAPPDATA%\hivedb-kv\sessions.emdb
//! let db = Emdb::builder()
//! .app_name("hivedb-kv")
//! .database_name("sessions.emdb")
//! .build()?;
//! # Ok::<(), emdb::Error>(())
//! ```
// 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 use EmdbBuilder;
pub use Emdb;
pub use ;
pub use ;
pub use ;
pub use Focus;
pub use Transaction;
pub use Ttl;