pub struct RingBuffer<'m> {
pub dropped_frames: u64,
pub high_water_frames: usize,
/* private fields */
}Expand description
A whole-frame byte ring over borrowed memory.
Fields§
§dropped_frames: u64Frames refused or overwritten because the ring was full.
high_water_frames: usizeMost frames ever stored at once.
Implementations§
Source§impl<'m> RingBuffer<'m>
impl<'m> RingBuffer<'m>
Sourcepub fn new(buf: &'m mut [u8], format: PcmFormat) -> Result<Self>
pub fn new(buf: &'m mut [u8], format: PcmFormat) -> Result<Self>
A ring over buf for frames of format. buf must hold at least one
frame; a trailing partial frame is unused.
Sourcepub fn capacity_frames(&self) -> usize
pub fn capacity_frames(&self) -> usize
Frames the ring can hold.
Sourcepub fn available_frames(&self) -> usize
pub fn available_frames(&self) -> usize
Frames stored right now.
Sourcepub fn free_frames(&self) -> usize
pub fn free_frames(&self) -> usize
Frames that can still be pushed without dropping.
Sourcepub fn push(&mut self, data: &[u8]) -> Result<()>
pub fn push(&mut self, data: &[u8]) -> Result<()>
Append whole frames. When they do not all fit, nothing is stored, the
frames count as dropped and Err(Busy) comes back — the producer
keeps running and the drop is on the record.
Sourcepub fn push_overwrite(&mut self, data: &[u8]) -> Result<usize>
pub fn push_overwrite(&mut self, data: &[u8]) -> Result<usize>
Append whole frames, discarding the oldest stored frames to make room.
Returns how many frames were discarded (also added to
dropped_frames). Use it when latency matters more than continuity.
Trait Implementations§
Auto Trait Implementations§
impl<'m> !UnwindSafe for RingBuffer<'m>
impl<'m> Freeze for RingBuffer<'m>
impl<'m> RefUnwindSafe for RingBuffer<'m>
impl<'m> Send for RingBuffer<'m>
impl<'m> Sync for RingBuffer<'m>
impl<'m> Unpin for RingBuffer<'m>
impl<'m> UnsafeUnpin for RingBuffer<'m>
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