[][src]Struct ringbuf::Consumer

pub struct Consumer<T> { /* fields omitted */ }

Consumer part of ring buffer.

Methods

impl<T: Sized> Consumer<T>[src]

pub fn capacity(&self) -> usize[src]

Returns capacity of the ring buffer.

pub fn is_empty(&self) -> bool[src]

Checks if the ring buffer is empty.

pub fn is_full(&self) -> bool[src]

Checks if the ring buffer is full.

pub fn len(&self) -> usize[src]

The length of the data in the buffer

pub fn remaining(&self) -> usize[src]

The remaining space in the buffer.

pub fn pop(&mut self) -> Result<T, PopError>[src]

Removes first element from the ring buffer and returns it.

pub fn for_each_mut<F>(&mut self, f: F) where
    F: FnMut(&mut T), 
[src]

Iterate mutably over the elements contained by this buffer.

pub fn for_each<F>(&mut self, f: F) where
    F: FnMut(&T), 
[src]

Iterate immutably over the elements contained by this buffer.

impl<T: Sized + Copy> Consumer<T>[src]

pub fn pop_slice(&mut self, elems: &mut [T]) -> Result<usize, PopSliceError>[src]

Removes first elements from the ring buffer and writes them into a slice. Elements should be Copy.

On success returns count of elements been removed from the ring buffer.

pub fn move_slice(
    &mut self,
    other: &mut Producer<T>,
    count: Option<usize>
) -> Result<usize, MoveSliceError>
[src]

Removes at most count elements from the Consumer of the ring buffer and appends them to the Producer of the another one. If count is None then as much as possible elements will be moved.

Elements should be Copy.

On success returns count of elements been moved.

impl Consumer<u8>[src]

pub fn write_into(
    &mut self,
    writer: &mut dyn Write,
    count: Option<usize>
) -> Result<usize, WriteIntoError>
[src]

Removes at most first count bytes from the ring buffer and writes them into a Write instance. If count is None then as much as possible bytes will be written.

impl<T: Sized> Consumer<T>[src]

pub fn access<F: FnOnce(&[T], &[T])>(&self, f: F) -> Result<(), AccessError>[src]

Gives immutable access to the elements contained by the ring buffer without removing them.

The method takes a function f as argument. f takes two slices of ring buffer content (the second one them may be empty). First slice contains older elements.

The slices may not include elements pushed to the buffer by concurring producer after the method call.

pub fn access_mut<F: FnOnce(&mut [T], &mut [T])>(
    &mut self,
    f: F
) -> Result<(), AccessError>
[src]

Gives mutable access to the elements contained by the ring buffer without removing them.

The method takes a function f as argument. f takes two slices of ring buffer content (the second one may be empty). First slice contains older elements.

The iteration may not include elements pushed to the buffer by concurring producer after the method call.

pub unsafe fn pop_access<R, E, F>(
    &mut self,
    f: F
) -> Result<Result<(usize, R), E>, PopAccessError> where
    R: Sized,
    E: Sized,
    F: FnOnce(&mut [T], &mut [T]) -> Result<(usize, R), E>, 
[src]

Allows to read from ring buffer memory directry.

This function is unsafe beacuse it gives access to possibly uninitialized memory and transfers to the user the responsibility of manually calling destructors

Takes a function f as argument. f takes two slices of ring buffer content (the second one may be empty). First slice contains older elements.

f should return: + On success: pair of number of elements been read, and some arbitrary data. + On failure: some another arbitrary data.

On success returns data returned from f.

Trait Implementations

impl Read for Consumer<u8>[src]

Auto Trait Implementations

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>

impl<T> !RefUnwindSafe for Consumer<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]