#[non_exhaustive]pub enum RenderError {
Show 13 variants
TooLarge {
width: u64,
height: u64,
limit: u64,
unit: &'static str,
},
InputTooLarge {
len: u64,
limit: u64,
},
InvalidRequest {
what: &'static str,
},
BufferSize {
expected: usize,
actual: usize,
},
PageIndexOutOfRange {
index: u32,
count: u32,
},
PasswordRequired,
WrongPassword,
DataPending {
ranges: Vec<(u64, u64)>,
},
Source {
offset: u64,
len: u64,
},
Failed {
backend: &'static str,
stage: &'static str,
},
ExportFailed {
format: &'static str,
},
Unavailable {
backend: &'static str,
},
Cancelled,
}Expand description
Why a render backend refused a request or couldn’t render.
Every variant has a stable code from fixtures/codes.json: the new
ones under renderErrors, the rest reused from the groups that already define them
(page-index-out-of-range, password-required, wrong-password, data-pending, source,
cancelled, invalid-argument). Messages never contain text read from the document.
Added in 0.2.0.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TooLarge
The requested tile is bigger than RenderLimits allow
(render-too-large). Checked before anything is allocated.
Fields
InputTooLarge
The input is longer than RenderLimits::max_input_bytes for a
backend that reads the whole file into memory (render-too-large).
InvalidRequest
A request that can never be valid: a non-finite or non-positive scale, an empty tile, a
tile outside the page (invalid-argument).
BufferSize
The output buffer doesn’t have exactly the bytes the tile needs (invalid-argument).
Fields
expected: usizeThe bytes the tile needs (TilePlan::byte_len).
PageIndexOutOfRange
The page index is past the last page (page-index-out-of-range, ADR 0027: 0-based).
PasswordRequired
The document is encrypted and no password was given (password-required).
WrongPassword
The password given doesn’t open the document (wrong-password).
DataPending
The source hasn’t got these bytes yet: fetch them and call again (data-pending).
Source
The source failed to read these bytes (source).
Failed
The engine couldn’t open the document or render the page: a damaged or unsupported
file, or an engine failure (render-failed).
ExportFailed
An export’s encoder failed on a page that was drawn (export-failed): it writes into
memory, so this is a bug, never the document’s fault.
The engine isn’t available: the PDFium library couldn’t be found or bound
(render-backend-unavailable).
Cancelled
A CancelToken stopped the render (cancelled).
Implementations§
Source§impl RenderError
impl RenderError
Sourcepub const CODES: &'static [&'static str]
pub const CODES: &'static [&'static str]
The codes this crate adds to fixtures/codes.json (under renderErrors). The other
variants reuse codes defined by other groups.
Added in 0.2.0.
Sourcepub const fn error_code(&self) -> ErrorCode
pub const fn error_code(&self) -> ErrorCode
The variant’s entry in the generated ErrorCode table (one per entry of
fixtures/codes.json), which holds its code string, kind, hint and docsUrl.
Added in 0.2.0.
Sourcepub const fn code(&self) -> &'static str
pub const fn code(&self) -> &'static str
A stable kebab-case code for this error (ADR 0026 §1).
Added in 0.2.0.
Sourcepub fn diagnostic(&self) -> Diagnostic
pub fn diagnostic(&self) -> Diagnostic
The ADR 0026 §1 object: what a binding hands to another language. data holds the
fields each code’s docs/errors page lists; nothing in it is read from the document.
Added in 0.2.0.
Trait Implementations§
Source§impl Clone for RenderError
impl Clone for RenderError
Source§impl Debug for RenderError
impl Debug for RenderError
Source§impl Display for RenderError
impl Display for RenderError
impl Eq for RenderError
Source§impl Error for RenderError
impl Error for RenderError
1.30.0 · 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()