Skip to main content

Module leniency

Module leniency 

Source
Expand description

Thread-local decode-leniency event collector.

Inner parser and filter code calls [emit] to record a recovery or leniency event without changing any behaviour. A caller that wants to observe events wraps its work with activate / drain:

pdf_syntax::leniency::activate();
let pdf = Pdf::new(bytes)?;                 // events accumulate here
let events = pdf_syntax::leniency::drain(); // returns them and resets

When no collector is active every [emit] call is a no-op — zero heap allocation on the hot path. Per-code deduplication prevents a single corrupt stream from producing thousands of identical events.

Structs§

LeniencyEvent
A single decode-leniency or structural-recovery event.

Enums§

LeniencySeverity
Severity of a LeniencyEvent.

Constants§

ASCII85_LENIENT_PARTIAL
ASCII-85: a 1-character terminal group was accepted leniently.
CCITT_PARTIAL_DECODE
CCITT: partial row decode — at least one row decoded before an error.
FLATE_BAD_BLOCK
A bad block header was encountered inside a flate stream.
FLATE_BROKEN_FALLBACK
Flate stream broken; decoded with a pure-Rust fallback.
INDIRECT_CYCLE
A cycle was detected in indirect object references.
INDIRECT_DEPTH_EXCEEDED
Indirect object resolution depth exceeded the 512-level limit.
LZW_INVALID_CODE
An invalid code was encountered in an LZW stream.
LZW_PREMATURE_EOF
Premature EOF in an LZW stream; the EOD code was absent.
STREAM_PARSE_FALLBACK
Stream parse failed; a manual fallback parser was used.

Functions§

activate
Activate the thread-local collector on the current thread.
drain
Drain all accumulated events and deactivate the collector.