Skip to main content

LoadedXref

Struct LoadedXref 

Source
#[non_exhaustive]
pub struct LoadedXref { pub table: XrefTable, pub trailer: Dict, pub startxref: u64, pub newest_shape: SectionShape, pub highest_object_number: u32, pub suppressed_by_size: usize, pub hidden_objects: BTreeSet<u32>, pub hybrid_stream_unreadable: bool, }
Expand description

Result of a successful chain load: the merged table, the newest trailer dictionary, and the physical facts a minimal-diff writer needs about the newest section.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§table: XrefTable

Merged object-number → entry map (newest wins, /Size-filtered).

§trailer: Dict

The trailer dictionary of the NEWEST section — the one whose /Root//Info//Encrypt govern the document (§7.5.5 load algorithm step 9).

§startxref: u64

The byte offset the file’s own startxref names (§7.5.5).

This is the exact value an appended update’s /Prev must carry — §7.5.6 Q2: “the location of the previous cross-reference section”, i.e. the section this update supersedes, which is the one startxref currently points at. Deriving it from the base trailer’s own /Prev instead is the classic off-by-one-revision bug.

§newest_shape: SectionShape

The physical form of the newest section — see SectionShape.

§highest_object_number: u32

The highest object number the chain mentions before the /Size filter runs.

§Why the unfiltered number has to be kept

/Size is a hard reader-side filter (Table 15, §7.5.5), so a file whose /Size under-reports loads with those entries invisible — and a writer that allocates a “new” object number from the filtered view will happily pick a number the file already defines. The result is an update section whose entry collides with a live one, which is the worst failure shape available: a file that looks fine and resolves an object to the wrong bytes.

Found by the writer_roundtrip fuzz target on a corpus file carrying /Size 3 over six real entries.

§suppressed_by_size: usize

How many entries the /Size filter removed.

Non-zero means the file is hiding cross-reference entries behind an under-reported /Size. That matters to the writer beyond diagnostics: raising /Size — which any object creation does — would expose every one of them, resurrecting objects the operator never touched and which may not even parse. See crate::document::Document::suppressed_object_count.

§hidden_objects: BTreeSet<u32>

The object numbers whose winning cross-reference entry came from a hybrid file’s /XRefStm stream rather than from any classic table (§7.5.8.4) — the file’s hidden objects (Pass 281.0).

§Why this has to be retained rather than re-derived

§7.5.8.4 describes a three-part unit a writer “creates … at the same time”: a main classic table where the hidden objects are free with generation 65535, an update section, and a cross-reference stream that gives their real locations. To rewrite such a file, a writer must know which objects belong on which side.

The alternative — re-deriving hiddenness from §7.5.8.4’s recursive visibility rule (“the root … shall not be hidden, nor any object that is visible from the root”) — answers a different question. That rule says what a producer is allowed to hide; this set records what this file did hide. A file may legally hide less than it could, and a rewrite that re-derived the maximum would move objects the operator never touched from one side of the partition to the other, which is precisely the “plausible, working, wrong file” R33 exists to prevent.

Empty for every non-hybrid file, and empty for a hybrid file whose /XRefStm did not parse — the writer distinguishes those two cases, because the second one means the partition is unknown rather than absent.

§hybrid_stream_unreadable: bool

Whether the newest section named an /XRefStm that pdfcer could not parse (Pass 281.0).

A broken /XRefStm is deliberately not fatal to loading — the module docs explain why (§7.5.8.4 guarantees the visible graph is resolvable without it), and every hidden object is optional by construction. It is fatal to a full rewrite: the file says it hides objects, pdfcer cannot say which, and emitting either partition would be a guess. crate::writer::WriteError::HybridFullRewrite keeps that case.

Implementations§

Source§

impl LoadedXref

Source

pub fn hybrid_partition(&self) -> HybridPartition

This file’s §7.5.8.4 partition, as one value for the writer (Pass 281.0).

Trait Implementations§

Source§

impl Clone for LoadedXref

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 LoadedXref

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for LoadedXref

§

impl Freeze for LoadedXref
where *const u8 is !null: Freeze, PhantomData<(u32, XrefEntry)>: Freeze, PhantomData<(Name, Object)>: Freeze, *const LeafNode<u32, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(u32, SetValZST)>>: Freeze,

§

impl Move for LoadedXref

§

impl RefUnwindSafe for LoadedXref

§

impl Send for LoadedXref
where RawTable<(u32, XrefEntry)>: Send, RawVecInner: Send, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Send, BoxRaw<(u32, SetValZST)>: Send,

§

impl Sync for LoadedXref
where RawTable<(u32, XrefEntry)>: Sync, RawVecInner: Sync, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Sync, BoxRaw<(u32, SetValZST)>: Sync,

§

impl Unpin for LoadedXref
where *const u8 is !null: Unpin, *const LeafNode<u32, SetValZST> is !null: Unpin, Box<(u32, SetValZST)>: Unpin,

§

impl UnsafeUnpin for LoadedXref
where *const u8 is !null: UnsafeUnpin, PhantomData<(u32, XrefEntry)>: UnsafeUnpin, PhantomData<(Name, Object)>: UnsafeUnpin, *const LeafNode<u32, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u32, SetValZST)>>: UnsafeUnpin,

§

impl UnwindSafe for LoadedXref
where HashMap<u32, XrefEntry>: UnwindSafe, RawVecInner: UnwindSafe, BTreeMap<u32, SetValZST>: UnwindSafe,

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.