1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum PcdError {
5 #[error("IO error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("Invalid header at line {line}: {msg}")]
9 InvalidHeader { line: usize, msg: String },
10
11 #[error("Unsupported field type: {0}")]
12 UnsupportedType(String),
13
14 #[error("Unsupported data format: {0}")]
15 UnsupportedDataFormat(String),
16
17 #[error("Invalid data: {0}")]
18 InvalidDataFormat(String),
19
20 #[error("Decompression failed: {0}")]
21 Decompression(String),
22
23 #[error("Layout mismatch: expected {expected}, got {got}")]
24 LayoutMismatch { expected: usize, got: usize },
25
26 #[error("Buffer too small: expected {expected}, got {got}")]
27 BufferTooSmall { expected: usize, got: usize },
28
29 #[error("{0}")]
30 Other(String),
31}
32
33pub type Result<T> = std::result::Result<T, PcdError>;