simplist 0.0.5

plain and simple http, for when you just want to make a darn request! supports tokio-based async, traditional sync and async-await models.
Documentation
use std;
use std::error::Error;
use std::fmt::Display;
use std::fmt::Formatter;
use std::string::FromUtf8Error;
use std::str::Utf8Error;

use hyper::StatusCode;
use hyper::error::Error as HyperError;
use hyper::error::UriError;



/// the error type for all errors in `crate simplist`.
#[derive(Debug)]
pub enum HttpError {
    Uri   (UriError),
    Hyper (HyperError),
    Utf8  (Utf8Error),
    Status(StatusCode),
}

impl Display for HttpError {
    fn fmt(&self, formatter: &mut Formatter) -> std::fmt::Result {
        match *self {
            HttpError::Uri   (ref x) => Display::fmt(x, formatter),
            HttpError::Hyper (ref x) => Display::fmt(x, formatter),
            HttpError::Utf8  (ref x) => Display::fmt(x, formatter),
            HttpError::Status(    x) => write!(formatter, "HttpError::StatusCode({})", Into::<u16>::into(x)),
        }
    }
}

impl Error for HttpError {
    fn description(&self) -> &str {
        match *self {
            HttpError::Uri   (ref x) => x.description(),
            HttpError::Hyper (ref x) => x.description(),
            HttpError::Utf8  (ref x) => x.description(),
            HttpError::Status(   ..) => "HttpError::StatusCode",
        }
    }

    fn cause(&self) -> Option<&Error> {
        match *self {
            HttpError::Uri   (ref x) => Some(x),
            HttpError::Hyper (ref x) => Some(x),
            HttpError::Utf8  (ref x) => Some(x),
            HttpError::Status(   ..) => None,
        }
    }
}



impl From<UriError> for HttpError {
    fn from(error: UriError) -> HttpError {
        HttpError::Uri(error)
    }
}

impl From<HyperError> for HttpError {
    fn from(error: HyperError) -> HttpError {
        HttpError::Hyper(error)
    }
}

impl From<FromUtf8Error> for HttpError {
    fn from(error: FromUtf8Error) -> HttpError {
        HttpError::Utf8(error.utf8_error())
    }
}