Skip to main content

SliceDecoder

Struct SliceDecoder 

Source
pub struct SliceDecoder<'input, P = [i16; 1152]> { /* private fields */ }
Expand description

Allocation-free decoder over a complete AHX byte slice.

Self::new owns a fixed PCM array. Self::with_buffer accepts caller-owned storage instead. Neither constructor requires std or alloc. Input is consumed only as frames are decoded; trailing bytes after the footer remain unread.

Implementations§

Source§

impl<'input, P> SliceDecoder<'input, P>

Source

pub const fn metadata(&self) -> Metadata

Validated file timing and header layout.

Source

pub const fn state(&self) -> DecoderState

Current decoding progress, successful completion, or terminal failure.

Source

pub fn into_inner(self) -> (&'input [u8], P)

Recover unconsumed input and PCM storage without rewinding. After successful EOF the input begins immediately after the AHX end marker.

Source§

impl<'input> SliceDecoder<'input>

Source

pub fn new(input: &'input [u8]) -> Result<Self, Error>

Validate the header and initialize fixed synthesis and PCM arrays.

Source§

impl<'input, P: AsMut<[i16]>> SliceDecoder<'input, P>

Source

pub fn with_buffer(input: &'input [u8], pcm: P) -> Result<Self, Error>

Use caller-owned storage with at least SAMPLES_PER_FRAME i16 elements.

Short buffers are rejected before parsing input or modifying output. Borrow a slice to retain ownership on constructor failure. Storage length is checked again on each block; shorter views return an error and invalidate the decoder.

Source

pub fn next_block(&mut self) -> Result<Option<&[i16]>, Error>

Decode the next borrowed mono PCM16 block, or None at validated EOF.

The final block is trimmed to the declared sample count; its footer is checked before the block is returned. Calls after successful EOF return None. Any error invalidates the reader; later calls return Error::Failed. An unwinding panic in caller-provided storage also leaves it failed.

Trait Implementations§

Source§

impl<P> Debug for SliceDecoder<'_, P>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'input, P> Freeze for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: Freeze,

§

impl<'input, P> RefUnwindSafe for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: RefUnwindSafe,

§

impl<'input, P> Send for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: Send,

§

impl<'input, P> Sync for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: Sync,

§

impl<'input, P> Unpin for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: Unpin,

§

impl<'input, P> UnsafeUnpin for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: UnsafeUnpin,

§

impl<'input, P> UnwindSafe for SliceDecoder<'input, P>
where Stream<SliceInput<'input>, P>: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.