Struct cl_generic_vec::GenericReadBufRef
source · [−]Expand description
A wrapper around &mut GenericReadBuf
which prevents the buffer that the GenericReadBuf
points to from being replaced.
Implementations
sourceimpl<'a, S: Storage<Item = u8> + ?Sized> GenericReadBufRef<'a, S>
impl<'a, S: Storage<Item = u8> + ?Sized> GenericReadBufRef<'a, S>
sourcepub fn reborrow(&mut self) -> GenericReadBufRef<'_, S>
pub fn reborrow(&mut self) -> GenericReadBufRef<'_, S>
Creates a new ReadBufRef
referencing the same ReadBuf
as this one.
sourcepub fn filled_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn filled_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a mutable reference to the filled portion of the buffer.
sourcepub fn initialized_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn initialized_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a mutable reference to the initialized portion of the buffer.
This includes the filled portion.
sourcepub unsafe fn unfilled_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub unsafe fn unfilled_mut(&mut self) -> &mut [MaybeUninit<u8>]
Returns a mutable reference to the unfilled part of the buffer without ensuring that it has been fully initialized.
Safety
The caller must not de-initialize portions of the buffer that have already been initialized.
sourcepub fn uninitialized_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub fn uninitialized_mut(&mut self) -> &mut [MaybeUninit<u8>]
Returns a mutable reference to the uninitialized part of the buffer.
It is safe to uninitialize any of these bytes.
sourcepub fn initialize_unfilled(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn initialize_unfilled(&mut self) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a mutable reference to the unfilled part of the buffer, ensuring it is fully initialized.
Since ReadBuf
tracks the region of the buffer that has been initialized, this is effectively “free” after
the first use.
sourcepub fn initialize_unfilled_to(&mut self, n: usize) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn initialize_unfilled_to(&mut self, n: usize) -> &mut [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a mutable reference to the first n
bytes of the unfilled part of the buffer, ensuring it is
fully initialized.
Panics
Panics if self.remaining()
is less than n
.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the buffer, resetting the filled region to empty.
The number of initialized bytes is not changed, and the contents of the buffer are not modified.
sourcepub fn add_filled(&mut self, n: usize)
pub fn add_filled(&mut self, n: usize)
Increases the size of the filled region of the buffer.
The number of initialized bytes is not changed.
Panics
Panics if the filled region of the buffer would become larger than the initialized region.
sourcepub fn set_filled(&mut self, n: usize)
pub fn set_filled(&mut self, n: usize)
Sets the size of the filled region of the buffer.
The number of initialized bytes is not changed.
Note that this can be used to shrink the filled region of the buffer in addition to growing it (for
example, by a Read
implementation that compresses data in-place).
Panics
Panics if the filled region of the buffer would become larger than the initialized region.
sourcepub unsafe fn assume_init(&mut self, n: usize)
pub unsafe fn assume_init(&mut self, n: usize)
Asserts that the first n
unfilled bytes of the buffer are initialized.
ReadBuf
assumes that bytes are never de-initialized, so this method does nothing when called with fewer
bytes than are already known to be initialized.
Safety
The caller must ensure that the first n
unfilled bytes of the buffer have already been initialized.
Methods from Deref<Target = GenericReadBuf<S>>
sourcepub fn filled(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn filled(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a shared reference to the filled portion of the buffer.
sourcepub fn initialized(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn initialized(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a shared reference to the initialized portion of the buffer.
This includes the filled portion.
sourcepub fn remaining(&self) -> usize
pub fn remaining(&self) -> usize
Returns the number of bytes at the end of the slice that have not yet been filled.
sourcepub fn filled_len(&self) -> usize
pub fn filled_len(&self) -> usize
Returns the amount of bytes that have been filled.
sourcepub fn initialized_len(&self) -> usize
pub fn initialized_len(&self) -> usize
Returns the amount of bytes that have been initialized.
Trait Implementations
sourceimpl<'a, S: Storage<Item = u8> + ?Sized> Deref for GenericReadBufRef<'a, S>
impl<'a, S: Storage<Item = u8> + ?Sized> Deref for GenericReadBufRef<'a, S>
type Target = GenericReadBuf<S>
type Target = GenericReadBuf<S>
The resulting type after dereferencing.
sourcefn deref(&self) -> &GenericReadBuf<S>
fn deref(&self) -> &GenericReadBuf<S>
Dereferences the value.
Auto Trait Implementations
impl<'a, S: ?Sized> RefUnwindSafe for GenericReadBufRef<'a, S> where
S: RefUnwindSafe,
impl<'a, S: ?Sized> Send for GenericReadBufRef<'a, S> where
S: Send,
impl<'a, S: ?Sized> Sync for GenericReadBufRef<'a, S> where
S: Sync,
impl<'a, S: ?Sized> Unpin for GenericReadBufRef<'a, S>
impl<'a, S> !UnwindSafe for GenericReadBufRef<'a, S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more