pub struct Registry { /* private fields */ }Implementations§
Source§impl Registry
impl Registry
pub fn new() -> Self
pub fn register_codec(&mut self, codec: Arc<dyn Codec>, meta: FormatMeta)
pub fn register_container( &mut self, container: Arc<dyn Container>, meta: FormatMeta, )
pub fn codec(&self, id: FormatId) -> Option<&Arc<dyn Codec>>
pub fn container(&self, id: FormatId) -> Option<&Arc<dyn Container>>
Sourcepub fn require_codec(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
pub fn require_codec(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
Like Self::codec but yields FormatNotEnabled (exit 3), which is how
a caller distinguishes “wrong build” from “broken file”.
Sourcepub fn require_encoder(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
pub fn require_encoder(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
The codec for id, if this build has it and it can encode.
Separate from Self::require_codec because a codec that cannot encode
is a normal thing to have: the pure-Rust zstd and xz fallbacks let a
build with no C toolchain still read those formats. Without this check
the caller reaches encoder() on such a codec, and the natural body for
that method is a panic — reachable straight from a command line.
Sourcepub fn require_decoder(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
pub fn require_decoder(&self, id: FormatId) -> Result<&Arc<dyn Codec>>
The codec for id, if this build has it and it can decode.
pub fn require_container(&self, id: FormatId) -> Result<&Arc<dyn Container>>
Sourcepub fn by_extension(&self, ext: &str) -> Option<FormatId>
pub fn by_extension(&self, ext: &str) -> Option<FormatId>
Extension lookup. Accepts "gz" or ".gz", any case.
Sourcepub fn match_magic(&self, prefix: &[u8]) -> Vec<FormatId>
pub fn match_magic(&self, prefix: &[u8]) -> Vec<FormatId>
Every format whose magic matches prefix. Empty rather than a guess.
Sourcepub fn priority_of(&self, id: FormatId) -> i16
pub fn priority_of(&self, id: FormatId) -> i16
The priority of a registered format, or 0 if unknown.