pub struct DocumentParserRegistry { /* private fields */ }Expand description
Registry that maps file extensions to DocumentParser implementations.
- Created with
new(): includesPlainTextParserfor all common formats. - Created with
empty(): no parsers at all (useful for overriding defaults). - Later registrations override earlier ones for the same extension.
Implementations§
Source§impl DocumentParserRegistry
impl DocumentParserRegistry
Sourcepub fn register(&mut self, parser: Arc<dyn DocumentParser>)
pub fn register(&mut self, parser: Arc<dyn DocumentParser>)
Register a parser. Later registrations win for the same extension.
Sourcepub fn find_parser(&self, path: &Path) -> Option<Arc<dyn DocumentParser>>
pub fn find_parser(&self, path: &Path) -> Option<Arc<dyn DocumentParser>>
Find the parser responsible for path (extension lookup, then linear
can_parse scan).
Sourcepub fn parse_file(&self, path: &Path) -> Result<Option<String>>
pub fn parse_file(&self, path: &Path) -> Result<Option<String>>
Parse path and return the extracted text.
Returns:
Ok(Some(text))— parsed successfullyOk(None)— no parser available, or file too largeErr(_)— I/O or metadata failure (not a parse failure)
Sourcepub fn parsers(&self) -> &[Arc<dyn DocumentParser>]
pub fn parsers(&self) -> &[Arc<dyn DocumentParser>]
All registered parsers (in registration order).
Trait Implementations§
Source§impl Clone for DocumentParserRegistry
impl Clone for DocumentParserRegistry
Source§fn clone(&self) -> DocumentParserRegistry
fn clone(&self) -> DocumentParserRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DocumentParserRegistry
impl !RefUnwindSafe for DocumentParserRegistry
impl Send for DocumentParserRegistry
impl Sync for DocumentParserRegistry
impl Unpin for DocumentParserRegistry
impl UnsafeUnpin for DocumentParserRegistry
impl !UnwindSafe for DocumentParserRegistry
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