#[non_exhaustive]pub struct Audio {
pub renditions: BTreeMap<String, AudioConfig>,
}Expand description
Information about an audio track in the catalog.
This struct contains a map of renditions (different quality/codec options)
Marked #[non_exhaustive] so additional optional fields can be added without
bumping the major version. External callers start from Audio::default and
fill in what they need (insert for renditions); struct-literal
construction (with or without ..base) is not available outside this crate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.renditions: BTreeMap<String, AudioConfig>A map of track name to rendition configuration. This is not an array so it will work with JSON Merge Patch. We use a BTreeMap so keys are sorted alphabetically for some deterministic behavior.
A malformed rendition refuses the whole catalog when decoding.
Implementations§
Source§impl Audio
impl Audio
Sourcepub fn insert(&mut self, name: &str, config: AudioConfig) -> Result<()>
pub fn insert(&mut self, name: &str, config: AudioConfig) -> Result<()>
Insert a track config, returning an error if the name already exists.
Sourcepub fn remove(&mut self, name: &str) -> Option<AudioConfig>
pub fn remove(&mut self, name: &str) -> Option<AudioConfig>
Remove the track from the catalog and return the configuration if found.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True when there are no renditions, so the section can be omitted from the catalog.
Sourcepub fn enabled(&self) -> impl Iterator<Item = (&String, &AudioConfig)>
pub fn enabled(&self) -> impl Iterator<Item = (&String, &AudioConfig)>
Iterate enabled renditions in quality order.
Sourcepub fn ranked(&self) -> impl Iterator<Item = (&String, &AudioConfig)>
pub fn ranked(&self) -> impl Iterator<Item = (&String, &AudioConfig)>
Iterate the renditions best first: enabled, then highest bitrate, then sample rate, then channel count.
A consumer that carries one rendition takes the first it supports, so the choice doesn’t depend on how the tracks are named. An unknown bitrate ranks below a known one, and exact ties keep name order.