use bytes::{Bytes, BytesMut};
pub trait IntoBytes {
fn into_bytes(self) -> Bytes;
}
impl IntoBytes for Bytes {
fn into_bytes(self) -> Bytes {
self
}
}
impl IntoBytes for BytesMut {
fn into_bytes(self) -> Bytes {
Bytes::from(self)
}
}
impl IntoBytes for String {
fn into_bytes(self) -> Bytes {
Bytes::from(self)
}
}
impl IntoBytes for Box<str> {
fn into_bytes(self) -> Bytes {
Bytes::from(Box::<[u8]>::from(self))
}
}
impl IntoBytes for &str {
fn into_bytes(self) -> Bytes {
Bytes::copy_from_slice(self.as_bytes())
}
}
impl IntoBytes for Vec<u8> {
fn into_bytes(self) -> Bytes {
Bytes::from(self)
}
}
impl IntoBytes for Box<[u8]> {
fn into_bytes(self) -> Bytes {
Bytes::from(self)
}
}
impl IntoBytes for &[u8] {
fn into_bytes(self) -> Bytes {
Bytes::copy_from_slice(self)
}
}