pub struct LinearChannelMut<'a, T> { /* private fields */ }
Expand description

Read-write access to a single channel of audio within a linear, multichannel audio buffer. This struct does not own the audio data; it provides an API for accessing data owned by something else.

See also crate::buf::Sequential.

Implementations§

source§

impl<'a, T> LinearChannelMut<'a, T>

source

pub fn new(buf: &'a mut [T]) -> Self

Construct a linear channel buffer.

The buffer provided as-is constitutes the frames of the channel.

Examples
use audio::channel::LinearChannelMut;

let buf: &mut [u32] = &mut [1, 3, 5, 7];
let channel = LinearChannelMut::new(buf);

assert_eq!(channel.iter().nth(1), Some(3));
assert_eq!(channel.iter().nth(2), Some(5));
source

pub fn get(&self, n: usize) -> Option<T>
where T: Copy,

Get the given frame.

source

pub fn iter(&self) -> Iter<'_, T>

Construct an iterator over the linear channel.

source

pub fn get_mut(&mut self, n: usize) -> Option<&mut T>

Get a mutable reference to the given frame.

source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Construct an immutable iterator over the linear channel.

source

pub fn into_ref(self) -> &'a [T]

Convert the channel into the underlying buffer.

source

pub fn into_mut(self) -> &'a mut [T]

Convert the channel into the underlying mutable buffer.

Trait Implementations§

source§

impl<T> AsMut<[T]> for LinearChannelMut<'_, T>

source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<'a, T> Channel for LinearChannelMut<'a, T>
where T: Copy,

§

type Sample = T

The sample of a channel.
§

type Channel<'this> = LinearChannel<'this, <LinearChannelMut<'a, T> as Channel>::Sample> where Self: 'this

The type the channel assumes when coerced into a reference.
§

type Iter<'this> = Iter<'this, <LinearChannelMut<'a, T> as Channel>::Sample> where Self: 'this

A borrowing iterator over the channel.
source§

fn as_channel(&self) -> Self::Channel<'_>

Reborrow the current channel as a reference.
source§

fn len(&self) -> usize

Get the length which indicates number of frames in the current channel. Read more
source§

fn get(&self, n: usize) -> Option<Self::Sample>

Get the frame at the given offset in the channel. Read more
source§

fn iter(&self) -> Self::Iter<'_>

Construct an iterator over the channel. Read more
source§

fn skip(self, n: usize) -> Self

Construct a channel buffer where the first n frames are skipped. Read more
source§

fn tail(self, n: usize) -> Self

Construct a channel buffer where the last n frames are included. Read more
source§

fn limit(self, limit: usize) -> Self

Limit the channel bufferto limit number of frames. Read more
source§

fn try_as_linear(&self) -> Option<&[T]>

Try to access the current channel as a linear buffer. Read more
source§

fn is_empty(&self) -> bool

Test if the current channel is empty. Read more
source§

impl<'a, T> ChannelMut for LinearChannelMut<'a, T>
where T: Copy,

§

type ChannelMut<'this> = LinearChannelMut<'this, T> where Self: 'this

A reborrowed mutable channel.
§

type IterMut<'this> = IterMut<'this, T> where Self: 'this

A mutable iterator over a channel.
source§

fn as_channel_mut(&mut self) -> Self::ChannelMut<'_>

Reborrow the channel mutably.
source§

fn get_mut(&mut self, n: usize) -> Option<&mut Self::Sample>

Get the frame at the given offset in the channel. Read more
source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

Construct a mutable iterator over the channel
source§

fn try_as_linear_mut(&mut self) -> Option<&mut [Self::Sample]>

Try to access the current channel as a mutable linear buffer. Read more
source§

fn fill(&mut self, value: Self::Sample)

Replace all samples in the channel with the specified value Read more
source§

impl<T> Debug for LinearChannelMut<'_, T>
where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T: Hash> Hash for LinearChannelMut<'a, T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, I> Index<I> for LinearChannelMut<'_, T>
where I: SliceIndex<[T]>,

§

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.
source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T, I> IndexMut<I> for LinearChannelMut<'_, T>
where I: SliceIndex<[T]>,

source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> LinearChannel for LinearChannelMut<'_, T>
where T: Copy,

source§

fn as_linear_channel(&self) -> &[Self::Sample]

Access the linear channel.
source§

impl<T> LinearChannelMut for LinearChannelMut<'_, T>
where T: Copy,

source§

fn as_linear_channel_mut(&mut self) -> &mut [Self::Sample]

Access the linear channel mutably.
source§

impl<'a, T: Ord> Ord for LinearChannelMut<'a, T>

source§

fn cmp(&self, other: &LinearChannelMut<'a, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a, T> PartialEq<&[T]> for LinearChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &&[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<[T]> for LinearChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T, const N: usize> PartialEq<[T; N]> for LinearChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &[T; N]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialEq<Vec<T>> for LinearChannelMut<'a, T>
where T: Copy + PartialEq,

source§

fn eq(&self, b: &Vec<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T: PartialEq> PartialEq for LinearChannelMut<'a, T>

source§

fn eq(&self, other: &LinearChannelMut<'a, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialOrd<&[T]> for LinearChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &&[T]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<[T]> for LinearChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &[T]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T, const N: usize> PartialOrd<[T; N]> for LinearChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &[T; N]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> PartialOrd<Vec<T>> for LinearChannelMut<'a, T>
where T: Copy + PartialOrd,

source§

fn partial_cmp(&self, b: &Vec<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T: PartialOrd> PartialOrd for LinearChannelMut<'a, T>

source§

fn partial_cmp(&self, other: &LinearChannelMut<'a, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T: Eq> Eq for LinearChannelMut<'a, T>

source§

impl<'a, T> StructuralEq for LinearChannelMut<'a, T>

source§

impl<'a, T> StructuralPartialEq for LinearChannelMut<'a, T>

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for LinearChannelMut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for LinearChannelMut<'a, T>
where T: Send,

§

impl<'a, T> Sync for LinearChannelMut<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for LinearChannelMut<'a, T>

§

impl<'a, T> !UnwindSafe for LinearChannelMut<'a, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.