Struct Take
pub struct Take<T> { /* private fields */ }
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) -> 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) -> &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(&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) -> 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(&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!;
Trait Implementations
impl<T: Buf> Buf for Take<T>
fn remaining(&self) -> usizefn chunk(&self) -> &[u8]fn advance(&mut self, cnt: usize)fn copy_to_bytes(&mut self, len: usize) -> Bytesfn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize
impl<T: Debug> Debug for Take<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T> Freeze for Take<T>
where
T: Freeze,
impl<T> RefUnwindSafe for Take<T>
where
T: RefUnwindSafe,
impl<T> Send for Take<T>
where
T: Send,
impl<T> Sync for Take<T>
where
T: Sync,
impl<T> Unpin for Take<T>
where
T: Unpin,
impl<T> UnsafeUnpin for Take<T>
where
T: UnsafeUnpin,
impl<T> UnwindSafe for Take<T>
where
T: UnwindSafe,
Blanket Implementations
impl<T> Any for Take<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Take<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Take<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Take<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Take<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Take<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Take<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>