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 new_with_default_parser_config(config: DefaultParserConfig) -> Self
pub fn new_with_default_parser_config(config: DefaultParserConfig) -> Self
Create a registry pre-loaded with PlainTextParser and a configured
DefaultParser.
Sourcepub fn new_with_default_parser(
config: DefaultParserConfig,
ocr_provider: Option<Arc<dyn DefaultParserOcrProvider>>,
) -> Self
pub fn new_with_default_parser( config: DefaultParserConfig, ocr_provider: Option<Arc<dyn DefaultParserOcrProvider>>, ) -> Self
Create a registry pre-loaded with PlainTextParser and a configured
DefaultParser, optionally wiring an OCR provider into that parser.
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_document(&self, path: &Path) -> Result<Option<ParsedDocument>>
pub fn parse_file_document(&self, path: &Path) -> Result<Option<ParsedDocument>>
Parse path and return a structured document.
Returns:
Ok(Some(document))— parsed successfullyOk(None)— no parser available, or file too largeErr(_)— I/O or metadata failure (not a parse failure)
Sourcepub fn parse_file(&self, path: &Path) -> Result<Option<String>>
pub fn parse_file(&self, path: &Path) -> Result<Option<String>>
Parse path and return extracted text for compatibility with older
call sites.
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