Skip to content
Snippets Groups Projects
Commit a367a723 authored by Carl Lerche's avatar Carl Lerche
Browse files

Impl IntoBuf for Bytes and BytesMut

parent 11fe277c
No related branches found
No related tags found
No related merge requests found
use ByteBuf;
use {IntoBuf, ByteBuf, SliceBuf};
use std::cell::UnsafeCell;
use std::sync::Arc;
......@@ -130,6 +130,22 @@ impl Bytes {
}
}
impl IntoBuf for Bytes {
type Buf = SliceBuf<Self>;
fn into_buf(self) -> Self::Buf {
SliceBuf::new(self)
}
}
impl<'a> IntoBuf for &'a Bytes {
type Buf = SliceBuf<Self>;
fn into_buf(self) -> Self::Buf {
SliceBuf::new(self)
}
}
impl Clone for Bytes {
fn clone(&self) -> Bytes {
Bytes { inner: self.inner.clone() }
......@@ -343,6 +359,22 @@ impl BytesMut {
}
}
impl IntoBuf for BytesMut {
type Buf = SliceBuf<Self>;
fn into_buf(self) -> Self::Buf {
SliceBuf::new(self)
}
}
impl<'a> IntoBuf for &'a BytesMut {
type Buf = SliceBuf<&'a BytesMut>;
fn into_buf(self) -> Self::Buf {
SliceBuf::new(self)
}
}
impl AsRef<[u8]> for BytesMut {
fn as_ref(&self) -> &[u8] {
let end = self.pos + self.len;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment