[][src]Struct rustasim::spsc::Producer

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

The producer side of a bounded single-producer single-consumer queue.

Examples

use rustasim::{spsc, PushError};

let (p, c) = spsc::new::<i32>(1);

assert_eq!(p.push(10), Ok(()));
assert_eq!(p.push(20), Err(PushError(20)));

assert!(!p.is_empty());
assert!(p.is_full());

Implementations

impl<T> Producer<T>[src]

pub fn push(&self, value: T) -> Result<(), PushError<T>>[src]

Attempts to push an element into the queue.

If the queue is full, the element is returned back as an error.

Examples

use rustasim::{spsc, PushError};

let (p, c) = spsc::new(1);

assert_eq!(p.push(10), Ok(()));
assert_eq!(p.push(20), Err(PushError(20)));

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

Returns the capacity of the queue.

Examples

use rustasim::spsc;

let (p, c) = spsc::new::<i32>(100);

assert_eq!(p.capacity(), 100);

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

Returns true if the queue is empty.

Examples

use rustasim::spsc;

let (p, c) = spsc::new(100);

assert!(p.is_empty());
p.push(1).unwrap();
assert!(!p.is_empty());

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

Returns true if the queue is full.

Examples

use rustasim::spsc;

let (p, c) = spsc::new(1);

assert!(!p.is_full());
p.push(1).unwrap();
assert!(p.is_full());

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

Returns the number of elements in the queue.

Examples

use rustasim::spsc;

let (p, c) = spsc::new(100);
assert_eq!(p.len(), 0);

p.push(10).unwrap();
assert_eq!(p.len(), 1);

p.push(20).unwrap();
assert_eq!(p.len(), 2);

Trait Implementations

impl<T> Debug for Producer<T>[src]

impl<T: Send> Send for Producer<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Producer<T>

impl<T> !Sync for Producer<T>

impl<T> Unpin for Producer<T>

impl<T> UnwindSafe for Producer<T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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<V, T> VZip<V> for T where
    V: MultiLane<T>,