pub struct ReadBufMut<'a> { /* private fields */ }Expand description
A type that grants mutable access to a ReadBuf.
You can create this by calling ReadBuf::as_mut.
Implementations§
Source§impl<'a> ReadBufMut<'a>
impl<'a> ReadBufMut<'a>
Sourcepub unsafe fn buf_mut(&mut self) -> &mut ReadBuf<'a>
pub unsafe fn buf_mut(&mut self) -> &mut ReadBuf<'a>
Get a mutable reference to the internal buffer.
§Safety
This must not be moved out of, and the buffer’s pointer to the bytes must not be changed.
Sourcepub unsafe fn into_mut(self) -> &'a mut ReadBuf<'a>
pub unsafe fn into_mut(self) -> &'a mut ReadBuf<'a>
Convert this type to a mutable reference to the internal buffer.
§Safety
This must not be moved out of, and the buffer’s pointer to the bytes must not be changed.
Sourcepub fn as_mut(&mut self) -> ReadBufMut<'_>
pub fn as_mut(&mut self) -> ReadBufMut<'_>
Borrow the buffer, rather than consuming it.
Source§impl ReadBufMut<'_>
These methods are also present on ReadBuf.
impl ReadBufMut<'_>
These methods are also present on ReadBuf.
Sourcepub fn filled_mut(&mut self) -> &mut [u8] ⓘ
pub fn filled_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable reference to the filled portion of the buffer.
Sourcepub fn initialized(&self) -> &[u8] ⓘ
pub fn initialized(&self) -> &[u8] ⓘ
Get a shared reference to the initialized portion of the buffer.
This includes the filled portion.
Sourcepub fn initialized_mut(&mut self) -> &mut [u8] ⓘ
pub fn initialized_mut(&mut self) -> &mut [u8] ⓘ
Get 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>]
Get a mutable reference to the unfilled part of the buffer without ensuring that it has been fully initialized.
§Safety
The caller must not deinitialize portions of the buffer that have already been initialized.
Sourcepub fn all(&self) -> &[MaybeUninit<u8>]
pub fn all(&self) -> &[MaybeUninit<u8>]
Get a shared reference to the entire backing buffer.
Sourcepub unsafe fn all_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub unsafe fn all_mut(&mut self) -> &mut [MaybeUninit<u8>]
Get a mutable reference to the entire backing buffer.
§Safety
The caller must not deinitialize portions of the buffer that have already been initialized.
Sourcepub fn initialize_unfilled(&mut self) -> &mut [u8] ⓘ
pub fn initialize_unfilled(&mut self) -> &mut [u8] ⓘ
Get 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] ⓘ
pub fn initialize_unfilled_to(&mut self, n: usize) -> &mut [u8] ⓘ
Get 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 remaining(&self) -> usize
pub fn remaining(&self) -> usize
Get the number of bytes at the end of the slice that have not yet been filled.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the buffer, resetting the filled region to empty.
The number of initialized bytes is not changed, and the contents of the buffer is not modified.
Sourcepub fn add_filled(&mut self, n: usize)
pub fn add_filled(&mut self, n: usize)
Increase the size of the filled region of the buffer by n bytes.
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)
Set the size of the filled region of the buffer to n.
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 deinitialized, 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.