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 authenticated;
11pub mod contiguous;
12pub mod segmented;
13
14#[cfg(all(test, feature = "arbitrary"))]
15mod conformance;
16
17/// Errors that can occur when interacting with `Journal`.
18#[derive(Debug, Error)]
19pub enum Error {
20    #[error("mmr error: {0}")]
21    Mmr(anyhow::Error),
22    #[error("journal error: {0}")]
23    Journal(anyhow::Error),
24    #[error("runtime error: {0}")]
25    Runtime(#[from] commonware_runtime::Error),
26    #[error("codec error: {0}")]
27    Codec(#[from] commonware_codec::Error),
28    #[error("invalid blob name: {0}")]
29    InvalidBlobName(String),
30    #[error("invalid blob size: index={0} size={1}")]
31    InvalidBlobSize(u64, u64),
32    #[error("item too large: size={0}")]
33    ItemTooLarge(usize),
34    #[error("already pruned to section: {0}")]
35    AlreadyPrunedToSection(u64),
36    #[error("section out of range: {0}")]
37    SectionOutOfRange(u64),
38    #[error("usize too small")]
39    UsizeTooSmall,
40    #[error("offset overflow")]
41    OffsetOverflow,
42    #[error("unexpected size: expected={0} actual={1}")]
43    UnexpectedSize(u32, u32),
44    #[error("missing blob: {0}")]
45    MissingBlob(u64),
46    #[error("item out of range: {0}")]
47    ItemOutOfRange(u64),
48    #[error("item pruned: {0}")]
49    ItemPruned(u64),
50    #[error("invalid rewind: {0}")]
51    InvalidRewind(u64),
52    #[error("compression failed")]
53    CompressionFailed,
54    #[error("decompression failed")]
55    DecompressionFailed,
56    #[error("value too large (> u32::MAX)")]
57    ValueTooLarge,
58    #[error("corruption detected: {0}")]
59    Corruption(String),
60    #[error("invalid configuration: {0}")]
61    InvalidConfiguration(String),
62    #[error("checksum mismatch: expected={0}, found={1}")]
63    ChecksumMismatch(u32, u32),
64}