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>
impl<'input, P> SliceDecoder<'input, P>
Sourcepub const fn state(&self) -> DecoderState
pub const fn state(&self) -> DecoderState
Current decoding progress, successful completion, or terminal failure.
Sourcepub fn into_inner(self) -> (&'input [u8], P)
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>
impl<'input> SliceDecoder<'input>
Source§impl<'input, P: AsMut<[i16]>> SliceDecoder<'input, P>
impl<'input, P: AsMut<[i16]>> SliceDecoder<'input, P>
Sourcepub fn with_buffer(input: &'input [u8], pcm: P) -> Result<Self, Error>
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.
Sourcepub fn next_block(&mut self) -> Result<Option<&[i16]>, Error>
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.