Trait audio::ExactSizeBuf

source ·
pub trait ExactSizeBuf: Buf {
    // Required method
    fn frames(&self) -> usize;
}
Expand description

Trait used to describe a buffer that knows exactly how many frames it has regardless of if it’s sized or not.

Examples

use audio::ExactSizeBuf;

fn test<T>(buf: T) where T: ExactSizeBuf {
    assert_eq!(buf.frames(), 4);
}

test(audio::interleaved![[0i16; 4]; 4]);
test(audio::sequential![[0i16; 4]; 4]);
test(audio::dynamic![[0i16; 4]; 4]);
test(audio::wrap::interleaved([0i16; 16], 4));
test(audio::wrap::sequential([0i16; 16], 4));

Required Methods§

source

fn frames(&self) -> usize

The number of frames in a buffer.

Examples
use audio::ExactSizeBuf;

fn test<T>(buf: T) where T: ExactSizeBuf {
    assert_eq!(buf.frames(), 4);
}

test(audio::interleaved![[0i16; 4]; 4]);
test(audio::sequential![[0i16; 4]; 4]);
test(audio::dynamic![[0i16; 4]; 4]);
test(audio::wrap::interleaved([0i16; 16], 4));
test(audio::wrap::sequential([0i16; 16], 4));

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<B> ExactSizeBuf for &B
where B: ExactSizeBuf + ?Sized,

source§

fn frames(&self) -> usize

source§

impl<B> ExactSizeBuf for &mut B
where B: ExactSizeBuf + ?Sized,

source§

fn frames(&self) -> usize

Implementors§

source§

impl<B> ExactSizeBuf for Limit<B>
where B: ExactSizeBuf,

Limit adjusts the implementation of ExactSizeBuf to take the frame limiting into account.

use audio::{Buf, ExactSizeBuf};

let buf = audio::interleaved![[0; 4]; 2];

assert_eq!((&buf).limit(0).frames(), 0);
assert_eq!((&buf).limit(1).frames(), 1);
assert_eq!((&buf).limit(5).frames(), 4);
source§

impl<B> ExactSizeBuf for Skip<B>
where B: ExactSizeBuf,

Skip adjusts the implementation of ExactSizeBuf.

use audio::{Buf, ExactSizeBuf};

let buf = audio::interleaved![[0; 4]; 2];

assert_eq!((&buf).skip(0).frames(), 4);
assert_eq!((&buf).skip(1).frames(), 3);
assert_eq!((&buf).skip(5).frames(), 0);
source§

impl<B> ExactSizeBuf for Tail<B>
where B: ExactSizeBuf,

Tail adjusts the implementation of ExactSizeBuf.

use audio::{Buf, ExactSizeBuf};

let buf = audio::interleaved![[0; 4]; 2];

assert_eq!((&buf).tail(0).frames(), 0);
assert_eq!((&buf).tail(1).frames(), 1);
assert_eq!((&buf).tail(5).frames(), 4);
source§

impl<B> ExactSizeBuf for Read<B>
where B: ExactSizeBuf,

source§

impl<B> ExactSizeBuf for ReadWrite<B>
where B: ExactSizeBuf,

source§

impl<B> ExactSizeBuf for Write<B>
where B: ExactSizeBuf,

source§

impl<T> ExactSizeBuf for Dynamic<T>
where T: Copy,

source§

impl<T> ExactSizeBuf for audio::buf::interleaved::Interleaved<T>
where T: Copy,

source§

impl<T> ExactSizeBuf for audio::buf::sequential::Sequential<T>
where T: Copy,

source§

impl<T> ExactSizeBuf for audio::wrap::Interleaved<T>
where T: Slice,

source§

impl<T> ExactSizeBuf for audio::wrap::Sequential<T>
where T: Slice,