1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! A frame buffer as created through
//! [UniformBuf::get_frame][crate::UniformBuf::get_frame].

use crate::frame::Frame;

/// The buffer of a single frame.
pub trait FrameMut: Frame {
    /// The type the frame assumes when coerced into a reference.
    type FrameMut<'this>: FrameMut<Sample = Self::Sample>
    where
        Self: 'this;

    /// A borrowing iterator over the channel.
    type IterMut<'this>: Iterator<Item = &'this mut Self::Sample>
    where
        Self: 'this;

    /// Reborrow the current frame as a reference.
    fn as_sample_mut(&self) -> Self::FrameMut<'_>;

    /// Get the sample mutable at the given channel in the frame.
    fn get_mut(&self, channel: usize) -> Option<&mut Self::Sample>;

    /// Construct a mutable iterator over the frame.
    fn iter_mut(&self) -> Self::IterMut<'_>;
}