AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::WaveRecorder

Struct WaveRecorder 

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

Worker-owned recording sink for an input ring, with explicit finalization. Device callbacks only publish to the producer; pump performs file I/O here. No thread, physical device, file path or recording permission is chosen.

Implementations§

§

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

pub fn new( destination: W, format: WaveFormat, maximum_frames: usize, consumer: AudioConsumer, ) -> Result<Self, AudioFileError>

Validate matching channels before writing a header to an empty destination.

pub fn frames(&self) -> u64

pub fn pump(&mut self) -> Result<usize, AudioFileError>

Drain at most prepared scratch frames. Empty returns zero without file I/O. Any recording error poisons this sink because dequeued frames cannot be rolled back; later calls reject. Input ring drops remain producer diagnostics.

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

Stop/join the producer first. Drain at most one ring capacity, patch WAV lengths and flush. Continuing publication can reject finalization or lose late frames: stopped-producer ownership is a caller lifecycle obligation. Drop performs no implicit drain/finalization/file I/O.

Trait Implementations§

§

impl<W: Write + Seek + Send + 'static> RecordingPump for WaveRecorder<W>

§

type Destination = W

Caller-selected sink returned only after successful consuming finish.
§

fn consumer(&self) -> &AudioConsumer

Stable exact owned consumer drained by pump/finish. It must identify the same ring for the recorder’s lifetime, including permanent retirement proof.
§

fn owns(&self, producer: &AudioProducer) -> bool

Check exact prepared producer/consumer identity outside callbacks.
§

fn pump(&mut self) -> Result<usize, AudioFileError>

Drain one bounded worker batch, returning successfully accepted frames.
§

fn frames(&self) -> u64

Source count semantics remain explicit: WAV/AIFF count successful writes; FLAC counts accepted encoder frames, including retained pending blocks.
§

fn finish(self) -> Result<W, AudioFileError>

Drain bounded remaining input and finalize the sink with producer stopped.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<W> UnwindSafe for WaveRecorder<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.