pub struct Guard<'a, E: CatalogExt = ()> { /* private fields */ }Expand description
RAII guard for modifying a catalog with automatic publishing on drop.
Obtained via Producer::modify. Derefs to the Catalog<E>, so base
sections are editable directly and application sections are editable through ext.
On drop, the hang and MSF catalog tracks are updated if the catalog was
mutated. That publish cannot return an error, so a failure (an extension that won’t serialize,
a catalog too large for a frame) aborts the catalog tracks instead: consumers see the error and
the next Producer::modify returns it. A stamp refused on publishing is
the exception: the edit is undone, so it is logged and the tracks stay open. Call
commit when the caller can act on the failure itself.
Implementations§
Source§impl<E: CatalogExt> Guard<'_, E>
impl<E: CatalogExt> Guard<'_, E>
Sourcepub fn commit(self) -> Result<()>
pub fn commit(self) -> Result<()>
Publish the edited catalog to every catalog track, returning any error.
Consumes the guard, so the subsequent drop publishes nothing. A no-op if the catalog was never
mutated, and still withheld while a Reserved gates the initial snapshot.
Unlike a drop, a failure here leaves the tracks open: the caller has the error and decides
what to do with it.
Source§impl Guard<'_, Extra>
impl Guard<'_, Extra>
Sourcepub fn set_section(
&mut self,
name: impl Into<String>,
value: Value,
) -> Result<()>
pub fn set_section( &mut self, name: impl Into<String>, value: Value, ) -> Result<()>
Set (or replace) a top-level application catalog section, republished on drop.
Errors if name is a HANG root (video, audio, sync, text, json, binary,
stats, echo, include, or the retired archive, clock, media, and timeline) or an
MSF root (version, generatedAt, isComplete, tracks, or initDataList).
Sourcepub fn remove_section(&mut self, name: &str) -> Option<Value>
pub fn remove_section(&mut self, name: &str) -> Option<Value>
Remove a top-level application catalog section, republished on drop if it existed.
Returns the section’s previous value, or None if it was absent.
Methods from Deref<Target = Catalog<E>>§
pub const DEFAULT_NAME: &'static str = "catalog.json"
Sourcepub fn check_renditions(&self) -> Result<(), Error>
pub fn check_renditions(&self) -> Result<(), Error>
Refuse a catalog with an ID naming both a video and an audio rendition, or with a rendition field out of range, such as a zero sample rate or a projection out of bounds.
Decoding already refuses an out-of-range rendition, so this catches a catalog built by hand.
Sourcepub fn without_ext(&self) -> Catalog
pub fn without_ext(&self) -> Catalog
Copy every section into a catalog with no application extension.