Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

Source

pub fn register_codec(&mut self, codec: Arc<dyn Codec>, meta: FormatMeta)

Source

pub fn register_container( &mut self, container: Arc<dyn Container>, meta: FormatMeta, )

Source

pub fn codec(&self, id: FormatId) -> Option<&Arc<dyn Codec>>

Source

pub fn container(&self, id: FormatId) -> Option<&Arc<dyn Container>>

Source

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

Source

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.

Source

pub fn require_decoder(&self, id: FormatId) -> Result<&Arc<dyn Codec>>

The codec for id, if this build has it and it can decode.

Source

pub fn require_container(&self, id: FormatId) -> Result<&Arc<dyn Container>>

Source

pub fn by_extension(&self, ext: &str) -> Option<FormatId>

Extension lookup. Accepts "gz" or ".gz", any case.

Source

pub fn match_magic(&self, prefix: &[u8]) -> Vec<FormatId>

Every format whose magic matches prefix. Empty rather than a guess.

Source

pub fn priority_of(&self, id: FormatId) -> i16

The priority of a registered format, or 0 if unknown.

Source

pub fn matrix(&self) -> Vec<FormatRow>

The capability matrix, sorted by id. Rendered by stuffr formats.

Trait Implementations§

Source§

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. Read more

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