Skip to main content

lora_snapshot/
errors.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum SnapshotCodecError {
5    #[error("snapshot I/O error: {0}")]
6    Io(#[from] std::io::Error),
7    #[error("snapshot encode error: {0}")]
8    Encode(String),
9    #[error("snapshot decode error: {0}")]
10    Decode(String),
11    #[error("snapshot has bad magic")]
12    BadMagic,
13    #[error("unsupported snapshot format version: {0}")]
14    UnsupportedVersion(u32),
15    #[error("snapshot compression `{0}` is not supported by this build")]
16    UnsupportedCompression(&'static str),
17    #[error("snapshot checksum mismatch")]
18    ChecksumMismatch,
19    #[error("snapshot is encrypted with key id `{0}`, but no matching key was supplied")]
20    MissingEncryptionKey(String),
21    #[error(
22        "snapshot is password-encrypted with key id `{0}`, but no matching password was supplied"
23    )]
24    MissingPassword(String),
25    #[error("snapshot password key derivation failed: {0}")]
26    PasswordKdf(String),
27    #[error("snapshot encryption failed")]
28    Encrypt,
29    #[error("snapshot decryption failed")]
30    Decrypt,
31}
32
33pub type Result<T> = std::result::Result<T, SnapshotCodecError>;