Skip to content

Commit

Permalink
Merge pull request #21 from 17dec/master
Browse files Browse the repository at this point in the history
Implement Display for Error and InvalidChunkSize
  • Loading branch information
seanmonstar authored Sep 12, 2016
2 parents 2e64a82 + f58d6d8 commit 49bf4d8
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit 49bf4d8

Please sign in to comment.