commonware_storage/journal/
mod.rs

1//! An append-only log for storing arbitrary data.
2//!
3//! Journals provide append-only logging for persisting arbitrary data with fast replay, historical
4//! pruning, and rudimentary support for fetching individual items. A journal can be used on its own
5//! to serve as a backing store for some in-memory data structure, or as a building block for a more
6//! complex construction that prescribes some meaning to items in the log.
7
8use thiserror::Error;
9
10pub mod fixed;
11pub mod variable;
12
13/// Errors that can occur when interacting with `Journal`.
14#[derive(Debug, Error)]
15pub enum Error {
16    #[error("runtime error: {0}")]
17    Runtime(#[from] commonware_runtime::Error),
18    #[error("codec error: {0}")]
19    Codec(#[from] commonware_codec::Error),
20    #[error("invalid blob name: {0}")]
21    InvalidBlobName(String),
22    #[error("invalid blob size: index={0} size={1}")]
23    InvalidBlobSize(u64, u64),
24    #[error("checksum mismatch: expected={0} actual={1}")]
25    ChecksumMismatch(u32, u32),
26    #[error("item too large: size={0}")]
27    ItemTooLarge(usize),
28    #[error("already pruned to section: {0}")]
29    AlreadyPrunedToSection(u64),
30    #[error("usize too small")]
31    UsizeTooSmall,
32    #[error("offset overflow")]
33    OffsetOverflow,
34    #[error("unexpected size: expected={0} actual={1}")]
35    UnexpectedSize(u32, u32),
36    #[error("missing blob: {0}")]
37    MissingBlob(u64),
38    #[error("item pruned: {0}")]
39    ItemPruned(u64),
40    #[error("invalid item: {0}")]
41    InvalidItem(u64),
42    #[error("invalid rewind: {0}")]
43    InvalidRewind(u64),
44    #[error("compression failed")]
45    CompressionFailed,
46    #[error("decompression failed")]
47    DecompressionFailed,
48    #[error("invalid sync range: lower_bound={0} upper_bound={1}")]
49    InvalidSyncRange(u64, u64),
50}