pub struct Deque { /* private fields */ }Expand description
A fixed-capacity ring buffer for bytes
Implementations§
Source§impl Deque
impl Deque
pub fn new(capacity: usize) -> Self
pub fn capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Resets the filled bytes in the buffer
Note that data is not actually wiped with this method. If that behavior is desired then
calling Self::consume_filled should be preferred.
Sourcepub fn consume_filled(&mut self, len: usize) -> Pair<&mut [u8]>
pub fn consume_filled(&mut self, len: usize) -> Pair<&mut [u8]>
Sourcepub fn unfilled(&mut self) -> Pair<&mut [MaybeUninit<u8>]>
pub fn unfilled(&mut self) -> Pair<&mut [MaybeUninit<u8>]>
Returns the unfilled bytes in the buffer
Callers will need to call Self::fill to indicate any writes that occurred to returned
slices.
Sourcepub fn make_contiguous(&mut self) -> &mut [u8] ⓘ
pub fn make_contiguous(&mut self) -> &mut [u8] ⓘ
Makes the buffer contiguous and contained in a single slice
Trait Implementations§
Source§impl Storage for Deque
impl Storage for Deque
Source§fn put_uninit_slice<F, Error>(
&mut self,
payload_len: usize,
f: F,
) -> Result<bool, Error>
fn put_uninit_slice<F, Error>( &mut self, payload_len: usize, f: F, ) -> Result<bool, Error>
Tries to write into a uninit slice for the current storage Read more
Source§fn remaining_capacity(&self) -> usize
fn remaining_capacity(&self) -> usize
Returns the additional number of bytes that can be written to the storage
const SPECIALIZES_BYTES: bool = false
const SPECIALIZES_BYTES_MUT: bool = false
Source§fn has_remaining_capacity(&self) -> bool
fn has_remaining_capacity(&self) -> bool
Returns
true if the storage will accept any additional bytesSource§fn with_write_limit(&mut self, max_len: usize) -> Limit<'_, Self>
fn with_write_limit(&mut self, max_len: usize) -> Limit<'_, Self>
Limits the number of bytes that can be written to the storage
Source§fn track_write(&mut self) -> Tracked<'_, Self>
fn track_write(&mut self) -> Tracked<'_, Self>
Tracks the number of bytes written to the storage
Source§fn write_once(&mut self) -> WriteOnce<'_, Self>
fn write_once(&mut self) -> WriteOnce<'_, Self>
Only allows a single write into the storage. After that, no more writes are allowed. Read more
Source§impl Storage for Deque
impl Storage for Deque
type Error = Infallible
Source§fn buffered_len(&self) -> usize
fn buffered_len(&self) -> usize
Returns the length of the chunk
Source§fn read_chunk(&mut self, watermark: usize) -> Result<Chunk<'_>, Self::Error>
fn read_chunk(&mut self, watermark: usize) -> Result<Chunk<'_>, Self::Error>
Reads the current contiguous chunk
Source§fn partial_copy_into<Dest>(
&mut self,
dest: &mut Dest,
) -> Result<Chunk<'_>, Self::Error>
fn partial_copy_into<Dest>( &mut self, dest: &mut Dest, ) -> Result<Chunk<'_>, Self::Error>
Copies the reader into
dest, with a trailing chunk of bytes. Read moreSource§fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
Copies the reader into
dest. Read moreSource§fn buffer_is_empty(&self) -> bool
fn buffer_is_empty(&self) -> bool
Returns if the chunk is empty
Source§fn full_copy(&mut self) -> FullCopy<'_, Self>
fn full_copy(&mut self) -> FullCopy<'_, Self>
Forces the entire reader to be copied, even when calling
partial_copy_into. Read moreSource§fn track_read(&mut self) -> Tracked<'_, Self>
fn track_read(&mut self) -> Tracked<'_, Self>
Tracks the number of bytes read from the storage
Auto Trait Implementations§
impl Freeze for Deque
impl RefUnwindSafe for Deque
impl Send for Deque
impl Sync for Deque
impl Unpin for Deque
impl UnwindSafe for Deque
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