use thiserror::Error;
pub type ProtocolResult<T> = Result<T, ProtocolError>;
#[derive(Debug, Error)]
pub enum ProtocolError {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("cbor encode error: {0}")]
CborEncode(#[from] ciborium::ser::Error<std::io::Error>),
#[error("cbor decode error: {0}")]
CborDecode(#[from] ciborium::de::Error<std::io::Error>),
#[error("frame too large: {size} bytes (max {max})")]
FrameTooLarge {
size: u32,
max: u32,
},
#[error("frame payload too short: {size} bytes (minimum {min})")]
FrameTooShort {
size: u32,
min: u32,
},
#[error("unexpected end of stream")]
UnexpectedEof,
}