mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-27 00:00:17 +02:00
Impl IntoBuf for Bytes and BytesMut
This commit is contained in:
+33
-1
@@ -1,4 +1,4 @@
|
|||||||
use ByteBuf;
|
use {IntoBuf, ByteBuf, SliceBuf};
|
||||||
|
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::sync::Arc;
|
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 {
|
impl Clone for Bytes {
|
||||||
fn clone(&self) -> Bytes {
|
fn clone(&self) -> Bytes {
|
||||||
Bytes { inner: self.inner.clone() }
|
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 {
|
impl AsRef<[u8]> for BytesMut {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
let end = self.pos + self.len;
|
let end = self.pos + self.len;
|
||||||
|
|||||||
Reference in New Issue
Block a user