commonware_storage/journal/
mod.rs1use thiserror::Error;
9
10pub mod authenticated;
11pub mod contiguous;
12pub mod segmented;
13
14#[cfg(all(test, feature = "arbitrary"))]
15mod conformance;
16
17impl<E, Op> crate::qmdb::sync::Journal for contiguous::fixed::Journal<E, Op>
18where
19 E: commonware_runtime::Storage + commonware_runtime::Clock + commonware_runtime::Metrics,
20 Op: commonware_codec::Codec<Cfg = ()> + commonware_codec::FixedSize,
21{
22 type Op = Op;
23 type Error = Error;
24
25 async fn size(&self) -> u64 {
26 Self::size(self)
27 }
28
29 async fn append(&mut self, op: Self::Op) -> Result<(), Self::Error> {
30 Self::append(self, op).await.map(|_| ())
31 }
32}
33
34#[derive(Debug, Error)]
36pub enum Error {
37 #[error("mmr error: {0}")]
38 Mmr(anyhow::Error),
39 #[error("journal error: {0}")]
40 Journal(anyhow::Error),
41 #[error("runtime error: {0}")]
42 Runtime(#[from] commonware_runtime::Error),
43 #[error("codec error: {0}")]
44 Codec(#[from] commonware_codec::Error),
45 #[error("invalid blob name: {0}")]
46 InvalidBlobName(String),
47 #[error("invalid blob size: index={0} size={1}")]
48 InvalidBlobSize(u64, u64),
49 #[error("checksum mismatch: expected={0} actual={1}")]
50 ChecksumMismatch(u32, u32),
51 #[error("item too large: size={0}")]
52 ItemTooLarge(usize),
53 #[error("already pruned to section: {0}")]
54 AlreadyPrunedToSection(u64),
55 #[error("section out of range: {0}")]
56 SectionOutOfRange(u64),
57 #[error("usize too small")]
58 UsizeTooSmall,
59 #[error("offset overflow")]
60 OffsetOverflow,
61 #[error("unexpected size: expected={0} actual={1}")]
62 UnexpectedSize(u32, u32),
63 #[error("missing blob: {0}")]
64 MissingBlob(u64),
65 #[error("item out of range: {0}")]
66 ItemOutOfRange(u64),
67 #[error("item pruned: {0}")]
68 ItemPruned(u64),
69 #[error("invalid rewind: {0}")]
70 InvalidRewind(u64),
71 #[error("compression failed")]
72 CompressionFailed,
73 #[error("decompression failed")]
74 DecompressionFailed,
75 #[error("corruption detected: {0}")]
76 Corruption(String),
77 #[error("invalid configuration: {0}")]
78 InvalidConfiguration(String),
79}