sound_rs v0.6.0

11 · Reference

Guarantees

A library is trustworthy when its promises are written down and tested. This is the list, and the ones that are deliberately not on it.

Errors

Library failures use sound_rs.SoundRsError (a RuntimeError) with a stable .code. Python argument conversion can raise TypeError or OverflowError; float64 arrays are rejected rather than silently converted.

CodeMeaning
ioThe file could not be opened, read or written.
formatThe container or codec was not understood, or no audio was decodable.
deviceNo output/input device, open failure or reported backend fault.
stalledPlayback/feed made no progress, or the recording collector could not keep up.
unsupportedThe build lacks a feature (NumPy) or hit a documented limit.
usageInvalid values, WAV dimensions or call order, for example feed() before begin_feed().

Codes are part of the API: renaming one is a breaking change.

No panics on bad input

The contract is to report malformed input without a panic crossing the Python boundary. Regression coverage in cargo test includes mutating every committed fixture ~200 times per file (bit flips, truncation, appended noise) and by feeding random bytes; every case must return Ok with finite samples or a non-empty error. This bounded test corpus is not exhaustive fuzzing or proof that arbitrary untrusted media is safe.

Threads and the GIL

Determinism

tests/decode_regression.py checks exact dimensions/rates for nine fixtures and SHA-256 hashes of samples rounded to 10⁻⁴ for all of them. Missing fixtures fail. fixtures fail the check. These are regression bounds, not a guarantee that every sample change is detected or that decoder output is bit-identical across CPUs and dependency versions.

Memory

Audio quality

What is not promised