Expand description
PDF syntax layer: byte sources, the file header, the lexer and object parser, the cross-reference table, stream filters, decryption and repair.
Every input is untrusted (docs/PLAN.md §2): nothing here panics on any
bytes, every resource is bounded by Limits, and all reads go through
the injected Source trait rather than touching the filesystem.
Re-exports§
pub use crypt::Entropy;pub use crypt::Permissions;
Modules§
- crypt
- The standard security handler, read side (ISO 32000-2 §7.6).
- filters
- Stream filters (ISO 32000-2 §7.4).
- lexer
- Tokenizer for PDF syntax (ISO 32000-2 §7.2), also used for content streams.
- parser
- Object parser on top of the
Lexer. - serialize
- Writing objects back as PDF syntax.
- xref
- Cross-reference sections: classic tables and xref streams (§7.5.4, §7.5.8).
Structs§
- Diagnostic
- One repair, with where it happened.
- Diagnostics
- A shared, append-only list of diagnostics, capped so a hostile file cannot grow it without bound.
- Dict
- A dictionary. Keys are kept sorted, so iteration (and anything written from it) is deterministic. A repeated key keeps its last value.
- File
- A PDF file opened for reading. Objects are parsed on first access and cached; the file itself is never modified.
- Header
- A located file header.
- Limits
- Limits applied while reading. Every one is enforced; exceeding one is an
error (
crate::Error::Limit), never a panic or unbounded work. - Name
- A name object, without its leading
/and with#xxescapes resolved. - ObjId
- An indirect object’s identity: object number and generation.
- Open
Options - How to open a file.
- PdfString
- A string object’s bytes, and whether it was written in hex.
- Source
Error - A
Sourcefailed to serve a read. - Stream
- A stream: its dictionary and its bytes exactly as stored in the file, still encoded and (if the file is encrypted) still encrypted.
- Version
- A PDF version as written in the header, e.g.
1.7.
Enums§
- Diagnostic
Kind - What was repaired or tolerated.
- Error
- Everything that can go wrong in the syntax layer.
- Header
Error - Why no header could be read.
- Limit
Kind - Which limit was exceeded.
- Object
- Any PDF object.
- Strictness
- Whether malformed input may be repaired.
Constants§
- HEADER_
SEARCH_ WINDOW - How far into a file the header is looked for.
Traits§
- Budget
- A CPU budget hook: work is charged in abstract units (roughly, bytes or
objects processed), and the hook stops processing by returning
false. - Sink
- Where a saved document is written. Like
crate::Source, it keeps the core crates free of ambient I/O: the host decides whether bytes go to memory, a file or a socket. - Source
- Random-access bytes a document is read from.
Functions§
- find_
header - Finds the
%PDF-M.mheader in the firstHEADER_SEARCH_WINDOWbytes.
Type Aliases§
- Result
- The syntax layer’s result type.
- Shared
Source - A source that can be shared across threads.