#[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) -> Self
pub fn new(id: &str, name: &str, media: MediaKind) -> Self
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]) -> Self
pub fn with_extensions(self, extensions: &[&str]) -> Self
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]) -> Self
pub fn with_mime(self, mime_types: &[&str]) -> Self
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) -> Self
pub fn decode_only(self) -> Self
Set the decode-only routing flag; see Self::decode_only.
Sourcepub fn with_payloads(self, payloads: &[ContentKind]) -> Self
pub fn with_payloads(self, payloads: &[ContentKind]) -> Self
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) -> Self
pub fn in_container(self, container: &str) -> Self
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.