pub struct WriteChunk<'a, T: Send + 'static>(/* private fields */);
Expand description
Structure for writing into multiple (Default
-initialized) slots in one go.
This is returned from Producer::write_chunk()
.
To obtain uninitialized slots, use Producer::write_chunk_uninit()
instead,
which also allows moving items from an iterator into the ring buffer
by means of WriteChunkUninit::fill_from_iter()
.
Implementations§
Source§impl<T> WriteChunk<'_, T>
impl<T> WriteChunk<'_, T>
Sourcepub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T])
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T])
Returns two slices for writing to the requested slots.
All slots are initially filled with their Default
value.
The first slice can only be empty if 0
slots have been requested.
If the first slice contains all requested slots, the second one is empty.
After writing to the slots, they are not automatically made available
to be read by the Consumer
.
This has to be explicitly done by calling commit()
or commit_all()
.
If items are written but not committed afterwards,
they will not become available for reading and
they will be leaked (which is only relevant if T
implements Drop
).
Sourcepub fn commit(self, n: usize)
pub fn commit(self, n: usize)
Makes the first n
slots of the chunk available for reading.
The rest of the chunk is dropped.
§Panics
Panics if n
is greater than the number of slots in the chunk.
Sourcepub fn commit_all(self)
pub fn commit_all(self)
Makes the whole chunk available for reading.
Trait Implementations§
Source§impl<T: Send + 'static> Drop for WriteChunk<'_, T>
impl<T: Send + 'static> Drop for WriteChunk<'_, T>
Source§impl<'a, T> From<WriteChunkUninit<'a, T>> for WriteChunk<'a, T>
impl<'a, T> From<WriteChunkUninit<'a, T>> for WriteChunk<'a, T>
Source§fn from(chunk: WriteChunkUninit<'a, T>) -> Self
fn from(chunk: WriteChunkUninit<'a, T>) -> Self
Fills all slots with the Default
value.