pub struct Engine { /* private fields */ }Expand description
Dispatches extract calls to the registered Extractor for the
file’s extension. Construct with Engine::new for an empty
engine, or Engine::with_defaults to populate the defaults that
match enabled feature flags.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new() -> Self
pub fn new() -> Self
New engine with no extractors registered. Useful when you want full control over the backend set.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
New engine with the default backends for the enabled feature
flags. Backends register themselves silently — if a backend
can’t initialize (e.g. libpdfium isn’t on the system library
path for the pdf feature), it’s skipped rather than failing
the whole construction. Use with_defaults_diagnostic if
you want to surface those failures to the user.
Sourcepub fn with_defaults_diagnostic() -> (Self, Vec<(&'static str, Error)>)
pub fn with_defaults_diagnostic() -> (Self, Vec<(&'static str, Error)>)
Like with_defaults but returns the
list of backend-init errors alongside the engine, so callers
can log “PDF support disabled: libpdfium not found” rather
than silently shipping a degraded experience.
Sourcepub fn register(&mut self, extractor: Box<dyn Extractor>) -> &mut Self
pub fn register(&mut self, extractor: Box<dyn Extractor>) -> &mut Self
Register a backend. Multiple backends can claim the same extension; the first registered wins on dispatch (so you can override defaults by registering your own extractor first).
Sourcepub fn extract(&self, path: &Path) -> Result<Document>
pub fn extract(&self, path: &Path) -> Result<Document>
Extract path to markdown, dispatching by file extension.
Returns Error::UnsupportedFormat if no registered extractor
claims the extension.
Sourcepub fn extract_bytes(&self, bytes: &[u8], ext: &str) -> Result<Document>
pub fn extract_bytes(&self, bytes: &[u8], ext: &str) -> Result<Document>
Same as extract but takes bytes + an explicit
extension. Backends that don’t implement
Extractor::extract_bytes return
Error::UnsupportedOperation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more