From 6dfb7a5a0ed361bb5f8bcdec6be50da4636b4c77 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 11 Sep 2018 13:52:04 -0700 Subject: [PATCH] pub(crate)ify the error module --- src/error.rs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/error.rs b/src/error.rs index 3c817fd..d701f4a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -253,7 +253,7 @@ impl StdError for Error { // pub(crate) #[derive(Debug)] -pub enum Kind { +pub(crate) enum Kind { Http(::http::Error), Hyper(::hyper::Error), Mime(::mime::FromStrError), @@ -344,10 +344,8 @@ fn io_timeout() -> io::Error { io::Error::new(io::ErrorKind::TimedOut, "timed out") } -// pub(crate) - #[allow(missing_debug_implementations)] -pub struct InternalFrom(pub T, pub Option); +pub(crate) struct InternalFrom(pub T, pub Option); #[doc(hidden)] // https://github.com/rust-lang/rust/issues/42323 impl From> for Error { @@ -371,16 +369,14 @@ where } } -#[inline] -pub fn from(err: T) -> Error +pub(crate) fn from(err: T) -> Error where T: Into, { InternalFrom(err, None).into() } -#[inline] -pub fn into_io(e: Error) -> io::Error { +pub(crate) fn into_io(e: Error) -> io::Error { match e.kind { Kind::Io(io) => io, _ => io::Error::new(io::ErrorKind::Other, e), @@ -407,40 +403,35 @@ macro_rules! try_ { ) } -#[inline] -pub fn loop_detected(url: Url) -> Error { +pub(crate) fn loop_detected(url: Url) -> Error { Error { kind: Kind::RedirectLoop, url: Some(url), } } -#[inline] -pub fn too_many_redirects(url: Url) -> Error { +pub(crate) fn too_many_redirects(url: Url) -> Error { Error { kind: Kind::TooManyRedirects, url: Some(url), } } -#[inline] -pub fn timedout(url: Option) -> Error { +pub(crate) fn timedout(url: Option) -> Error { Error { kind: Kind::Io(io_timeout()), url: url, } } -#[inline] -pub fn client_error(url: Url, status: StatusCode) -> Error { +pub(crate) fn client_error(url: Url, status: StatusCode) -> Error { Error { kind: Kind::ClientError(status), url: Some(url), } } -#[inline] -pub fn server_error(url: Url, status: StatusCode) -> Error { +pub(crate) fn server_error(url: Url, status: StatusCode) -> Error { Error { kind: Kind::ServerError(status), url: Some(url),