Skip to main content

TerminatorPolicy

Enum TerminatorPolicy 

Source
#[non_exhaustive]
pub enum TerminatorPolicy { Strict, RecoverAtNextHeader, }
Expand description

What to do when an indirect object’s endobj keyword is missing.

§7.3.10 requires a definition to be N G obj … endobj, so a body that runs straight into the next N G obj header is malformed. But the object itself may have parsed perfectly — the damage is a missing four-byte keyword, not a corrupt value — and refusing it costs the operator the whole object.

The default is and must stay TerminatorPolicy::Strict, for the same reason StreamLengthPolicy::Strict is: on a cleanly-loading file a missing endobj is real damage the operator should hear about, and accepting it would put an inferred extent into the writer’s byte-identical re-emission path and break the round-trip/minimal-diff invariant (ARCHITECTURE.md §5).

§Why the lenient policy exists

It was added 2026-08-07 after the veraPDF parse gate found pdfcer writing a document whose catalog said /Pages 2 0 R while object 2 was absent from the file. The input (qpdf’s bad6.pdf) omits exactly one endobj — the one after the /Pages node — so confirm_candidates dropped the object as unparseable and the writer emitted a catalog pointing at nothing. veraPDF could recover the original and could not recover pdfcer’s rewrite of it, which is a document made strictly worse by passing through pdfcer.

Like StreamLengthPolicy::RecoverFromEndstream, this is reachable only from the rebuild-by-scan recovery path, where the file’s cross-reference machinery has already been proven unparseable and no byte-identical re-emission is on the table.

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

Strict

A missing endobj is ParseErrorKind::MissingEndobj. The default, and the only policy the clean load path ever uses.

§

RecoverAtNextHeader

Accept a definition whose body parsed cleanly but whose endobj is missing, provided the terminator looks like the start of the next object header (an integer) or the buffer ended.

The integer guard is what keeps this from swallowing arbitrary garbage: 2 0 obj << … >> 3 0 obj recovers, while a body followed by an unexpected keyword still fails. Every such repair is counted in Parser::missing_endobj_recovered so it can be disclosed (R20, fuzzy-never-sneaky) rather than silently absorbed.

Trait Implementations§

Source§

impl Clone for TerminatorPolicy

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 Copy for TerminatorPolicy

Source§

impl Debug for TerminatorPolicy

Source§

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

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

impl Default for TerminatorPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for TerminatorPolicy

Source§

impl PartialEq for TerminatorPolicy

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 TerminatorPolicy

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.