Expand description
§COS object model (ISO 32000-1 §7.3)
The value types of the Carousel Object System — the tree every PDF
is made of. Spec sources: iso32000__s__7.3.md (the eight basic
types, dictionary semantics, null), iso32000__s__7.3.10.md
(indirect objects and references), iso32000__s__7.3.8.md (streams)
in the PDF-spec RAG. Clause numbers are ISO 32000-1:2008.
§ONE object model (named invariant)
This is the only object representation in pdfcer-core: the parse result and the write source are the same types (docs/decisions/001-oxidize-pdf-adopt-vs-build.md §6.1 item 3, recorded in ARCHITECTURE.md §12). The audited failure mode this prevents: a read-only parser model plus a separate builder-only generation model whose bridge never gets built, making round-trip structurally impossible. Any future “builder” convenience API must construct these types.
§Value semantics vs provenance
Object is a plain value tree — no spans inside it. Provenance
lives one level up: an IndirectObject records where its
definition physically lives as a Provenance, and re-emission of
logically-untouched objects works from that (crate::span;
ARCHITECTURE.md §5). Within an object the operator did modify,
re-serialization from values is correct — §5 demands byte-identity
only for what was NOT touched. (Content streams get a finer-grained
span-per-token model in their own module, per decision 001 §6.1
item 2 — that is deliberately NOT this tree.)
Provenance is an enum, not a span, because PDF 1.5’s object
streams (§7.5.7) create objects that have no byte range of their own
in the file — see Provenance for the full reasoning.
§Normative behaviors encoded here
null-valued dictionary entry ≡ absent entry (§7.3.7/§7.3.9): collapsed inDict::get— one accessor, not a check at every call site.- Duplicate keys are malformed (§7.3.7 “shall not”) — the parser
rejects them at parse time (fail-clean), so
Dictnever holds duplicates from a parsed file. - Integer vs real is preserved (§7.3.3): two variants, never
collapsed to f64 —
4and4.0are different tokens with different re-serializations. - Generation numbers are part of object identity (§7.3.10):
ObjIdcarries both.
Structs§
- Dict
- A dictionary (§7.3.7): name-keyed, unordered per spec — but pdfcer preserves the parsed entry order so that re-serializing a modified dictionary perturbs sibling entries as little as possible (smaller diffs; the spec says written order “shall be ignored”, so preserving it is always safe).
- Indirect
Object - A parsed indirect object: identifier, value, and the provenance that makes minimal-diff re-emission possible.
- Name
- A PDF name (§7.3.5): the decoded byte sequence,
#-escapes already expanded, without the introducing/. - ObjId
- An indirect-object identifier: object number + generation number (§7.3.10 — “together … shall uniquely identify an indirect object”).
- Stream
- A stream object (§7.3.8): its dictionary plus the span of its encoded data bytes in the retained source buffer.
Enums§
- Object
- A COS object (§7.3.1’s eight basic types, plus the indirect reference, which is a value position in its own right per §7.3.10’s substitutability rule).
- Provenance
- Where an indirect object’s definition physically lives in the loaded file — the provenance discriminator the minimal-diff writer needs (ARCHITECTURE.md §5; decision 001 §6.1 item 1).
Functions§
- equivalent_
across_ buffers - Compare two objects that were parsed from different source buffers, ignoring where their stream data physically sits.