claxon::frame

Struct FrameReader

Source
pub struct FrameReader<R: ReadBytes> { /* private fields */ }
Expand description

Reads frames from a stream and exposes decoded blocks as an iterator.

TODO: for now, it is assumes that the reader starts at a frame header; no searching for a sync code is performed at the moment.

Implementations§

Source§

impl<R: ReadBytes> FrameReader<R>

Source

pub fn new(input: R) -> FrameReader<R>

Creates a new frame reader that will yield at least one element.

Source

pub fn read_next_or_eof(&mut self, buffer: Vec<i32>) -> FrameResult

Decodes the next frame or returns an error if the data was invalid.

The buffer is moved into the returned block, so that the same buffer may be reused to decode multiple blocks, avoiding a heap allocation every time. It can be retrieved again with block.into_buffer(). If the buffer is not large enough to hold all samples, a larger buffer is allocated automatically.

TODO: I should really be consistent with ‘read’ and ‘decode’.

Source

pub fn into_inner(self) -> R

Destroy the frame reader, returning the wrapped reader.

Auto Trait Implementations§

§

impl<R> Freeze for FrameReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for FrameReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for FrameReader<R>
where R: Send,

§

impl<R> Sync for FrameReader<R>
where R: Sync,

§

impl<R> Unpin for FrameReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for FrameReader<R>
where R: UnwindSafe,

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.