diff --git a/src/error.rs b/src/error.rs index bbafb1c41..4cbfe39eb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -590,6 +590,32 @@ impl From for JsonPayloadError { } } +/// Error type returned when reading body as lines. +pub enum ReadlinesError { + EncodingError, + PayloadError(PayloadError), + LimitOverflow, + ContentTypeError(ContentTypeError), +} + +impl From for ReadlinesError { + fn from(err: PayloadError) -> Self { + ReadlinesError::PayloadError(err) + } +} + +impl From for ReadlinesError { + fn from(_: Error) -> Self { + ReadlinesError::EncodingError + } +} + +impl From for ReadlinesError { + fn from(err: ContentTypeError) -> Self { + ReadlinesError::ContentTypeError(err) + } +} + /// Errors which can occur when attempting to interpret a segment string as a /// valid path segment. #[derive(Fail, Debug, PartialEq)] diff --git a/src/httpmessage.rs b/src/httpmessage.rs index 91ea09f69..a380f3b98 100644 --- a/src/httpmessage.rs +++ b/src/httpmessage.rs @@ -13,7 +13,7 @@ use std::str; use error::{ ContentTypeError, HttpRangeError, ParseError, PayloadError, UrlencodedError, - Error, ErrorBadRequest + Error, ErrorBadRequest, ReadlinesError }; use header::Header; use json::JsonBody; @@ -394,31 +394,6 @@ where } } -pub enum ReadlinesError { - EncodingError, - PayloadError(PayloadError), - LimitOverflow, - ContentTypeError(ContentTypeError), -} - -impl From for ReadlinesError { - fn from(err: PayloadError) -> Self { - ReadlinesError::PayloadError(err) - } -} - -impl From for ReadlinesError { - fn from(_: Error) -> Self { - ReadlinesError::EncodingError - } -} - -impl From for ReadlinesError { - fn from(err: ContentTypeError) -> Self { - ReadlinesError::ContentTypeError(err) - } -} - /// Future that resolves to a complete http message body. pub struct MessageBody { limit: usize,