pub struct Consumer<'a, T: Sized, const N: usize> { /* private fields */ }Expand description
A Consumer is a smart pointer to a Buffer, which is endowed with
the right to remove data from the buffer. Only one Consumer may exist
at one time for any given buffer. The methods of a Consumer are the
only way to read data out of a Buffer.
Implementations§
Source§impl<'a, T: Sized, const N: usize> Consumer<'a, T, N>
impl<'a, T: Sized, const N: usize> Consumer<'a, T, N>
Sourcepub fn read<'b>(&'b mut self, target_len: usize) -> Region<'b, Self, T>
pub fn read<'b>(&'b mut self, target_len: usize) -> Region<'b, Self, T>
Return a Region for up to target_len elements to be read from
the buffer. The returned region may be shorter than target_len.
The returned region has length zero if and only if the buffer is empty.
The returned region is guaranteed to be not longer than target_len.
To read the largest possible length, set target_len = usize::MAX.
Even though we are reading from the buffer, the Region which is returned
is mutable. Its memory is available for arbitrary use by the caller
for as long as the Region remains in scope.