#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringStable format identifier used in plans and conversion requests.
name: StringHuman-readable format name.
extensions: Vec<String>Extension aliases, normalized and deduplicated during registration.
media: MediaKindBroad media category.
decode_only: boolMark 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
impl Format
Sourcepub fn new(id: &str, name: &str, media: MediaKind) -> Format
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.
Sourcepub fn with_extensions(self, extensions: &[&str]) -> Format
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.
Sourcepub fn with_mime(self, mime_types: &[&str]) -> Format
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.
Sourcepub fn decode_only(self) -> Format
pub fn decode_only(self) -> Format
Set the decode-only routing flag; see Self::decode_only.
Sourcepub fn with_payloads(self, payloads: &[ContentKind]) -> Format
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.
Sourcepub fn in_container(self, container: &str) -> Format
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§
impl Eq for Format
impl StructuralPartialEq for Format
Auto Trait Implementations§
impl Forget for Format
impl Freeze for Format
impl RefUnwindSafe for Format
impl Send for Format
impl Sync for Format
impl Unpin for Format
impl UnsafeUnpin for Format
impl UnwindSafe for Format
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.