1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum ProtoError {
6 #[error("I/O error: {0}")]
7 Io(#[from] std::io::Error),
8
9 #[error("bincode encode error: {0}")]
10 Encode(#[from] bincode::error::EncodeError),
11
12 #[error("bincode decode error: {0}")]
13 Decode(#[from] bincode::error::DecodeError),
14
15 #[error("unknown message type: {0:#04x}")]
16 UnknownMessageType(u8),
17
18 #[error("frame too large: {size} bytes (max {max})")]
19 FrameTooLarge { size: u32, max: u32 },
20
21 #[error("incomplete frame: expected {expected} bytes, got {actual}")]
22 IncompleteFrame { expected: usize, actual: usize },
23}