Skip to main content

Format

Struct Format 

Source
#[non_exhaustive]
pub struct Format { pub id: String, pub name: String, pub extensions: Vec<String>, pub media: MediaKind, pub decode_only: bool, pub mime_types: Vec<String>, pub payloads: Vec<ContentKind>, pub container: Option<String>, }
Expand description

A registered format and its lookup metadata.

A format ID describes a file representation, not an encoder configuration. Registering a format does not imply that any conversion to or from it exists.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: String

Stable format identifier used in plans and conversion requests.

§name: String

Human-readable format name.

§extensions: Vec<String>

Extension aliases, normalized and deduplicated during registration.

§media: MediaKind

Broad media category.

§decode_only: bool

Mark the format as decode-only for routing purposes.

Unless Policy::allow_decode_only is set, search skips edges targeting this format. It may still be a source or an identity target. This flag does not itself check an adapter’s encoding capabilities.

§mime_types: Vec<String>

Registered MIME types, normalized to lowercase during registration.

Graph::resolve matches trimmed, case-folded values containing / against these types and against the ID. Adapters declare an empty list when a format has no registered media type.

§payloads: Vec<ContentKind>

Declared content kinds this format can carry, as a capability ceiling.

A plain png declares [image]; an mp4 declares [image:codec, audio:codec, ...]. This describes what the representation is capable of holding, not what a specific file holds. Entries deduplicate by exact ContentKind via Graph::add_format. The planner uses declared payloads to qualify edges that require content on a format that has no observed profile; see Graph::routes_with_profile and Policy::inspect_content.

§container: Option<String>

Name of the physical container when this format wraps another.

Set by adapters for nested or wrapper representations, such as mp3 inside m4a or a compressed stream inside tar.gz. None (the default) marks a top-level format. The planner never interprets this field; it is a metadata label surfaced to callers and reports.

Implementations§

Source§

impl Format

Source

pub fn new(id: &str, name: &str, media: MediaKind) -> Format

Construct a format without extensions and with decode_only set to false.

This constructor does not validate the ID; Graph::add_format does.

Source

pub fn with_extensions(self, extensions: &[&str]) -> Format

Set extension aliases, normalizing case, whitespace, and leading dots.

Replaces previous aliases, sorts and deduplicates them. Invalid aliases are rejected later by Graph::add_format, not by this method.

Source

pub fn with_mime(self, mime_types: &[&str]) -> Format

Replace registered MIME types, normalizing case and surrounding whitespace.

Graph::add_format additionally rejects blank entries and types with whitespace. Type matching in Graph::resolve happens during lookup.

Source

pub fn decode_only(self) -> Format

Set the decode-only routing flag; see Self::decode_only.

Source

pub fn with_payloads(self, payloads: &[ContentKind]) -> Format

Declare the content kinds this representation can carry.

Replaces previous declarations and deduplicates by exact ContentKind; see Self::payloads.

Source

pub fn in_container(self, container: &str) -> Format

Name the physical container wrapping this representation; see Self::container.

The name is trimmed, stripped of leading dots, and lowercased; it must satisfy the same character rules as a format ID.

Trait Implementations§

Source§

impl Clone for Format

Source§

fn clone(&self) -> Format

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Format

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Format

Source§

impl PartialEq for Format

Source§

fn eq(&self, other: &Format) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Format

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.