ConsIter

Struct ConsIter 

Source
pub struct ConsIter<'buf, B: MutRB, const W: bool> { /* private fields */ }
Expand description

Iterator used to pop data from the buffer.

When working with types which implement both Copy and Clone traits, copy methods should be preferred over clone methods.

Implementations§

Source§

impl<'buf, B: MutRB<Item = T>, T, const W: bool> ConsIter<'buf, B, W>

Source

pub fn reset_index(&mut self)

Resets the index of the iterator. I.e., moves the iterator to the location occupied by its successor.

Source

pub fn peek_ref<'a>(&mut self) -> Option<&'a T>

Returns a reference to an element.

Being this a reference, Self::advance() has to be called when done with the data in order to move the iterator.

Source

pub fn peek_slice<'a>(&mut self, count: usize) -> Option<NonMutableSlice<'a, T>>

Returns a tuple of slice references, the sum of which with len equal to count.

Being these references, Self::advance() has to be called when done with the data in order to move the iterator.

Source

pub fn peek_available<'a>(&mut self) -> Option<NonMutableSlice<'a, T>>

Returns a tuple of slice references, the sum of which with len equal to available data.

Being these references, Self::advance() has to be called when done with the data in order to move the iterator.

Source

pub unsafe fn pop_move(&mut self) -> Option<T>

Tries to pop an element, moving it.

§Safety

This method moves items, so locations from which they are moved out are left uninitialised. These locations must be re-initialised used proper ProdIter methods (*_init) ones

Source

pub fn pop(&mut self) -> Option<T>

Tries to pop an element, duplicating it.

§Safety

This method acts like ptr::read: it duplicates the item by making a bitwise copy, ignoring whether it is Copy/Clone or not. So it is your responsibility to ensure that the data may indeed be duplicated.

Source

pub fn copy_item(&mut self, dst: &mut T) -> Option<()>
where T: Copy,

  • Returns Some(()), copying next item into dst, if available.
  • Returns None doing nothing, otherwise.

This method uses copy and should be preferred over clone version, if possible.

Unlike peek* methods, this one automatically advances the iterator.

Source

pub fn clone_item(&mut self, dst: &mut T) -> Option<()>
where T: Clone,

Same as Self::copy_item, but uses clone, instead.

Unlike peek* methods, this one automatically advances the iterator.

Source

pub fn copy_slice(&mut self, dst: &mut [T]) -> Option<()>
where T: Copy,

  • Returns Some(()), filling dst slice with the next dst.len() values, if available.
  • Returns None doing nothing, otherwise.

This method fills the slice using copy and should be preferred over clone version, if possible.

Unlike peek* methods, this one automatically advances the iterator.

Source

pub fn clone_slice(&mut self, dst: &mut [T]) -> Option<()>
where T: Clone,

Same as Self::copy_slice, but uses clone, instead.

Unlike peek* methods, this one automatically advances the iterator.

Trait Implementations§

Source§

impl<B: MutRB + IterManager, const W: bool> Drop for ConsIter<'_, B, W>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<B: MutRB<Item = T>, T, const W: bool> MRBIterator for ConsIter<'_, B, W>

Source§

type Item = T

Source§

fn detach(self) -> Detached<Self>
where Self: Sized,

Detaches the iterator yielding a Detached.
Source§

unsafe fn advance(&mut self, count: usize)

Advances the iterator by count. Read more
Source§

fn available(&mut self) -> usize

Returns the number of items available for an iterator.
Source§

fn wait_for(&mut self, count: usize)

Waits, blocking the thread in a loop, until there are at least count available items.
Source§

fn index(&self) -> usize

Returns the index of the iterator.
Source§

fn buf_len(&self) -> usize

Returns the length of the buffer.
Source§

fn alive_iters(&self) -> u8

Returns how many iterators are still alive.
Source§

fn prod_index(&self) -> usize

Returns the index of the producer.
Source§

fn work_index(&self) -> usize

Returns the index of the worker.
Source§

fn cons_index(&self) -> usize

Returns the index of the consumer.
Source§

fn get_workable<'a>(&mut self) -> Option<&'a mut Self::Item>

Returns a mutable references to the current value. Read more
Source§

fn get_workable_slice_exact<'a>( &mut self, count: usize, ) -> Option<MutableSlice<'a, <Self as MRBIterator>::Item>>

Returns a tuple of mutable slice references, the sum of which with len equal to count. Read more
Source§

fn get_workable_slice_avail<'a>( &mut self, ) -> Option<MutableSlice<'a, <Self as MRBIterator>::Item>>

Returns a tuple of mutable slice references, the sum of which with len equal to Self::available(). Read more
Source§

fn get_workable_slice_multiple_of<'a>( &mut self, rhs: usize, ) -> Option<MutableSlice<'a, <Self as MRBIterator>::Item>>

Returns a tuple of mutable slice references, the sum of which with len equal to the higher multiple of rhs. Read more
Source§

impl<B: ConcurrentRB + MutRB<Item = T>, T, const W: bool> Send for ConsIter<'_, B, W>

Auto Trait Implementations§

§

impl<'buf, B, const W: bool> Freeze for ConsIter<'buf, B, W>

§

impl<'buf, B, const W: bool> RefUnwindSafe for ConsIter<'buf, B, W>
where B: RefUnwindSafe,

§

impl<'buf, B, const W: bool> !Sync for ConsIter<'buf, B, W>

§

impl<'buf, B, const W: bool> Unpin for ConsIter<'buf, B, W>

§

impl<'buf, B, const W: bool> UnwindSafe for ConsIter<'buf, B, W>
where B: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.