1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use thiserror::Error;
/// An error encountered while reading a RESP stream.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum RespError {
/// Reached the end of the stream unexpectedly
#[error("unexpected end of input")]
EndOfInput,
/// Received an invalid boolean
#[error("invalid boolean")]
InvalidBoolean,
/// Received an invalid blob
#[error("invalid blob length")]
InvalidBlobLength,
/// Received an invalid double
#[error("invalid double")]
InvalidDouble,
/// Received an invalid integer
#[error("invalid integer")]
InvalidInteger,
/// Received an invalid map
#[error("invalid map")]
InvalidMap,
/// Received an invalid set
#[error("invalid set")]
InvalidSet,
/// Received an invalid verbatim
#[error("invalid verbatim")]
InvalidVerbatim,
/// Error reading from the stream.
#[error("io error")]
IO(#[from] std::io::Error),
/// Simple frame cannot contain a newline.
#[error("newline is not allowed in this frame")]
Newline,
/// Unsupported in current version.
#[error("unsupported in the current version")]
Version,
/// Expected a primitive, but got a complex value
#[error("map keys and set values must be primitives")]
RespPrimitive,
/// Received an inline request that was too big.
#[error("too big inline request")]
TooBigInline,
/// Unexpected byte sequence
#[error("expected {:?}, got {:?}", char::from(*.0), char::from(*.1))]
Unexpected(u8, u8),
/// Unknown RESP type
#[error("unknown resp type: {:?}", char::from(*.0))]
UnknownType(u8),
/// Invalid inline command
#[error("invalid inline command")]
InvalidInline,
}