pub trait AdapterMut<'a, T>: Adapter<'a, T>where
T: Clone + 'a,{
// Required method
unsafe fn write_sample_unchecked(
&mut self,
channel: usize,
frame: usize,
value: &T,
) -> bool;
// Provided methods
fn write_sample(
&mut self,
channel: usize,
frame: usize,
value: &T,
) -> Option<bool> { ... }
fn write_from_slice_to_channel(
&mut self,
channel: usize,
skip: usize,
slice: &[T],
) -> (usize, usize) { ... }
fn write_from_slice_to_frame(
&mut self,
frame: usize,
skip: usize,
slice: &[T],
) -> (usize, usize) { ... }
fn write_from_other_to_channel(
&mut self,
other: &dyn Adapter<'a, T>,
other_channel: usize,
self_channel: usize,
other_skip: usize,
self_skip: usize,
take: usize,
) -> Option<usize> { ... }
fn fill_channel_with(&mut self, channel: usize, value: &T) -> Option<()> { ... }
fn fill_frame_with(&mut self, frame: usize, value: &T) -> Option<()> { ... }
fn fill_frames_with(
&mut self,
start: usize,
count: usize,
value: &T,
) -> Option<usize> { ... }
fn fill_with(&mut self, value: &T) { ... }
fn copy_frames_within(
&mut self,
src: usize,
dest: usize,
count: usize,
) -> Option<usize> { ... }
}Expand description
A trait for writing samples to a buffer.
Samples are accessed indirectly by a write_sample method.
Implementations may perform any needed transformation
of the sample value before writing to the underlying buffer.
Required Methods§
Sourceunsafe fn write_sample_unchecked(
&mut self,
channel: usize,
frame: usize,
value: &T,
) -> bool
unsafe fn write_sample_unchecked( &mut self, channel: usize, frame: usize, value: &T, ) -> bool
Write a sample to the
given combination of frame and channel.
Returns a boolean indicating if the sample value
was clipped during conversion.
Implementations that do not perform any conversion
always return false.
§Safety
This method performs no bounds checking. Calling it with an out-of-bound value for frame or channel results in undefined behavior, for example returning an invalid value or panicking.
Provided Methods§
Sourcefn write_sample(
&mut self,
channel: usize,
frame: usize,
value: &T,
) -> Option<bool>
fn write_sample( &mut self, channel: usize, frame: usize, value: &T, ) -> Option<bool>
Write a sample to the
given combination of frame and channel.
Returns a boolean indicating if the sample value
was clipped during conversion.
Implementations that do not perform any conversion
always return false.
Returns None if the frame or channel is
out of bounds of the buffer.
Sourcefn write_from_slice_to_channel(
&mut self,
channel: usize,
skip: usize,
slice: &[T],
) -> (usize, usize)
fn write_from_slice_to_channel( &mut self, channel: usize, skip: usize, slice: &[T], ) -> (usize, usize)
Write values from a slice into a channel of the buffer.
The skip argument is the offset into the buffer channel
where the first value will be written.
If the slice is longer than the available space in the buffer channel,
then only the number of samples that fit will be read.
Returns a tuple of two numbers.
The first is the number of values written,
and the second is the number of values that were clipped during conversion.
Implementations that do not perform any conversion
always return zero clipped samples.
If an invalid channel number is given,
or if skip is larger than the length of the channel,
no samples will be read and (0, 0) is returned.
Sourcefn write_from_slice_to_frame(
&mut self,
frame: usize,
skip: usize,
slice: &[T],
) -> (usize, usize)
fn write_from_slice_to_frame( &mut self, frame: usize, skip: usize, slice: &[T], ) -> (usize, usize)
Write values from a slice into a frame of the buffer.
The skip argument is the offset into the buffer frame
where the first value will be written.
If the slice is longer than the available space in the buffer frame,
then only the number of samples that fit will be read.
Returns a tuple of two numbers.
The first is the number of values written,
and the second is the number of values that were clipped during conversion.
Implementations that do not perform any conversion
always return zero clipped samples.
If an invalid frame number is given,
or if skip is larger than the length of the frame,
no samples will be read and (0, 0) is returned.
Sourcefn write_from_other_to_channel(
&mut self,
other: &dyn Adapter<'a, T>,
other_channel: usize,
self_channel: usize,
other_skip: usize,
self_skip: usize,
take: usize,
) -> Option<usize>
fn write_from_other_to_channel( &mut self, other: &dyn Adapter<'a, T>, other_channel: usize, self_channel: usize, other_skip: usize, self_skip: usize, take: usize, ) -> Option<usize>
Copy values from a channel of another buffer to self.
The self_skip and other_skip arguments are the offsets
in frames for where copying starts in the two buffers.
The method copies take values.
Returns the the number of values that were clipped during conversion. Implementations that do not perform any conversion always return zero clipped samples.
If an invalid channel number is given,
or if either of the buffers is to short to copy take values,
no values will be copied and None is returned.
Sourcefn fill_channel_with(&mut self, channel: usize, value: &T) -> Option<()>
fn fill_channel_with(&mut self, channel: usize, value: &T) -> Option<()>
Write the provided value to every sample in a channel.
Can be used to clear a channel by writing zeroes,
or to initialize each sample to a certain value.
Returns None if called with an invalid channel number.
Sourcefn fill_frame_with(&mut self, frame: usize, value: &T) -> Option<()>
fn fill_frame_with(&mut self, frame: usize, value: &T) -> Option<()>
Write the provided value to every sample in a frame.
Can be used to clear a frame by writing zeroes,
or to initialize each sample to a certain value.
Returns None if called with an invalid frame number.
Sourcefn fill_frames_with(
&mut self,
start: usize,
count: usize,
value: &T,
) -> Option<usize>
fn fill_frames_with( &mut self, start: usize, count: usize, value: &T, ) -> Option<usize>
Write the provided value to every sample in a range of frames.
Can be used to clear a range of frames by writing zeroes,
or to initialize each sample to a certain value.
Returns None if called with a too large range.
Sourcefn fill_with(&mut self, value: &T)
fn fill_with(&mut self, value: &T)
Write the provided value to every sample in the entire buffer. Can be used to clear a buffer by writing zeroes, or to initialize each sample to a certain value.
Sourcefn copy_frames_within(
&mut self,
src: usize,
dest: usize,
count: usize,
) -> Option<usize>
fn copy_frames_within( &mut self, src: usize, dest: usize, count: usize, ) -> Option<usize>
Copy frames within the buffer.
Copying is performed for all channels.
Copies (by cloning) count frames, from the range src..src+count,
to the range dest..dest+count.
The two regions are allowed to overlap.