Skip to main content

Engine

Struct Engine 

Source
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

Source

pub fn new() -> Self

New engine with no extractors registered. Useful when you want full control over the backend set.

Source

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.

Source

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.

Source

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).

Source

pub fn len(&self) -> usize

Returns the number of registered extractors.

Source

pub fn is_empty(&self) -> bool

Returns true when no extractors are registered.

Source

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.

Source

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§

Source§

impl Default for Engine

Source§

fn default() -> Self

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.