AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::FlacWriter

Struct FlacWriter 

pub struct FlacWriter<W> { /* private fields */ }
Expand description

Optional incremental PCM16/24 FLAC writer for an empty seekable destination. Accepts at most 65536 whole interleaved frames per write and retains only one 4096-frame pending block, one backend frame buffer and one serialized frame. Backend working allocations remain its contract; all methods are worker-only. Invalid input preserves prior state/output. Encoding/I/O/capacity failure after acceptance poisons the writer; output may contain an irreversible prefix. Finish emits the sole short final block, rewrites STREAMINFO count/MD5/frame sizes and flushes before returning ownership. Drop does not finalize; partial files are not complete recordings. No float quantization, path/thread/device policy, implicit file truncation or physical recording/deadline claim.

Implementations§

§

impl<W: Write + Seek> FlacWriter<W>

pub fn new( destination: W, format: FlacFormat, maximum_frames: u64, maximum_bytes: u64, ) -> Result<Self, Error>

Require a destination of length zero, 1..8 channels/1..96000 Hz, a maximum frame count 1..2^36-1 fitting usize, and byte budget at least 42 (header). Validation/preparation precede header output; native I/O errors may mutate destination position or leave a partial header. The sink is caller-owned.

pub fn format(&self) -> FlacFormat

pub fn accepted_frames(&self) -> u64

Accepted frames, including retained pending input and any poisoned prefix.

pub fn pending_frames(&self) -> usize

pub fn written_bytes(&self) -> u64

Header plus complete serialized frames submitted successfully to the sink. A failed write may have submitted an additional partial frame.

pub fn is_poisoned(&self) -> bool

pub fn write_frames(&mut self, samples: &[i32]) -> Result<(), Error>

Validate the complete call before acceptance, then emit full fixed blocks. Empty writes are no-ops. Per-call/total input bounds and signed precision violations preserve a usable writer. Output-budget failure during encoding poisons; earlier successful output and accepted pending samples remain.

pub fn finish(self) -> Result<W, Error>

Consume a nonempty recording; output/header/flush failure returns an error and drops the sink without a complete-file guarantee. No retry/rollback.

Auto Trait Implementations§

§

impl<W> Freeze for FlacWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for FlacWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for FlacWriter<W>
where W: Send,

§

impl<W> Sync for FlacWriter<W>
where W: Sync,

§

impl<W> Unpin for FlacWriter<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for FlacWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for FlacWriter<W>
where W: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.