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
// Copyright 2026 James Gober. Licensed under Apache-2.0.
//! Database introspection — the [`EmdbStats`] snapshot returned by
//! [`crate::Emdb::stats`].
//!
//! Stats are a point-in-time snapshot, not a live counter. Calling
//! `stats()` walks the per-namespace runtime state and asks the
//! filesystem for the file size; both reads are lock-free or
//! short-lock and complete in O(namespaces) time. Use this from
//! dashboards, health checks, or "should I compact now?" decision
//! logic.
/// Point-in-time database statistics.
///
/// Returned by [`crate::Emdb::stats`]. Every field is `pub` because
/// the type is a plain bag-of-numbers and exists purely so consumers
/// can read it; no constructor is exposed.
///
/// # Examples
///
/// ```rust
/// use emdb::Emdb;
///
/// let db = Emdb::open_in_memory();
/// db.insert("k1", "v1")?;
/// db.insert("k2", "v2")?;
///
/// let stats = db.stats()?;
/// assert_eq!(stats.live_records, 2);
/// assert!(stats.file_size_bytes >= stats.logical_size_bytes);
/// # Ok::<(), emdb::Error>(())
/// ```