Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,31 @@ pub enum Error {
Version,
}

impl ::core::fmt::Display for Error {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {
Error::HeaderName => f.write_str("invalid header name"),
Error::HeaderValue => f.write_str("invalid header value"),
Error::NewLine => f.write_str("invalid new line"),
Error::Status => f.write_str("invalid response status"),
Error::Token => f.write_str("invalid token"),
Error::TooManyHeaders => f.write_str("too many headers"),
Error::Version => f.write_str("invalid HTTP version"),
}
}
}

/// An error in parsing a chunk size.
// Note: Move this into the error enum once v2.0 is released.
#[derive(Debug, PartialEq, Eq)]
pub struct InvalidChunkSize;

impl ::core::fmt::Display for InvalidChunkSize {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
f.write_str("invalid chunk size")
}
}

/// A Result of any parsing action.
///
/// If the input is invalid, an `Error` will be returned. Note that incomplete
Expand Down