Struct Deque

Source
pub struct Deque { /* private fields */ }
Expand description

A fixed-capacity ring buffer for bytes

Implementations§

Source§

impl Deque

Source

pub fn new(capacity: usize) -> Self

Source

pub fn capacity(&self) -> usize

Source

pub fn remaining_capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

pub fn consume(&mut self, len: usize)

Consumes len bytes from the head of the buffer

§Panics

len MUST be less than or equal to Self::len

Source

pub fn filled(&mut self) -> Pair<&mut [u8]>

Returns the filled bytes in the buffer

Source

pub fn consume_filled(&mut self, len: usize) -> Pair<&mut [u8]>

Returns and consumes len filled bytes in the buffer

§Panics

len MUST be less than or equal to Self::len

Source

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.

Source

pub fn make_contiguous(&mut self) -> &mut [u8]

Makes the buffer contiguous and contained in a single slice

Source

pub unsafe fn fill(&mut self, len: usize) -> Result<(), FillError>

Notifies the buffer that len bytes were written to it

§Safety

Callers must ensure the filled bytes were actually initialized

Trait Implementations§

Source§

impl Clone for Deque

Source§

fn clone(&self) -> Deque

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Deque

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Vec<u8>> for Deque

Source§

fn from(buffer: Vec<u8>) -> Deque

Converts to this type from the input type.
Source§

impl Storage for Deque

Source§

fn put_slice(&mut self, bytes: &[u8])

Writes a slice of bytes into the storage Read more
Source§

fn put_uninit_slice<F, Error>( &mut self, payload_len: usize, f: F, ) -> Result<bool, Error>
where F: FnOnce(&mut UninitSlice) -> Result<(), Error>,

Tries to write into a uninit slice for the current storage Read more
Source§

fn remaining_capacity(&self) -> usize

Returns the additional number of bytes that can be written to the storage
Source§

const SPECIALIZES_BYTES: bool = false

Source§

const SPECIALIZES_BYTES_MUT: bool = false

Source§

fn has_remaining_capacity(&self) -> bool

Returns true if the storage will accept any additional bytes
Source§

fn put_bytes(&mut self, bytes: Bytes)

Writes Bytes into the storage Read more
Source§

fn put_bytes_mut(&mut self, bytes: BytesMut)

Writes BytesMut into the storage Read more
Source§

fn put_chunk(&mut self, chunk: Chunk<'_>)

Writes a reader Chunk into the storage
Source§

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>

Tracks the number of bytes written to the storage
Source§

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

Source§

type Error = Infallible

Source§

fn buffered_len(&self) -> usize

Returns the length of the chunk
Source§

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>
where Dest: Storage + ?Sized,

Copies the reader into dest, with a trailing chunk of bytes. Read more
Source§

fn copy_into<Dest>(&mut self, dest: &mut Dest) -> Result<(), Self::Error>
where Dest: Storage + ?Sized,

Copies the reader into dest. Read more
Source§

fn buffer_is_empty(&self) -> bool

Returns if the chunk is empty
Source§

fn full_copy(&mut self) -> FullCopy<'_, Self>

Forces the entire reader to be copied, even when calling partial_copy_into. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Infallible for T
where T: Storage<Error = Infallible> + ?Sized,

Source§

fn infallible_read_chunk(&mut self, watermark: usize) -> Chunk<'_>

Source§

fn infallible_partial_copy_into<Dest>(&mut self, dest: &mut Dest) -> Chunk<'_>
where Dest: Storage + ?Sized,

Source§

fn infallible_copy_into<Dest>(&mut self, dest: &mut Dest)
where Dest: Storage + ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T