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§
sourcefn frames(&self) -> usize
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 &Bwhere
B: ExactSizeBuf + ?Sized,
impl<B> ExactSizeBuf for &Bwhere
B: ExactSizeBuf + ?Sized,
source§impl<B> ExactSizeBuf for &mut Bwhere
B: ExactSizeBuf + ?Sized,
impl<B> ExactSizeBuf for &mut Bwhere
B: ExactSizeBuf + ?Sized,
Implementors§
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);
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);
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);