Skip to main content

LoadAnomaly

Enum LoadAnomaly 

Source
#[non_exhaustive]
pub enum LoadAnomaly { DuplicateDictKey { object: Option<ObjId>, key: Vec<u8>, kept: Object, discarded: Object, }, StreamLengthRecovered { object: ObjId, }, MissingEndobjRecovered { object: ObjId, }, ObjectUnreadable { object: ObjId, reason: String, }, }
Expand description

One thing the file said that contradicted itself, and what pdfcer decided about it (Pass 283.0).

§The operator ruling this exists to satisfy

“We should be making pdfcer so that it opens pdfs that have errors, and have a way that it manages those errors such that they aren’t fatal, and if the user can intervene in a decision that should always be an option along with them not having to intervene.”

Three obligations in one sentence, and this type carries all three:

  1. Not fatal — the document loads.
  2. Intervention is possible — the record names the object, the key, the value kept and the value discarded, which is everything a shell needs to offer the operator the other choice and re-load with it (crate::parser::DuplicateKeyPolicy).
  3. Intervention is not required — pdfcer already picked, the default is documented, and a caller that never reads this list gets a working document.

It is a disclosure, not a prompt: project rule 4 as narrowed by decision 059 — the inferred value is live document state, and what pdfcer guessed is reported off to the side rather than gating the open.

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

DuplicateDictKey

One dictionary named the same key twice (§7.3.7) and pdfcer kept one of the values.

Both values are carried, not just the winner. A count would say that pdfcer chose; a shell offering the operator the choice needs to show what it chose between, and a report that cannot answer “what was the other one?” makes the intervention theoretical.

Fields

§object: Option<ObjId>

The object whose dictionary contradicted itself. None when the dictionary is the trailer, which is not an indirect object.

§key: Vec<u8>

The repeated key, e.g. PageMode.

§kept: Object

The value pdfcer KEPT — the last occurrence under the default policy.

§discarded: Object

The value pdfcer DISCARDED. A caller offering the choice presents this as the alternative; a caller re-loading under crate::parser::DuplicateKeyPolicy::KeepFirst gets it instead.

§

StreamLengthRecovered

A stream’s /Length was absent, non-integer, unresolvable or simply wrong, and pdfcer re-derived the data extent by scanning to endstream (§7.3.8.1).

/Length is REQUIRED by §7.3.8.2 Table 5, so this is a shall violation — and one every reader recovers from, because the keyword that ends the data is right there in the file. Refusing costs the whole document to preserve a number the file itself contradicts.

There is no operator choice to offer here, and that is not an oversight: the alternative to the scanned extent is no object at all. The record exists so the operator learns the file is damaged, not so a decision can be re-taken.

Fields

§object: ObjId

The object whose stream extent was re-derived.

§

MissingEndobjRecovered

An indirect object’s endobj keyword was missing and pdfcer accepted the definition anyway, ending it at the next object header (§7.3.10).

Same shape as Self::StreamLengthRecovered: a required keyword the file omits, an unambiguous end, and no second reading to choose between.

Fields

§object: ObjId

The object accepted without its terminator.

§

ObjectUnreadable

One object could not be loaded at all, and the document was loaded without it.

§Why this is continuing rather than guessing

§7.3.10 already defines what a reference to an object that is not there means: “An indirect reference to an undefined object shall not be considered an error by a conforming reader; it shall be treated as a reference to the null object.” An object whose bytes will not parse is an undefined object as far as every consumer is concerned — so omitting it is not a liberty pdfcer takes, it is the behaviour the standard prescribes for the state the file is in.

That is the whole difference between this and a repair: nothing is invented, and the resulting document is one the standard describes.

§What it replaces

DocError::BadObject, ObjectIdMismatch, ObjectStreamMissing, ObjectStream and ObjectStreamIdMismatch — five ways one bad object used to cost the whole document. They survive as errors under LoadOptions::strict.

There is no alternative to offer here either. The choice is between this object and no document, and reason is carried so the operator can see WHICH object and WHY rather than being told a count.

Fields

§object: ObjId

The object that could not be loaded.

§reason: String

Why, in the loader’s own words — the error that would have been returned.

Implementations§

Source§

impl LoadAnomaly

Source

pub const fn object(&self) -> Option<ObjId>

The object this anomaly is about, when it has one.

Source

pub const fn kind(&self) -> &'static str

A short stable token for machine-readable output.

Trait Implementations§

Source§

impl Clone for LoadAnomaly

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LoadAnomaly

Source§

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

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

impl PartialEq for LoadAnomaly

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LoadAnomaly

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.