pub struct MemoryPcmSink { /* private fields */ }Expand description
In-memory PcmSink that records every written buffer and flush.
This is the deterministic test backend for the sink side of the PCM fabric:
written buffers accumulate in order and can be inspected through
buffers or taken with
into_buffers, while flushes are counted.
§Examples
use sim_lib_stream_audio::{MemoryPcmSink, PcmBuffer, PcmSink, PcmSpec};
let spec = PcmSpec::i16(1, 48_000)?;
let mut sink = MemoryPcmSink::new(spec);
sink.write_buffer(PcmBuffer::i16(spec, 1, vec![7])?)?;
sink.flush()?;
assert_eq!(sink.buffers().len(), 1);
assert_eq!(sink.flush_count(), 1);Implementations§
Source§impl MemoryPcmSink
impl MemoryPcmSink
Sourcepub fn flush_count(&self) -> usize
pub fn flush_count(&self) -> usize
Returns how many times flush has been called.
Sourcepub fn into_buffers(self) -> Vec<PcmBuffer>
pub fn into_buffers(self) -> Vec<PcmBuffer>
Consumes the sink and returns the recorded buffers.
Trait Implementations§
Source§impl Clone for MemoryPcmSink
impl Clone for MemoryPcmSink
Source§fn clone(&self) -> MemoryPcmSink
fn clone(&self) -> MemoryPcmSink
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryPcmSink
impl Debug for MemoryPcmSink
Source§impl PcmSink for MemoryPcmSink
impl PcmSink for MemoryPcmSink
Auto Trait Implementations§
impl Freeze for MemoryPcmSink
impl RefUnwindSafe for MemoryPcmSink
impl Send for MemoryPcmSink
impl Sync for MemoryPcmSink
impl Unpin for MemoryPcmSink
impl UnsafeUnpin for MemoryPcmSink
impl UnwindSafe for MemoryPcmSink
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