1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ProtocolError {
8 #[error("incomplete packet: expected {expected} bytes, got {actual}")]
10 IncompletePacket {
11 expected: usize,
13 actual: usize,
15 },
16
17 #[error("invalid packet type: {0:#x}")]
19 InvalidPacketType(u8),
20
21 #[error("invalid token type: {0:#x}")]
23 InvalidTokenType(u8),
24
25 #[error("invalid data type: {0:#x}")]
27 InvalidDataType(u8),
28
29 #[error("invalid prelogin option: {0:#x}")]
31 InvalidPreloginOption(u8),
32
33 #[error("invalid TDS version: {0:#x}")]
35 InvalidTdsVersion(u32),
36
37 #[error("string encoding error: {0}")]
39 StringEncoding(
40 #[cfg(feature = "std")] String,
41 #[cfg(not(feature = "std"))] &'static str,
42 ),
43
44 #[error("packet too large: {length} bytes (max {max})")]
46 PacketTooLarge {
47 length: usize,
49 max: usize,
51 },
52
53 #[error("invalid packet status: {0:#x}")]
55 InvalidPacketStatus(u8),
56
57 #[error("buffer overflow: needed {needed} bytes, capacity {capacity}")]
59 BufferOverflow {
60 needed: usize,
62 capacity: usize,
64 },
65
66 #[error("unexpected end of stream")]
68 UnexpectedEof,
69
70 #[error("unsupported protocol version: {0}")]
72 UnsupportedVersion(u32),
73}