Struct mutringbuf::iterators::sync_iterators::cons_iter::ConsIter

source ·
pub struct ConsIter<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<B: MutRB<Item = T>, T, const W: bool> ConsIter<B, W>

source

pub fn is_prod_alive(&self) -> bool

Returns true if the producer iterator is still alive, false if it has been dropped.

source

pub fn is_work_alive(&self) -> bool

Returns true if the worker iterator is still alive, false if it has been dropped.

Note: when the buffer is used in non-mutable mode this will always return false.

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<(&'a [T], &'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<(&'a [T], &'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(&mut self) -> Option<T>

Tries to pop an element, moving it.

§Safety

This items 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 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<T> for ConsIter<B, W>

source§

fn available(&mut self) -> usize

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

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

Advances the iterator by count. Read more
source§

fn index(&self) -> usize

Returns the index of the iterator.
source§

fn buf_len(&self) -> usize

Returns the length of the buffer.
source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<B, const W: bool> UnwindSafe for ConsIter<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>,

§

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>,

§

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.