toad_msg/msg/opt/
parse_error.rs

1/// Errors encounterable while parsing an option from bytes
2#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
3pub enum OptParseError {
4  /// Reached end of stream before parsing was finished
5  UnexpectedEndOfStream,
6
7  /// Option value was longer than the fixed capacity
8  #[allow(missing_docs)]
9  OptionValueTooLong { capacity: usize, actual: usize },
10
11  /// Parsed more options than reserved capacity
12  TooManyOptions(usize),
13
14  /// Option Delta was set to 15, which is invalid.
15  OptionDeltaReservedValue(u8),
16
17  /// Value Length was set to 15, which is invalid.
18  ValueLengthReservedValue(u8),
19
20  /// Not a true failure case; only means we tried to read the payload marker byte (0xFF)
21  /// as an option header.
22  OptionsExhausted,
23}
24
25impl OptParseError {
26  /// Shorthand for [`OptParseError::UnexpectedEndOfStream`]
27  pub fn eof() -> Self {
28    Self::UnexpectedEndOfStream
29  }
30}