audio_core/frame.rs
1//! A frame buffer as created through
2//! [UniformBuf::get_frame][crate::UniformBuf::get_frame].
3
4/// The buffer of a single frame.
5pub trait Frame {
6 /// The sample of a channel.
7 type Sample: Copy;
8
9 /// The type the frame assumes when coerced into a reference.
10 type Frame<'this>: Frame<Sample = Self::Sample>
11 where
12 Self: 'this;
13
14 /// A borrowing iterator over the channel.
15 type Iter<'this>: Iterator<Item = Self::Sample>
16 where
17 Self: 'this;
18
19 /// Reborrow the current frame as a reference.
20 fn as_frame(&self) -> Self::Frame<'_>;
21
22 /// Get the length which indicates number of samples in the current frame.
23 fn len(&self) -> usize;
24
25 /// Test if the current frame is empty.
26 fn is_empty(&self) -> bool {
27 self.len() == 0
28 }
29
30 /// Get the sample at the given channel in the frame.
31 fn get(&self, channel: usize) -> Option<Self::Sample>;
32
33 /// Construct an iterator over the frame.
34 fn iter(&self) -> Self::Iter<'_>;
35}