pub struct StreamRingBuffer { /* private fields */ }Expand description
Lock-free ring buffer for streaming
Uses atomic operations for single-producer single-consumer (SPSC) pattern. The buffer is power-of-two sized for efficient modulo operations.
Implementations§
Source§impl StreamRingBuffer
impl StreamRingBuffer
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new ring buffer with the given capacity. Capacity will be rounded up to the next power of 2.
Sourcepub fn available_space(&self) -> usize
pub fn available_space(&self) -> usize
Get available space for writing
Sourcepub fn backpressure(&self) -> &Backpressure
pub fn backpressure(&self) -> &Backpressure
Get the backpressure signal
Sourcepub fn push(&self, data: &[u8]) -> Result<(), DCPError>
pub fn push(&self, data: &[u8]) -> Result<(), DCPError>
Push data into the buffer. Returns Err(Backpressure) if there’s not enough space.
Sourcepub fn pop(&self, buf: &mut [u8]) -> usize
pub fn pop(&self, buf: &mut [u8]) -> usize
Pop data from the buffer into the provided slice. Returns the number of bytes read.
Auto Trait Implementations§
impl !Freeze for StreamRingBuffer
impl RefUnwindSafe for StreamRingBuffer
impl Send for StreamRingBuffer
impl Sync for StreamRingBuffer
impl Unpin for StreamRingBuffer
impl UnsafeUnpin for StreamRingBuffer
impl UnwindSafe for StreamRingBuffer
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