Skip to main content

nodedb_codec/
error.rs

1//! Error types for codec operations.
2
3/// Errors that can occur during encoding or decoding.
4#[derive(Debug, thiserror::Error)]
5pub enum CodecError {
6    /// Input data is too short or truncated.
7    #[error("truncated input: expected at least {expected} bytes, got {actual}")]
8    Truncated { expected: usize, actual: usize },
9
10    /// Input data is corrupted (invalid header, bad checksum, etc.).
11    #[error("corrupt data: {detail}")]
12    Corrupt { detail: String },
13
14    /// Decompression failed (LZ4/Zstd library error).
15    #[error("decompression failed: {detail}")]
16    DecompressFailed { detail: String },
17
18    /// Compression failed (LZ4/Zstd library error).
19    #[error("compression failed: {detail}")]
20    CompressFailed { detail: String },
21
22    /// The codec stored in metadata doesn't match the expected codec.
23    #[error("codec mismatch: expected {expected}, found {found}")]
24    CodecMismatch { expected: String, found: String },
25}