[][src]Struct rtrb::WriteChunkUninit

pub struct WriteChunkUninit<'a, T> { /* fields omitted */ }

Structure for writing into multiple (uninitialized) slots in one go.

This is returned from Producer::write_chunk_uninit().

For a safe alternative that provides Default-initialized slots, see WriteChunk.

The slots can be accessed with as_mut_slices() or by iteration, which yields mutable references to possibly uninitialized data (in other words: &mut MaybeUninit<T>). A mutable reference (&mut) to the WriteChunkUninit 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, '_> WriteChunkUninit<'_, T>[src]

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

Returns two slices for writing to the requested slots.

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.

The extension trait CopyToUninit can be used to safely copy data into those slices.

pub unsafe 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.

Safety

The user must make sure that the first n elements (and not more, in case T implements Drop) have been initialized.

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

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

Safety

The user must make sure that all iterated elements have been initialized.

pub unsafe fn commit_all(self)[src]

Makes the whole chunk available for reading.

Safety

The user must make sure that all elements have been initialized.

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 WriteChunkUninit<'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 WriteChunkUninit<'a, T>[src]

type Item = &'a mut MaybeUninit<T>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for WriteChunkUninit<'a, T>[src]

impl<'a, T> !Send for WriteChunkUninit<'a, T>[src]

impl<'a, T> !Sync for WriteChunkUninit<'a, T>[src]

impl<'a, T> Unpin for WriteChunkUninit<'a, T>[src]

impl<'a, T> !UnwindSafe for WriteChunkUninit<'a, T>[src]

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.