stream_httparse/streaming_parser/
error.rs

1/// A simple Result wrapper that already has the ParseError
2/// type as its Error-Type
3pub type ParseResult<T> = Result<T, ParseError>;
4
5/// Indicates all Errors related to parsing a Request/Response/Chunk
6#[derive(Debug, Clone, PartialEq)]
7pub enum ParseError {
8    /// Could not find a valid Method in the Request
9    MissingMethod,
10    /// Could not find a valid Path in the Request
11    MissingPath,
12    /// Could not identify the Protocol of the Request/Response
13    MissingProtocol,
14    /// Could not find any headers in the Request/Response
15    MissingHeaders,
16    /// Could not find a StatusCode in the Response
17    MissingStatusCode,
18    /// Returned StatusCode is not valid
19    InvalidStatusCode,
20}
21
22impl std::fmt::Display for ParseError {
23    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24        match *self {
25            Self::MissingMethod => write!(f, "Missing Method"),
26            Self::MissingPath => write!(f, "Missing Path"),
27            Self::MissingProtocol => write!(f, "Missing Protocol"),
28            Self::MissingHeaders => write!(f, "Missing Headers"),
29            Self::MissingStatusCode => write!(f, "Missing StatusCode"),
30            Self::InvalidStatusCode => write!(f, "Invalid StatusCode"),
31        }
32    }
33}