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("invalid blob name: {0}")]
19    InvalidBlobName(String),
20    #[error("checksum mismatch: expected={0} actual={1}")]
21    ChecksumMismatch(u32, u32),
22    #[error("item too large: size={0}")]
23    ItemTooLarge(usize),
24    #[error("already pruned to section: {0}")]
25    AlreadyPrunedToSection(u64),
26    #[error("usize too small")]
27    UsizeTooSmall,
28    #[error("offset overflow")]
29    OffsetOverflow,
30    #[error("unexpected size: expected={0} actual={1}")]
31    UnexpectedSize(u32, u32),
32    #[error("missing blob: {0}")]
33    MissingBlob(u64),
34    #[error("item pruned: {0}")]
35    ItemPruned(u64),
36    #[error("invalid item: {0}")]
37    InvalidItem(u64),
38    #[error("invalid rewind: {0}")]
39    InvalidRewind(u64),
40}