tl/
errors.rs

1use core::fmt;
2use std::error::Error;
3
4/// An error that occurred during parsing
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub enum ParseError {
7    /// The input string length was too large to fit in a `u32`
8    InvalidLength,
9}
10
11impl fmt::Display for ParseError {
12    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
13        match self {
14            ParseError::InvalidLength => {
15                write!(f, "The input string length is too large to fit in a `u32`")
16            }
17        }
18    }
19}
20
21impl Error for ParseError {}
22
23/// An error that occurred during a call to `Bytes::set`
24#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
25pub enum SetBytesError {
26    /// The length of the given data would overflow a `u32`
27    LengthOverflow,
28}
29
30impl fmt::Display for SetBytesError {
31    fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
32        match self {
33            SetBytesError::LengthOverflow => {
34                write!(f, "The string length is too large to fit in a `u32`")
35            }
36        }
37    }
38}
39
40impl Error for SetBytesError {}