pub trait FileCodec {
// Required methods
fn device(&self) -> Device;
fn sample_rate(&self) -> u32;
fn encode_file(
&self,
in_audio: &Path,
out_compressed: &Path,
) -> Result<CompressStats>;
fn decode_file(&self, in_compressed: &Path, out_wav: &Path) -> Result<()>;
// Provided method
fn roundtrip_file(
&self,
in_audio: &Path,
out_wav: &Path,
) -> Result<CompressStats> { ... }
}Expand description
A file-level audio compressor: an audio file ⇄ an opaque compressed
bitstream on disk. Unlike AudioCodec, there are no in-memory PCM buffers
or discrete RVQ codes — the compressed form is a self-contained file
(e.g. TSAC’s transformer-entropy-coded .tsac). This is the home for codecs
that don’t expose a frame/quantizer structure.
Required Methods§
Sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Native sample rate the codec targets.
Sourcefn encode_file(
&self,
in_audio: &Path,
out_compressed: &Path,
) -> Result<CompressStats>
fn encode_file( &self, in_audio: &Path, out_compressed: &Path, ) -> Result<CompressStats>
Compress in_audio → out_compressed, returning size + timing.
Provided Methods§
Sourcefn roundtrip_file(
&self,
in_audio: &Path,
out_wav: &Path,
) -> Result<CompressStats>
fn roundtrip_file( &self, in_audio: &Path, out_wav: &Path, ) -> Result<CompressStats>
Encode then decode through a temporary compressed file. Codecs with a cheaper native roundtrip may override this.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".