use thiserror::Error;
#[derive(Error, Debug)]
pub enum IgtlError {
#[error("Invalid header: {0}")]
InvalidHeader(String),
#[error("CRC mismatch: expected {expected:#x}, got {actual:#x}")]
CrcMismatch {
expected: u64,
actual: u64,
},
#[error("Unknown message type: {0}")]
UnknownMessageType(String),
#[error("Invalid message size: expected {expected}, got {actual}")]
InvalidSize {
expected: usize,
actual: usize,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("UTF-8 conversion error: {0}")]
Utf8(#[from] std::string::FromUtf8Error),
#[error("Invalid timestamp: {0}")]
InvalidTimestamp(String),
#[error("Message body too large: {size} bytes (max: {max})")]
BodyTooLarge {
size: usize,
max: usize,
},
}
pub type Result<T> = std::result::Result<T, IgtlError>;