pub struct Consumer<T> { /* private fields */ }
Expand description
Consumer view into the ring buffer.
Trait Implementations
sourceimpl<T: Clone + Copy> RbConsumer<T> for Consumer<T>
impl<T: Clone + Copy> RbConsumer<T> for Consumer<T>
sourcefn skip_pending(&self) -> Result<usize>
fn skip_pending(&self) -> Result<usize>
Skips all pending values. Technically it sets the consumer’s read pointer to the position of the producer’s write pointer. Read more
sourcefn get(&self, data: &mut [T]) -> Result<usize>
fn get(&self, data: &mut [T]) -> Result<usize>
Fills the given slice with values or, if the buffer is empty, does not modify it.
This method does not change the state of the buffer, this means that the read pointer
isn’t changed if you call get
. Consecutive calls to this method are idempotent, i.e. they
will fill the given slice with the same data.
Using get
can be beneficial to read
when a successive call has failed and you want to
try again with same data. You can use skip
to move the read pointer i.e. mark the values
as read after the call succeeded. Read more
sourcefn read(&self, data: &mut [T]) -> Result<usize>
fn read(&self, data: &mut [T]) -> Result<usize>
Fills the given slice with values or, if the buffer is empty, does not modify it. Returns the number of written values or an error. Read more
sourcefn read_blocking(&self, data: &mut [T]) -> Option<usize>
fn read_blocking(&self, data: &mut [T]) -> Option<usize>
Works analog to read
but blocks until it can read elements to fill
the given buffer slice.
The number of blocks read is not necessarily equal to the length of the given buffer slice,
the exact number is returned in the Option
value. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Consumer<T>
impl<T> Send for Consumer<T> where
T: Send,
impl<T> Sync for Consumer<T> where
T: Send,
impl<T> Unpin for Consumer<T>
impl<T> UnwindSafe for Consumer<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more