Skip to main content

hematite/storage/
mod.rs

1//! Low-level storage primitives.
2//!
3//! This module is the bottom of the stack. It is responsible for durable page IO and nothing
4//! above it should need to understand file offsets, sidecar files, or crash-recovery record
5//! layouts.
6//!
7//! The storage layer centers on a single abstraction:
8//!
9//! ```text
10//!              Pager
11//!                |
12//!    +-----------+-----------+
13//!    |           |           |
14//! buffer      free pages   durability
15//! pool        + file len   (rollback/WAL)
16//! ```
17//!
18//! Responsibilities:
19//! - map logical page ids to bytes on disk or bytes in the in-memory backend;
20//! - allocate, reuse, and retire pages;
21//! - maintain checksum metadata for durable pages;
22//! - implement transaction visibility for rollback-journal and WAL modes;
23//! - report integrity/accounting information upward without knowing what page contents mean.
24//!
25//! Extraction boundary:
26//! - external callers should treat [`Pager`] plus the re-exported page/id types as the entire
27//!   storage API;
28//! - the other submodules are pager internals and are intentionally hidden so the on-disk
29//!   representation can evolve without leaking into higher layers;
30//! - this is the storage half of the future generic fork point.
31
32pub(crate) mod buffer_pool;
33pub(crate) mod file_manager;
34pub(crate) mod free_list;
35pub(crate) mod journal;
36pub(crate) mod overflow;
37pub(crate) mod pager;
38pub(crate) mod types;
39pub(crate) mod wal;
40
41pub use pager::{JournalMode, Pager};
42pub use types::{
43    Page, PageId, PagerIntegrityReport, DB_HEADER_PAGE_ID, INVALID_PAGE_ID, PAGE_SIZE,
44    STORAGE_METADATA_PAGE_ID,
45};
46
47#[cfg(test)]
48mod tests;