pub struct Consumer { /* private fields */ }Expand description
The consumer half of the ring buffer. Not Clone — enforces single-consumer.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn pop_slice(&self, buf: &mut [f32]) -> usize
pub fn pop_slice(&self, buf: &mut [f32]) -> usize
Pop up to buf.len() samples into buf. Returns the number of samples read.
§Examples
let (p, c) = rt_ring::new(4);
p.push_slice(&[10.0, 20.0, 30.0]);
let mut buf = [0.0f32; 4];
let n = c.pop_slice(&mut buf);
assert_eq!(n, 3);
assert_eq!(&buf[..n], &[10.0, 20.0, 30.0]);Sourcepub fn available(&self) -> usize
pub fn available(&self) -> usize
Returns the number of samples currently available for reading.
§Examples
let (p, c) = rt_ring::new(4);
assert_eq!(c.available(), 0);
p.push(1.0);
assert_eq!(c.available(), 1);Sourcepub fn overwrite_count(&self) -> u64
pub fn overwrite_count(&self) -> u64
Returns the total number of samples that were overwritten since creation.
§Examples
let (p, c) = rt_ring::new(4);
for i in 0..10 {
p.push(i as f32);
}
assert_eq!(c.overwrite_count(), 6);Auto Trait Implementations§
impl Freeze for Consumer
impl RefUnwindSafe for Consumer
impl Send for Consumer
impl Sync for Consumer
impl Unpin for Consumer
impl UnsafeUnpin for Consumer
impl UnwindSafe for Consumer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more