Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants Io(Error), EncryptedSaveUnsupported, PasswordNotText, NoEntropy, NoDestinationCatalog, PageIndexOutOfRange(PageIndex), BadPageRange, BadNupParams, Svg(Error), Subset(String), UnrecognisedFontProgram, EmptyFontProgram, EmptyToUnicodeCMap, BadCidToGidMap(usize), UnrecognisedImageData, EmptyImage, ImageDataLength { expected: usize, found: usize, }, MissingGlyph(MissingGlyph), InlinePage(PageIndex), Object(Error),
}
Expand description

A failure that stops the editor producing output.

Damage in the input is not an error here: a broken object silently vanishes from the output the way the C++ writer drops it, and every such recovery is recorded as a pdfrum_common::Diagnostic. Err is reserved for “cannot continue”.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io(Error)

The sink refused the bytes.

§

EncryptedSaveUnsupported

The document declares /Encrypt, this reader derived no key for it (an /Identity crypt filter, or a handler opened as pdfrum_crypt::SecurityHandler::Identity), and remove_security was not set. Re-declaring a cipher over plaintext would produce a file nothing could open.

§

PasswordNotText

A password given for a new encryption is not valid UTF-8, or does not survive SASLprep (ISO 32000-2 §7.6.4.3.3).

§

NoEntropy

The operating system’s cryptographic generator is unavailable, so the file key and AES vectors a new encryption needs cannot be drawn. Only an encrypting save can raise this; every other save needs no randomness it cannot derive.

§

NoDestinationCatalog

A document with no usable catalog cannot be the destination of an import: there is nowhere to attach the pages.

§

PageIndexOutOfRange(PageIndex)

A page index named by an import is outside the source document.

§

BadPageRange

A page-range string the grammar of ISO 32000 viewers accepts could not be parsed; the C++ treats one bad entry as discarding everything.

§

BadNupParams

N-up was asked for a grid or sheet size with a zero dimension.

§

Svg(Error)

Available on crate feature svg-import only.

An SVG would not resolve. Only produced with the svg-import feature, whose ingestion parses it.

§

Subset(String)

The font program could not be subset.

§

UnrecognisedFontProgram

The bytes are not a TrueType, OpenType, or Type 1 font program.

§

EmptyFontProgram

The program parsed but declares no glyphs.

§

EmptyToUnicodeCMap

A caller-supplied /ToUnicode CMap was empty.

The font it would write would carry no statement of what its codes mean. A caller who wanted a generated /ToUnicode should ask for FontEncoding::Composite instead.

§

BadCidToGidMap(usize)

A caller-supplied /CIDToGIDMap was empty, or was not a whole number of big-endian u16 entries.

[oracle-bug] ISO 32000-1 §9.7.4.2 defines /CIDToGIDMap as a stream of two-byte glyph indices, so a half-entry is not a map. Both the empty and the odd-length case are rejected here, before any of it is written.

§

UnrecognisedImageData

The bytes are not a JPEG or JPEG 2000 codestream a PDF may hold.

Raised when no JPEG header can be read, when the component count is not 1, 3 or 4, or when the sample precision is not 1, 2, 4, 8 or 16. The oracle reaches the same outcome by producing no stream at all; this is the same refusal with the reason attached.

§

EmptyImage

An image was asked for with a zero width or height.

§

ImageDataLength

The sample buffer is not the length the dimensions and pixel format require.

The oracle cannot reach this: its API takes a bitmap object that already knows its own pitch, so a short buffer is not expressible. Loose bytes are, and reading past them is not an option.

Fields

§expected: usize

Bytes the dimensions and format require.

§found: usize

Bytes the caller supplied.

§

MissingGlyph(MissingGlyph)

A drawing refused a character the font has no glyph for.

Raised by EmbeddedFont::encode_checked and by the facade’s canvas, which encodes through it. A blank where a glyph should be is a worse answer than a refusal, because nothing downstream can tell the two apart.

§

InlinePage(PageIndex)

A page written inline in its parent’s /Kids has no object of its own for an appended content stream to reach.

§

Object(Error)

An object the writer needed could not be fetched or made sense of.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<MissingGlyph> for Error

Source§

fn from(source: MissingGlyph) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.