#[non_exhaustive]pub enum Error {
Sink(SinkError),
ChainBroken,
Capacity,
NonMonotonicClock,
HashMismatch(RecordId),
LinkMismatch(RecordId),
IdMismatch(RecordId),
Truncated,
InvalidFormat,
Io,
}Expand description
Error categories produced by audit-trail.
Variants are intentionally coarse-grained. Concrete backends communicate
finer-grained failures via SinkError wrapped inside Error::Sink.
§Example
use audit_trail::Error;
let err = Error::ChainBroken;
assert_eq!(err.to_string(), "audit hash chain broken");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Sink(SinkError)
A configured sink failed to persist a record.
ChainBroken
The running hash chain failed a generic integrity check.
Verification surfaces more specific variants
(Error::HashMismatch, Error::LinkMismatch,
Error::IdMismatch) when possible.
Capacity
A fixed-size buffer or counter exceeded its capacity (for example, the record id counter overflowed).
NonMonotonicClock
The configured clock returned a timestamp that violates monotonicity.
HashMismatch(RecordId)
A record’s stored hash does not match the digest recomputed from
its fields. Carries the failing record’s id.
LinkMismatch(RecordId)
A record’s prev_hash does not equal the previous record’s hash.
Carries the failing record’s id.
IdMismatch(RecordId)
A record’s id is not the expected next id in the chain. Carries the id that was found.
Truncated
Input ended before a complete record could be decoded.
InvalidFormat
Encoded bytes are present but do not parse as a valid record (bad magic, bad version, invalid UTF-8, length-prefix mismatch, …).
Io
Underlying I/O failure (only emitted by std-gated readers/sinks).
Detail is suppressed to keep Error both Copy and no_std-safe;
callers needing the full std::io::Error should use the
constructor methods that return std::io::Result directly.
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()