[][src]Struct rtrb::WriteChunk

pub struct WriteChunk<'a, T>(_);

Structure for writing into multiple (Default-initialized) slots in one go.

This is returned from Producer::write_chunk().

For an unsafe alternative that provides uninitialized slots, see WriteChunkUninit.

The slots (which initially contain Default values) can be accessed with as_mut_slices() or by iteration, which yields mutable references (in other words: &mut T). A mutable reference (&mut) to the WriteChunk should be used to iterate over it. Each slot can only be iterated once and the number of iterations is tracked.

After writing, the provided slots are not automatically made available to be read by the Consumer. If desired, this has to be explicitly done by calling commit(), commit_iterated() or commit_all().

Implementations

impl<T, '_> WriteChunk<'_, T> where
    T: Copy + Default
[src]

pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T])[src]

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.

See RingBuffer::with_chunks() for a way to make sure that the second slice is always empty.

pub fn commit(self, n: usize)[src]

Makes the first n slots of the chunk available for reading.

Panics

Panics if n is greater than the number of slots in the chunk.

pub fn commit_iterated(self) -> usize[src]

Returns the number of iterated slots and makes them available for reading.

pub fn commit_all(self)[src]

Makes the whole chunk available for reading.

pub fn len(&self) -> usize[src]

Returns the number of slots in the chunk.

pub fn is_empty(&self) -> bool[src]

Returns true if the chunk contains no slots.

Trait Implementations

impl<'a, T: Debug> Debug for WriteChunk<'a, T>[src]

impl<'a, T> From<WriteChunkUninit<'a, T>> for WriteChunk<'a, T> where
    T: Copy + Default
[src]

pub fn from(chunk: WriteChunkUninit<'a, T>) -> Self[src]

Fills all slots with the Default value.

impl<'a, T> Iterator for WriteChunk<'a, T> where
    T: Copy + Default
[src]

type Item = &'a mut T

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for WriteChunk<'a, T>

impl<'a, T> !Send for WriteChunk<'a, T>

impl<'a, T> !Sync for WriteChunk<'a, T>

impl<'a, T> Unpin for WriteChunk<'a, T>

impl<'a, T> !UnwindSafe for WriteChunk<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.