pub struct Take<T> { /* private fields */ }Expand description
The take adapter.
See: Buf::take.
Implementations§
Source§impl<T> Take<T>
impl<T> Take<T>
Sourcepub fn left(&self) -> usize
pub fn left(&self) -> usize
Get the number of bytes logically left in the buffer.
This method is not the same as Buf::remaining(). It returns the maximum number
of bytes the underlying buffer is allowed to have left. The returned value might be
greater than the actual amount of bytes the underlying buffer has left.
Sourcepub fn set_left(&mut self, left: usize)
pub fn set_left(&mut self, left: usize)
Set the maximum amount of bytes the underlying buffer is allowed to have.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Destruct the adapter and get back the underlying buffer.
Trait Implementations§
Source§impl<T: Buf> Buf for Take<T>
impl<T: Buf> Buf for Take<T>
Source§fn advance(&mut self, n: usize)
fn advance(&mut self, n: usize)
Advance the internal cursor of the buffer by
n bytes. Read moreSource§fn has_remaining(&self) -> bool
fn has_remaining(&self) -> bool
Check whether the buffer has any data left in it.
Source§fn copy_to_slice(&mut self, slice: &mut [u8]) -> usize
fn copy_to_slice(&mut self, slice: &mut [u8]) -> usize
Copy data from the buffer into
slice advancing the buffer accordingly.Source§fn copy_to_vec(self, vec: &mut Vec<u8>)where
Self: Sized,
fn copy_to_vec(self, vec: &mut Vec<u8>)where
Self: Sized,
Available on crate feature
alloc only.Copy the buffer into
vec.Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Create a “by reference” adapter that takes the current instance of
Buf
by mutable reference.impl<T: Copy> Copy for Take<T>
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> UnwindSafe for Take<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more