pub struct RecordingReader { /* private fields */ }Implementations§
Source§impl RecordingReader
impl RecordingReader
Sourcepub fn from_samples(samples: &[f32]) -> Self
pub fn from_samples(samples: &[f32]) -> Self
A finished recording of canonical 16 kHz mono samples, held in
memory.
Sourcepub fn from_samples_in(
spool_dir: &Path,
samples: &[f32],
) -> Result<Self, CaptureError>
Available on non-target_family=wasm only.
pub fn from_samples_in( spool_dir: &Path, samples: &[f32], ) -> Result<Self, CaptureError>
target_family=wasm only.RecordingReader::from_samples, saved as a private WAV in
spool_dir.
Sourcepub fn from_pcm16_in(
spool_dir: &Path,
samples: &[i16],
) -> Result<Self, CaptureError>
Available on non-target_family=wasm only.
pub fn from_pcm16_in( spool_dir: &Path, samples: &[i16], ) -> Result<Self, CaptureError>
target_family=wasm only.A finished recording of canonical samples already in 16-bit PCM, saved
as a private WAV in spool_dir.
Sourcepub fn fill_through(&mut self, position: u64) -> Result<bool, CaptureError>
pub fn fill_through(&mut self, position: u64) -> Result<bool, CaptureError>
Waits until the window reaches position, or until capture ends short
of it. Returns whether it reached position.
Sourcepub fn fill_available(&mut self) -> Result<(), CaptureError>
Available on non-target_family=wasm only.
pub fn fill_available(&mut self) -> Result<(), CaptureError>
target_family=wasm only.Takes whatever audio has arrived, without waiting for more.
Sourcepub fn fill(&mut self) -> Result<(), CaptureError>
pub fn fill(&mut self) -> Result<(), CaptureError>
Waits for capture to end.
Sourcepub fn fork(&self) -> Self
pub fn fork(&self) -> Self
A second reader of the same recording, with its own window and its own release floor: what one reader frees, the other still holds.
The recording keeps no history, so a fork opens where capture stands
rather than at the beginning — ask RecordingReader::held_from where
that was.
Every sample written from here on is copied into its queue until it drops, so a fork nobody reads grows without bound.
Sourcepub fn fork_window(&mut self) -> Self
pub fn fork_window(&mut self) -> Self
A fork that starts from this reader’s window, not where capture stands. It copies what this reader holds once it takes its queue.
Sourcepub fn span(&self, span: Range<u64>) -> &[f32]
pub fn span(&self, span: Range<u64>) -> &[f32]
The audio in span, clamped to the window. A span that ran off either
edge yields what survives of it, which may be nothing.
Sourcepub fn release_before(&mut self, position: u64)
pub fn release_before(&mut self, position: u64)
Frees this reader’s audio before position; other readers keep their
own copies.
Sourcepub fn reached_end(&self) -> bool
pub fn reached_end(&self) -> bool
Whether this reader has seen capture end. It learns that only when it
reads past the audio it holds, so it can lag.
RecordingReader::ended_at does not.
Sourcepub fn finished_audio(&mut self) -> Result<&RecordedAudio, CaptureError>
pub fn finished_audio(&mut self) -> Result<&RecordedAudio, CaptureError>
The finished WAV. Waits for capture to end, and keeps none of the samples it waits through.
§Panics
On a fork: only the reader that opened the recording owns its audio.
Sourcepub fn wait_for_end(&self, timeout: Duration) -> bool
Available on non-target_family=wasm only.
pub fn wait_for_end(&self, timeout: Duration) -> bool
target_family=wasm only.Waits up to timeout for capture to end, reading nothing. Returns
whether it ended.
Sourcepub fn waker(&self) -> RecordingWaker
Available on crate feature silero and non-target_family=wasm only.
pub fn waker(&self) -> RecordingWaker
silero and non-target_family=wasm only.Wakes this recording’s waiting readers without writing to it.
Sourcepub fn ended_at(&self) -> Option<Instant>
Available on non-target_family=wasm only.
pub fn ended_at(&self) -> Option<Instant>
target_family=wasm only.When capture ended. Unlike RecordingReader::reached_end, it does not wait
for this reader to catch up.
Source§impl RecordingReader
impl RecordingReader
Sourcepub fn from_wav_file(path: impl AsRef<Path>) -> Result<Self, CaptureError>
Available on non-target_family=wasm only.
pub fn from_wav_file(path: impl AsRef<Path>) -> Result<Self, CaptureError>
target_family=wasm only.Opens a caller-owned canonical 16 kHz mono WAV as a finished recording.
The file is validated for format, not trust — trust policy is for artifacts a daemon loads on a user’s behalf, and this file is the caller’s own. The file is borrowed, never deleted, and read whole into memory: about 8 bytes per sample, near 460 MB per hour of audio.
Sourcepub fn from_open_wav(
file: File,
path: impl AsRef<Path>,
) -> Result<Self, CaptureError>
Available on non-target_family=wasm only.
pub fn from_open_wav( file: File, path: impl AsRef<Path>, ) -> Result<Self, CaptureError>
target_family=wasm only.RecordingReader::from_wav_file over a file already open at
path, so checks made on that descriptor cover what is read.
Trait Implementations§
Source§impl Drop for RecordingReader
Retires this reader’s queue, so capture stops copying audio nobody will
read into it.
impl Drop for RecordingReader
Retires this reader’s queue, so capture stops copying audio nobody will read into it.