Skip to main content

Guard

Struct Guard 

Source
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>

Source

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>

Source

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).

Source

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>>§

Source

pub const DEFAULT_NAME: &'static str = "catalog.json"

Source

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.

Source

pub fn without_ext(&self) -> Catalog

Copy every section into a catalog with no application extension.

Source

pub fn to_json(&self) -> Result<String, Error>

Serialize the catalog to a JSON string.

Source

pub fn to_vec(&self) -> Result<Vec<u8>, Error>

Serialize the catalog to a vector of bytes.

Source

pub fn to_writer(&self, writer: impl Write) -> Result<(), Error>

Serialize the catalog to a writer.

Trait Implementations§

Source§

impl<E: CatalogExt> Deref for Guard<'_, E>

Source§

type Target = Catalog<E>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<E: CatalogExt> DerefMut for Guard<'_, E>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<E: CatalogExt> Drop for Guard<'_, E>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, E = ()> !Send for Guard<'a, E>

§

impl<'a, E = ()> !UnwindSafe for Guard<'a, E>

§

impl<'a, E> Freeze for Guard<'a, E>

§

impl<'a, E> RefUnwindSafe for Guard<'a, E>
where E: RefUnwindSafe,

§

impl<'a, E> Sync for Guard<'a, E>
where E: Sync,

§

impl<'a, E> Unpin for Guard<'a, E>

§

impl<'a, E> UnsafeUnpin for Guard<'a, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more