Skip to main content

Block

Struct Block 

Source
pub struct Block<'slice, 'sample: 'slice> { /* private fields */ }
Expand description

A block yielded by BlocksIter. Can be iterated over once or multiple times, and also supports direct access to the block’s samples if needed.

Implementations§

Source§

impl<'slice, 'sample> Block<'slice, 'sample>

Source

pub fn samples(&self) -> usize

Get the number of samples per channel in the block.

Source

pub fn channels(&self) -> usize

Returns the number of channels in this buffer.

Source

pub fn iter_mut(&mut self) -> BlockChannelsIter<'slice, 'sample>

A resetting iterator. This lets you iterate over the same block multiple times. Otherwise you don’t need to use this function as Block already implements Iterator. You can also use the direct accessor functions on this block instead.

Source

pub fn iter_samples(&mut self) -> SamplesIter<'slice, 'sample>

Iterate over this block on a per-sample per-channel basis. This is identical to Buffer::iter_samples() but for a smaller block instead of the entire buffer

Source

pub fn get(&self, channel_index: usize) -> Option<&[f32]>

Access a channel by index. Useful when you would otherwise iterate over this Block multiple times.

Source

pub unsafe fn get_unchecked(&self, channel_index: usize) -> &[f32]

The same as get(), but without any bounds checking.

§Safety

channel_index must be in the range 0..Self::len().

Source

pub fn get_mut(&mut self, channel_index: usize) -> Option<&mut [f32]>

Access a mutable channel by index. Useful when you would otherwise iterate over this Block multiple times.

Source

pub unsafe fn get_unchecked_mut(&mut self, channel_index: usize) -> &mut [f32]

The same as get_mut(), but without any bounds checking.

§Safety

channel_index must be in the range 0..Self::len().

Source

pub fn to_channel_simd<const LANES: usize>( &self, sample_index: usize, ) -> Option<Simd<f32, LANES>>

Get a SIMD vector containing the channel data for a specific sample in this block. If `LANES

channels.len()then this will be padded with zeroes. IfLANES < channels.len()` then this won’t contain all values.

Returns a None value if sample_index is out of bounds.

Source

pub unsafe fn to_channel_simd_unchecked<const LANES: usize>( &self, sample_index: usize, ) -> Simd<f32, LANES>

Get a SIMD vector containing the channel data for a specific sample in this block. Will always read exactly LANES channels, and does not perform bounds checks on sample_index.

§Safety

Undefined behavior if LANES > block.len() or if sample_index > block.len().

Source

pub fn from_channel_simd<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES>, ) -> bool

Write data from a SIMD vector to this sample’s channel data for a specific sample in this block. This takes the padding added by to_channel_simd() into account.

Returns false if sample_index is out of bounds.

Source

pub unsafe fn from_channel_simd_unchecked<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES>, )

Write data from a SIMD vector to this sample’s channel data for a specific sample in this block.. This assumes LANES matches exactly with the number of channels in the buffer, and does not perform bounds checks on sample_index.

§Safety

Undefined behavior if LANES > block.len() or if sample_index > block.len().

Trait Implementations§

Source§

impl<'slice, 'sample> IntoIterator for Block<'slice, 'sample>

Source§

type Item = &'sample mut [f32]

The type of the elements being iterated over.
Source§

type IntoIter = BlockChannelsIter<'slice, 'sample>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'slice, 'sample> Freeze for Block<'slice, 'sample>

§

impl<'slice, 'sample> RefUnwindSafe for Block<'slice, 'sample>

§

impl<'slice, 'sample> !Send for Block<'slice, 'sample>

§

impl<'slice, 'sample> !Sync for Block<'slice, 'sample>

§

impl<'slice, 'sample> Unpin for Block<'slice, 'sample>

§

impl<'slice, 'sample> UnsafeUnpin for Block<'slice, 'sample>

§

impl<'slice, 'sample> !UnwindSafe for Block<'slice, 'sample>

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>,

Source§

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>,

Source§

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.