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_reader(&mut self, reader: Arc<dyn DocumentReader>) -> &mut Self

Source

pub fn register_detector(&mut self, detector: Arc<dyn Detector>) -> &mut Self

Source

pub fn reader_for(&self, format: FormatId) -> Option<&dyn DocumentReader>

Finds the reader that handles a format. The last one registered wins, so a plugin can deliberately replace a built-in.

Source

pub fn formats(&self) -> Vec<FormatId>

Source

pub fn detect(&self, src: &Source) -> Option<Detection>

Runs every detector and returns the most confident result.

Ties go to whichever was registered later: plugins register after the built-ins, so they can claim a format at equal confidence.

Source

pub fn detect_all(&self, src: &Source) -> Vec<Detection>

Every candidate, ordered by descending confidence. This is what --explain prints: seeing what was rejected is half the useful information.

Source

pub fn detect_or_fallback(&self, src: &Source) -> Detection

Detection with the final safety net: if nobody claims the source, decide between text and binary. Never returns None, because “I don’t know what this is” is not an acceptable answer from a universal viewer.

Trait Implementations§

Source§

impl Debug for Registry

Source§

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

Formats the value using the given formatter. Read more
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.