Skip to main content

hyphae_storage/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Durable log, recovery, snapshot, and materialized-index implementation.
4
5mod backup;
6mod data_directory;
7mod engine;
8mod index;
9mod log;
10mod manifest;
11mod mutation;
12mod snapshot;
13
14pub use backup::{BackupError, BackupInfo, RestoreInfo, restore_backup, verify_backup};
15pub use data_directory::{DataDirectory, DataDirectoryError};
16pub use engine::{
17    CompactionOutcome, CompactionReport, KvEntry, KvPage, MAX_SCAN_PAGE_ENTRIES, OpenedStorage,
18    StorageEngine, StorageError, StorageRecoveryReport,
19};
20pub use index::MaterializedIndexError;
21pub use log::{
22    AppendOutcome, CommitReceipt, DurableLog, LogError, OpenedLog, RecoveredTransaction,
23    RecoveryReport,
24};
25pub use manifest::ManifestError;
26pub use mutation::{MAX_KEY_BYTES, Mutation, MutationError};
27pub use snapshot::{
28    SnapshotContents, SnapshotEntry, SnapshotError, SnapshotInfo, SnapshotReadLimits,
29    load_snapshot, verify_snapshot,
30};
31
32#[cfg(test)]
33mod test_support {
34    use std::{fs, io, path::PathBuf};
35
36    pub(crate) struct TestDirectory {
37        path: PathBuf,
38    }
39
40    impl TestDirectory {
41        pub(crate) fn new(name: &str) -> io::Result<Self> {
42            let path = std::env::temp_dir().join(format!(
43                "hyphae-{name}-{}-{}",
44                std::process::id(),
45                uuid::Uuid::now_v7()
46            ));
47            fs::create_dir_all(&path)?;
48            Ok(Self { path })
49        }
50
51        pub(crate) fn path(&self) -> &std::path::Path {
52            &self.path
53        }
54    }
55
56    impl Drop for TestDirectory {
57        fn drop(&mut self) {
58            let _ignored = fs::remove_dir_all(&self.path);
59        }
60    }
61}