pub enum OcrError {
Pdf(Error),
Io(Error),
PageOutOfRange(u32, u32),
Engine(String),
Render(String),
Other(String),
}Expand description
Errors returned by the pdf-ocr crate during optical character
recognition.
Wrapping engines (Tesseract, PaddleOCR) bubble their own errors up via
the OcrError::Engine variant — this crate does not classify
engine-specific failures.
Variants§
Pdf(Error)
The underlying PDF byte stream could not be parsed before OCR could be attempted (malformed cross-reference table, truncated stream, encrypted document opened without a password, etc.).
Io(Error)
An I/O error occurred while reading the source PDF or writing OCR output (e.g. searchable PDF or hOCR sidecar).
PageOutOfRange(u32, u32)
The caller asked to OCR a page index that does not exist in the document.
Fields: (requested_page, total_pages). Page numbers are 1-based.
Engine(String)
The configured OCR engine returned a non-recoverable error (Tesseract initialisation failure, missing language data, model load failure, etc.). The wrapped string is the engine’s verbatim message — surface it to the user.
Render(String)
Rasterising the page for OCR failed before the engine could see any pixels (font resolution failure, unsupported colorspace, page geometry error, etc.).
Other(String)
A non-categorised OCR failure. Reserved for cases the more specific variants do not cover; the message describes the situation.
Trait Implementations§
Source§impl Error for OcrError
impl Error for OcrError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for OcrError
impl !RefUnwindSafe for OcrError
impl Send for OcrError
impl Sync for OcrError
impl Unpin for OcrError
impl UnsafeUnpin for OcrError
impl !UnwindSafe for OcrError
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