Skip to main content

PipeBuffer

Struct PipeBuffer 

Source
pub struct PipeBuffer<T, const N: usize>
where T: Transcendental,
{ /* private fields */ }
Expand description

Single-producer, single-consumer buffer for node connections

This buffer provides wait-free operations and minimal overhead. It is ideal for point-to-point connections between audio nodes.

§Type Parameters

  • T: Audio sample type (f32 or f64) implementing Transcendental
  • N: Buffer size (number of samples per block)

Implementations§

Source§

impl<T, const N: usize> PipeBuffer<T, N>
where T: Transcendental,

Source

pub fn new() -> PipeBuffer<T, N>

Create a new pipe buffer

The buffer starts empty with no data available.

Source

pub fn write(&self, data: &[T; N])

Write a block of data to the buffer

This operation is wait-free and will overwrite any existing data. The buffer holds at most one block at a time - new writes always overwrite the previous block, regardless of whether it was read.

§Arguments
  • data - Array of samples to write (must be exactly N samples)
Source

pub fn read(&self) -> Option<[T; N]>

Read a block without consuming (multiple consumers can read the same data)

Unlike try_read, this does not mark the buffer as empty. Multiple callers can read the same data before the next write.

Source

pub fn try_read(&self) -> Option<[T; N]>

Try to read a block of data from the buffer

Returns Some(data) if data is available, None otherwise. This operation is wait-free and non-blocking. This call consumes the data — subsequent readers will get None until the next write.

Source

pub fn read_blocking(&self) -> [T; N]

Read data, blocking until available (for non-real-time use)

This is a convenience method for non-real-time contexts like testing or offline processing. It spins until data is available.

Source

pub fn has_data(&self) -> bool

Check if buffer has valid data available

Source

pub fn write_seq(&self) -> usize

Get write sequence number (for debugging)

Source

pub fn read_seq(&self) -> usize

Get read sequence number (for debugging)

Source

pub fn is_caught_up(&self) -> bool

Check if reader is caught up with writer

Source

pub fn overwrites(&self) -> usize

Get the number of overwritten blocks (for debugging)

Source

pub fn reset(&self)

Reset the buffer to empty state

Clears the valid flag and resets statistics. Does not actually zero the memory (not needed for correctness).

Trait Implementations§

Source§

impl<T, const N: usize> Clone for PipeBuffer<T, N>
where T: Transcendental + Copy,

Source§

fn clone(&self) -> PipeBuffer<T, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, const N: usize> Debug for PipeBuffer<T, N>
where T: Transcendental + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T, const N: usize> Default for PipeBuffer<T, N>
where T: Transcendental,

Source§

fn default() -> PipeBuffer<T, N>

Returns the “default value” for a type. Read more
Source§

impl<T, const N: usize> SignalBuffer<T> for PipeBuffer<T, N>
where T: Transcendental,

Source§

fn capacity(&self) -> usize

Get the total capacity of the buffer in samples Read more
Source§

fn len(&self) -> usize

Get the current number of items in the buffer Read more
Source§

fn is_empty(&self) -> bool

Check if the buffer is empty
Source§

fn is_full(&self) -> bool

Check if the buffer is full
Source§

fn clear(&mut self)

Clear all items from the buffer Read more
Source§

fn stats(&self) -> BufferStats

Get a snapshot of current buffer statistics
Source§

fn reset_stats(&mut self)

Reset all statistics to zero Read more

Auto Trait Implementations§

§

impl<T, const N: usize> !Freeze for PipeBuffer<T, N>

§

impl<T, const N: usize> !RefUnwindSafe for PipeBuffer<T, N>

§

impl<T, const N: usize> Send for PipeBuffer<T, N>

§

impl<T, const N: usize> Sync for PipeBuffer<T, N>

§

impl<T, const N: usize> Unpin for PipeBuffer<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for PipeBuffer<T, N>
where T: UnsafeUnpin,

§

impl<T, const N: usize> UnwindSafe for PipeBuffer<T, N>
where T: UnwindSafe,

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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