Struct Take
struct Take<T> { ... }
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>
fn into_inner(self: Self) -> TConsumes this
Take, returning the underlying value.Examples
use ; let mut buf = b"hello world".take; let mut dst = vec!; dst.put; assert_eq!; let mut buf = buf.into_inner; dst.clear; dst.put; assert_eq!;fn get_ref(self: &Self) -> &TGets a reference to the underlying
Buf.It is inadvisable to directly read from the underlying
Buf.Examples
use Buf; let buf = b"hello world".take; assert_eq!;fn get_mut(self: &mut Self) -> &mut TGets a mutable reference to the underlying
Buf.It is inadvisable to directly read from the underlying
Buf.Examples
use ; let mut buf = b"hello world".take; let mut dst = vec!; buf.get_mut.advance; dst.put; assert_eq!;fn limit(self: &Self) -> usizeReturns the maximum number of bytes that can be read.
Note
If the inner
Bufhas fewer bytes than indicated by this method then that is the actual number of available bytes.Examples
use Buf; let mut buf = b"hello world".take; assert_eq!; assert_eq!; assert_eq!;fn set_limit(self: &mut Self, lim: usize)Sets the maximum number of bytes that can be read.
Note
If the inner
Bufhas fewer bytes thanlimthen that is the actual number of available bytes.Examples
use ; let mut buf = b"hello world".take; let mut dst = vec!; dst.put; assert_eq!; dst.clear; buf.set_limit; dst.put; assert_eq!;
impl<T> Any for Take<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Take<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Take<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> Freeze for Take<T>
impl<T> From for Take<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> RefUnwindSafe for Take<T>
impl<T> Send for Take<T>
impl<T> Sync for Take<T>
impl<T> Unpin for Take<T>
impl<T> UnsafeUnpin for Take<T>
impl<T> UnwindSafe for Take<T>
impl<T, U> Into for Take<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Take<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Take<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: $crate::fmt::Debug> Debug for Take<T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T: Buf> Buf for Take<T>
fn remaining(self: &Self) -> usizefn chunk(self: &Self) -> &[u8]fn advance(self: &mut Self, cnt: usize)fn copy_to_bytes(self: &mut Self, len: usize) -> Bytesfn chunks_vectored<'a>(self: &'a Self, dst: &mut [IoSlice<'a>]) -> usize