[][src]Struct rtrb::ReadChunk

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

Structure for reading from multiple slots in one go.

This is returned from Consumer::read_chunk().

The slots can be accessed with as_slices() or by iteration. Even though iterating yields immutable references (&T), a mutable reference (&mut) to the ReadChunk should be used to iterate over it. Each slot can only be iterated once and the number of iterations is tracked.

After reading, the provided slots are not automatically made available to be written again by the Producer. If desired, this has to be explicitly done by calling commit(), commit_iterated() or commit_all(). Note that this runs the destructor of the committed items (if T implements Drop).

Implementations

impl<T, '_> ReadChunk<'_, T>[src]

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

Returns two slices for reading from 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.

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

Drops the first n slots of the chunk, making the space available for writing again.

Panics

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

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

Drops all slots that have been iterated, making the space available for writing again.

Returns the number of iterated slots.

pub fn commit_all(self)[src]

Drops all slots of the chunk, making the space available for writing again.

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

impl<'a, T: Eq> Eq for ReadChunk<'a, T>[src]

impl<'a, T> Iterator for ReadChunk<'a, T>[src]

type Item = &'a T

The type of the elements being iterated over.

impl<'a, T: PartialEq> PartialEq<ReadChunk<'a, T>> for ReadChunk<'a, T>[src]

impl<'a, T> StructuralEq for ReadChunk<'a, T>[src]

impl<'a, T> StructuralPartialEq for ReadChunk<'a, T>[src]

Auto Trait Implementations

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

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

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

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

impl<'a, T> !UnwindSafe for ReadChunk<'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.