Frames

Struct Frames 

Source
pub struct Frames<'a> { /* private fields */ }
Expand description

Representation of the frames of an associated DsfFile.

A frame consists of n blocks, one for each channel. So a stereo frame consits of two blocks, the first contains 4096 bytes of sample data for the front-left channel, the second contains 4096 bytes of data for the front-right channel.

Only one frame ever exists in memory at a time. When a new frame is required it is loaded from file on-demand. This keeps the memory footprint small e.g. 2 × 4096 = 8192 bytes for a stereo frame.

Implementations§

Source§

impl<'a> Frames<'a>

Source

pub fn offset(&self, frame_index: u64) -> Result<u64, Error>

Return the offset (position in the DSF file in bytes) of the specified frame.

Note that frame_index is zero-based so the first frame has frame_index=0, etc.

§Errors

This method returns an error ifframe_index >= frame_count.

Source

pub fn frame_and_block_index( &self, sample_index: u64, ) -> Result<(u64, usize), Error>

Return the frame and block index as a tuple (frame_index, block_index) for the given sample_index if they exist or a out of range error if sample_index >= sample_count.

§Errors

Returns an error if sample_index >= sample_count.

Source

pub fn load_frame(&mut self, frame_index: u64) -> Result<(), Error>

Load the frame specified by frame_index into memory.

The Frames struct keeps only one frame in memory at a time.

§Errors

This method returns an error if frames_index is out of range or there is an io::Error.

Source

pub fn samples_as_u32( &mut self, channel_index: usize, sample_index: u64, ) -> Result<u32, Error>

Return a u32 containing the specified sample and channel.

§Errors

This method returns an error if sample_index is out of range or if unable to read the frame.

Auto Trait Implementations§

§

impl<'a> Freeze for Frames<'a>

§

impl<'a> RefUnwindSafe for Frames<'a>

§

impl<'a> Send for Frames<'a>

§

impl<'a> Sync for Frames<'a>

§

impl<'a> Unpin for Frames<'a>

§

impl<'a> !UnwindSafe for Frames<'a>

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.