use thiserror::Error;
#[derive(Debug, Error)]
pub enum WirePactError {
#[error("incomplete frame: need {needed} bytes, have {available}")]
Incomplete { needed: usize, available: usize },
#[error("frame too large: {size} bytes (max {max})")]
FrameTooLarge { size: u32, max: u32 },
#[error("invalid line encoding: {0}")]
InvalidLine(String),
#[error("invalid frame type: {0}")]
InvalidFrameType(u8),
#[error("invalid payload for {message}: {reason}")]
InvalidPayload {
message: &'static str,
reason: String,
},
#[error("io error: {0}")]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, WirePactError>;