pub struct Registry { /* private fields */ }Implementations§
Source§impl Registry
impl Registry
pub fn new() -> Self
pub fn register_reader(&mut self, reader: Arc<dyn DocumentReader>) -> &mut Self
pub fn register_detector(&mut self, detector: Arc<dyn Detector>) -> &mut Self
Sourcepub fn reader_for(&self, format: FormatId) -> Option<&dyn DocumentReader>
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.
pub fn formats(&self) -> Vec<FormatId>
Sourcepub fn detect(&self, src: &Source) -> Option<Detection>
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.
Sourcepub fn detect_all(&self, src: &Source) -> Vec<Detection>
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.
Sourcepub fn detect_or_fallback(&self, src: &Source) -> Detection
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§
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !UnwindSafe for Registry
impl Freeze for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
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
Mutably borrows from an owned value. Read more