1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use thiserror::Error;
/// Errors that can occur during libro operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum LibroError {
/// A chain entry's hash does not match its content, or the chain linkage is broken.
///
/// `index` identifies the first invalid entry. `expected` and `actual` contain
/// the mismatched hash values.
#[error("chain integrity violated at entry {index}: expected hash {expected}, got {actual}")]
IntegrityViolation {
index: usize,
expected: String,
actual: String,
},
/// An error from a storage backend (file, SQLite, or custom store).
#[error("store error: {0}")]
Store(String),
/// An I/O error from file operations.
#[error(transparent)]
Io(#[from] std::io::Error),
/// A JSON serialization or deserialization error.
#[error(transparent)]
Json(#[from] serde_json::Error),
/// An input field exceeds the allowed maximum length.
#[error("field `{field}` too long: {len} bytes (max {max})")]
FieldTooLong {
field: &'static str,
len: usize,
max: usize,
},
/// An RFC 3161 timestamp request or response is malformed.
#[error("timestamp error: {0}")]
Timestamp(String),
/// A witness anchoring operation failed.
#[error("anchoring error: {0}")]
Anchoring(String),
/// DER encoding/decoding error.
#[error("DER encoding error: {0}")]
Der(String),
}