Skip to main content

StreamRingBuffer

Struct StreamRingBuffer 

Source
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

Source

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.

Source

pub fn capacity(&self) -> usize

Get the capacity of the buffer

Source

pub fn len(&self) -> usize

Get the number of bytes available to read

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty

Source

pub fn available_space(&self) -> usize

Get available space for writing

Source

pub fn backpressure(&self) -> &Backpressure

Get the backpressure signal

Source

pub fn push(&self, data: &[u8]) -> Result<(), DCPError>

Push data into the buffer. Returns Err(Backpressure) if there’s not enough space.

Source

pub fn pop(&self, buf: &mut [u8]) -> usize

Pop data from the buffer into the provided slice. Returns the number of bytes read.

Source

pub fn peek(&self, buf: &mut [u8]) -> usize

Peek at data without consuming it. Returns the number of bytes peeked.

Source

pub fn clear(&self)

Clear the buffer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V