[][src]Struct ringbuf::Producer

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

Producer part of ring buffer.

Methods

impl<T: Sized> Producer<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 push(&mut self, elem: T) -> Result<(), (PushError, T)>
[src]

Pushes element into ring buffer.

On error returns pair of error and element that wasn't pushed.

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

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

Pushes elements from slice into ring buffer. Elements should be be cloneable.

On success returns count of elements been pushed into ring buffer.

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

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

Allows to write into ring buffer memory directry.

This function is unsafe beacuse it gives access to possibly uninitialized memory and transfers 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 written, and some arbitrary data.
  • On failure: some another arbitrary data.

On success returns data returned from f.

Trait Implementations

impl ReadFrom for Producer<u8>
[src]

impl Write for Producer<u8>
[src]

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
[src]

Attempts to write an entire buffer into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self
1.0.0
[src]

Creates a "by reference" adaptor for this instance of Write. Read more

Auto Trait Implementations

impl<T> Send for Producer<T> where
    T: Send

impl<T> Sync for Producer<T> where
    T: Send

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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