toad_msg/msg/
parse_error.rs

1#[allow(unused_imports)]
2use crate::Type;
3
4/// Errors encounterable while parsing a message from bytes
5#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
6pub enum MessageParseError {
7  /// Reached end of stream before parsing was finished
8  UnexpectedEndOfStream,
9
10  /// Token length was > 8
11  InvalidTokenLength(u8),
12
13  /// Error parsing option
14  OptParseError(super::opt::parse_error::OptParseError),
15
16  /// The rest of the message contained more bytes than there was capacity for
17  PayloadTooLong(usize),
18
19  /// The message type is invalid (see [`Type`] for information & valid values)
20  InvalidType(u8),
21}
22
23impl MessageParseError {
24  /// Shorthand for [`MessageParseError::UnexpectedEndOfStream`]
25  pub fn eof() -> Self {
26    Self::UnexpectedEndOfStream
27  }
28}