[−][src]Struct rustasim::spsc::Producer
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
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,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,