use crate::Channel;
#[macro_use]
mod macros;
mod skip;
pub use self::skip::Skip;
mod limit;
pub use self::limit::Limit;
mod tail;
pub use self::tail::Tail;
pub trait Buf {
type Sample;
type Channel<'this>: Channel<Sample = Self::Sample>
where
Self: 'this;
type IterChannels<'this>: Iterator<Item = Self::Channel<'this>>
where
Self: 'this;
fn frames_hint(&self) -> Option<usize>;
fn channels(&self) -> usize;
fn get_channel(&self, channel: usize) -> Option<Self::Channel<'_>>;
fn iter_channels(&self) -> Self::IterChannels<'_>;
fn skip(self, n: usize) -> Skip<Self>
where
Self: Sized,
{
Skip::new(self, n)
}
fn tail(self, n: usize) -> Tail<Self>
where
Self: Sized,
{
Tail::new(self, n)
}
fn limit(self, limit: usize) -> Limit<Self>
where
Self: Sized,
{
Limit::new(self, limit)
}
}
impl<B> Buf for &B
where
B: ?Sized + Buf,
{
type Sample = B::Sample;
type Channel<'a>
= B::Channel<'a>
where
Self: 'a;
type IterChannels<'a>
= B::IterChannels<'a>
where
Self: 'a;
#[inline]
fn frames_hint(&self) -> Option<usize> {
(**self).frames_hint()
}
#[inline]
fn channels(&self) -> usize {
(**self).channels()
}
#[inline]
fn get_channel(&self, channel: usize) -> Option<Self::Channel<'_>> {
(**self).get_channel(channel)
}
#[inline]
fn iter_channels(&self) -> Self::IterChannels<'_> {
(**self).iter_channels()
}
}
impl<B> Buf for &mut B
where
B: ?Sized + Buf,
{
type Sample = B::Sample;
type Channel<'this>
= B::Channel<'this>
where
Self: 'this;
type IterChannels<'this>
= B::IterChannels<'this>
where
Self: 'this;
#[inline]
fn frames_hint(&self) -> Option<usize> {
(**self).frames_hint()
}
#[inline]
fn channels(&self) -> usize {
(**self).channels()
}
#[inline]
fn get_channel(&self, channel: usize) -> Option<Self::Channel<'_>> {
(**self).get_channel(channel)
}
#[inline]
fn iter_channels(&self) -> Self::IterChannels<'_> {
(**self).iter_channels()
}
}