use bytes::Bytes;
pub struct Contents {
data: Bytes,
}
impl From<Bytes> for Contents {
fn from(data: Bytes) -> Self {
Self { data }
}
}
impl From<Contents> for Vec<u8> {
fn from(contents: Contents) -> Self {
contents.data.to_vec()
}
}
impl TryFrom<Contents> for String {
type Error = std::string::FromUtf8Error;
fn try_from(contents: Contents) -> Result<Self, Self::Error> {
Self::from_utf8(contents.data.to_vec())
}
}