#[non_exhaustive]pub enum Error {
Show 16 variants
Load(LoadError),
AlreadyLoaded {
loaded_from: Option<PathBuf>,
requested: PathBuf,
},
Io(Error),
PasswordRequired,
IncorrectPassword,
UnsupportedSecurity,
InvalidPdf,
Pdfium {
code: u64,
},
PageIndexOutOfBounds {
index: usize,
count: usize,
},
PageLoadFailed {
index: usize,
},
TextLoadFailed {
index: usize,
},
TextTooLarge {
chars: usize,
limit: usize,
},
FormInitFailed,
RenderTooLarge {
required_bytes: u64,
limit: u64,
},
RenderFailed {
reason: &'static str,
},
InvalidConfig(String),
}Expand description
All errors returned by the safe API.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Load(LoadError)
The PDFium library could not be loaded.
AlreadyLoaded
PDFium is already loaded from a different library path; the process keeps the first successfully loaded library for its lifetime.
Fields
Io(Error)
I/O failure while reading a PDF file from disk.
PasswordRequired
The document is encrypted and requires a password, but none was supplied.
IncorrectPassword
A password was supplied but does not unlock the document.
UnsupportedSecurity
The document uses a security/encryption scheme PDFium does not support.
InvalidPdf
The data is not a PDF, or is too corrupt to open.
Pdfium
PDFium reported an error code this crate does not recognize.
PageIndexOutOfBounds
Requested page index does not exist.
PageLoadFailed
PDFium failed to load a page that should exist (severely corrupt page tree or content).
TextLoadFailed
PDFium failed to prepare the page for text extraction.
TextTooLarge
The page reports more text characters than the configured
extraction limit (see PdfPage::text_with_limit); nothing was
allocated.
FormInitFailed
PDFium failed to initialize the form-fill environment.
RenderTooLarge
The rendered output would exceed RenderConfig::max_output_bytes
(or the hard i32 pixel-dimension limits of PDFium’s bitmap API).
RenderFailed
Rendering failed inside PDFium (bitmap creation or coordinate transform rejected).
InvalidConfig(String)
An argument or configuration value is invalid (zero/non-finite scale, zero target dimensions, interior NUL byte in a password, …).
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_encryption_error(&self) -> bool
pub fn is_encryption_error(&self) -> bool
True when the failure is specifically about encryption/passwords:
Error::PasswordRequired, Error::IncorrectPassword, or
Error::UnsupportedSecurity.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()