use bytes::Bytes;
use hyper::Body;
#[derive(Debug, Default)]
pub struct HttpContent {
underlying: Body,
}
impl HttpContent {
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(),
}
}
}