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 bytes::Bytes;
use hyper::Body;



/// the optional body of a http request.
///
/// instances of this object are generally instantiated using one of the provided
/// [`From`](https://doc.rust-lang.org/std/convert/trait.From.html) or
/// [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) conversions.
///
/// # conversions
///
/// [`HttpContent`](struct.HttpContent.html)s can be created from any of the following types, or from an
/// [`Option`](https://doc.rust-lang.org/std/option/enum.Option.html) of any of the following types:
///
/// ## byte types
///
///   - [`Vec<u8>`](https://doc.rust-lang.org/std/vec/struct.Vec.html)
///   - [`&'static [u8]`](https://doc.rust-lang.org/std/primitive.slice.html)
///
/// ## string types
///
///   - [`std::string::String`](https://doc.rust-lang.org/std/string/struct.String.html)
///   - [`&'static str`](https://doc.rust-lang.org/std/primitive.slice.html)
///
/// ## types from other crates
///
///   - [`bytes::Bytes`](https://docs.rs/bytes/0.4.4/bytes/struct.Bytes.html)
///   - [`Option<hyper::Body>`](https://docs.rs/hyper/0.11.1/hyper/struct.Body.html)
///
#[derive(Debug, Default)]
pub struct HttpContent {
    underlying: Body,
}

impl HttpContent {
    /// creates a content object that is empty and has no value.
    ///
    /// # examples
    ///
    /// ```
    /// use simplist::HttpContent;
    ///
    /// let content = HttpContent::none();
    /// ```
    pub fn none() -> HttpContent {
        HttpContent { underlying: Body::default() }
    }
}



impl Into<Body> for HttpContent {
    fn into(self) -> Body {
        self.underlying
    }
}



impl From<Bytes> for HttpContent {
    #[inline]
    fn from(bytes: Bytes) -> HttpContent {
        HttpContent { underlying: bytes.into() }
    }
}

impl From<Vec<u8>> for HttpContent {
    #[inline]
    fn from(vec: Vec<u8>) -> HttpContent {
        HttpContent { underlying: vec.into() }
    }
}

impl From<&'static [u8]> for HttpContent {
    #[inline]
    fn from(slice: &'static [u8]) -> HttpContent {
        HttpContent { underlying: slice.into() }
    }
}

impl From<String> for HttpContent {
    #[inline]
    fn from(string: String) -> HttpContent {
        HttpContent { underlying: string.into() }
    }
}

impl From<&'static str> for HttpContent {
    #[inline]
    fn from(slice: &'static str) -> HttpContent {
        HttpContent { underlying: slice.into() }
    }
}

impl From<Option<Body>> for HttpContent {
    #[inline]
    fn from(body: Option<Body>) -> HttpContent {
        HttpContent { underlying: body.into() }
    }
}

impl<T> From<Option<T>> for HttpContent where T: Into<HttpContent> {
    #[inline]
    fn from(body: Option<T>) -> HttpContent {
        match body {
            Some(x) => x.into(),
            None    => HttpContent::none(),
        }
    }
}