Struct Take
pub struct Take<T> { /* private fields */ }Expand description
A Buf adapter which limits the bytes read from an underlying buffer.
This struct is generally created by calling take() on Buf. See
documentation of take() for more details.
Implementations§
§impl<T> Take<T>
impl<T> Take<T>
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this Take, returning the underlying value.
§Examples
use bytes::{Buf, BufMut};
let mut buf = b"hello world".take(2);
let mut dst = vec![];
dst.put(&mut buf);
assert_eq!(*dst, b"he"[..]);
let mut buf = buf.into_inner();
dst.clear();
dst.put(&mut buf);
assert_eq!(*dst, b"llo world"[..]);pub fn get_ref(&self) -> &T
pub fn get_ref(&self) -> &T
Gets a reference to the underlying Buf.
It is inadvisable to directly read from the underlying Buf.
§Examples
use bytes::Buf;
let buf = b"hello world".take(2);
assert_eq!(11, buf.get_ref().remaining());