async: Add conversions from static slices to Body

These useful conversions were missed in #159.

refs #158
This commit is contained in:
Kamal Marhubi
2017-09-19 00:18:46 -04:00
parent a7c4a42caa
commit 87f03e167c

View File

@@ -51,6 +51,13 @@ impl From<Vec<u8>> for Body {
}
}
impl From<&'static [u8]> for Body {
#[inline]
fn from(s: &'static [u8]) -> Body {
reusable(Bytes::from_static(s))
}
}
impl From<String> for Body {
#[inline]
fn from(s: String) -> Body {
@@ -58,6 +65,13 @@ impl From<String> for Body {
}
}
impl From<&'static str> for Body {
#[inline]
fn from(s: &'static str) -> Body {
s.as_bytes().into()
}
}
/// A chunk of bytes for a `Body`.
///
/// A `Chunk` can be treated like `&[u8]`.