pub type PersistenceResult<T> = Result<T, PersistenceError>;
#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum PersistenceError {
#[error("i/o error: {0}")]
Io(#[from] std::io::Error),
#[error("format error: {0}")]
Format(String),
#[error("crc mismatch (expected {expected:#010x}, got {actual:#010x})")]
CrcMismatch {
expected: u32,
actual: u32,
},
#[error("encode error: {0}")]
Encode(String),
#[error("decode error: {0}")]
Decode(String),
#[error("invalid state: {0}")]
InvalidState(String),
#[error("invalid configuration: {0}")]
InvalidConfig(String),
#[error("operation not supported: {0}")]
NotSupported(String),
#[error("lock failed on {resource}: {reason}")]
LockFailed {
resource: String,
reason: String,
},
#[error("not found: {0}")]
NotFound(String),
}