Skip to main content

Buffer

Trait Buffer 

Source
pub trait Buffer<T: Scalar> {
    // Required methods
    fn capacity(&self) -> usize;
    fn len(&self) -> usize;
    fn as_slice(&self) -> &[T];
    fn as_mut_slice(&mut self) -> &mut [T];
    fn fill(&mut self, value: T);
    fn copy_from(&mut self, src: &[T]);
    fn clear(&mut self);

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn is_full(&self) -> bool { ... }
    fn stats(&self) -> BufferStats { ... }
    fn reset_stats(&mut self) { ... }
}
Expand description

Common interface for all buffer types used in the signal graph.

Required Methods§

Source

fn capacity(&self) -> usize

Maximum number of elements the buffer can hold.

Source

fn len(&self) -> usize

Current number of elements in the buffer.

Source

fn as_slice(&self) -> &[T]

Read-only access to the buffer data.

Source

fn as_mut_slice(&mut self) -> &mut [T]

Mutable access to the buffer data.

Source

fn fill(&mut self, value: T)

Fill the entire buffer with a value.

Source

fn copy_from(&mut self, src: &[T])

Copy data from a slice. Copies min(src.len(), self.len()) samples.

Source

fn clear(&mut self)

Remove all items from the buffer.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether the buffer is empty (len() == 0).

Source

fn is_full(&self) -> bool

Whether the buffer is full (len() == capacity()).

Source

fn stats(&self) -> BufferStats

Snapshot of performance statistics.

Source

fn reset_stats(&mut self)

Reset performance counters (not the data).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Scalar> Buffer<T> for HeapBuffer<T>

Source§

impl<T: Scalar, const SIZE: usize> Buffer<T> for FixedBuffer<T, SIZE>

Source§

impl<T: Transcendental> Buffer<T> for TapeLoop<T>

Source§

impl<T: Transcendental, const MAX_DELAY: usize> Buffer<T> for DelayLine<T, MAX_DELAY>

Source§

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

Source§

impl<T: Transcendental, const N: usize> Buffer<T> for RingBuffer<T, N>

Source§

impl<T: Transcendental, const N: usize, const CONSUMERS: usize> Buffer<T> for FanOutBuffer<T, N, CONSUMERS>

Source§

impl<T: Transcendental, const N: usize, const PRODUCERS: usize> Buffer<T> for FanInBuffer<T, N, PRODUCERS>