Skip to main content

DiagKind

Enum DiagKind 

Source
#[non_exhaustive]
pub enum DiagKind {
Show 102 variants HeaderOffset, BadStartXref, XrefRebuilt, XrefPrevLoop, XrefEntriesShifted, XrefStreamEntryDropped, RootRecovered, LengthMismatch, KeywordResync, MalformedDict, MalformedArray, StreamInCompositeDropped, ObjNumMismatch, ObjStmEntryDropped, UndecodableStream, PageTreeRepaired, PageTreeDepthExceeded, PasswordReencoded, CMapNameUnknown, CMapTableMissing, CMapUsecmapUnknown, CMapUsecmapDepth, CMapCodespaceDropped, CMapTruncatedCodespace, CMapReversedRange, CMapWideMappingsDropped, CMapRangeLimit, CMapOperandOverflow, Type1PfbTruncated, Type1HexTruncated, Type1EncodingGlyphMissing, Type1CharstringAborted, Type1BlendInconsistent, ToUnicodeBlockRejected, FontProgramUnreadable, CidToGidStreamShort, FontWidthsTruncated, GsubUnreadable, FontSubstitutionFailed, UnknownOperator, OperandsDropped, OperandCountMismatch, UnbalancedRestore, UnbalancedMarkedContent, FormRecursionRefused, InlineImageAbandoned, InlineImageResync, InlineImageUnsupported, BadTextRenderMode, DashPatternDropped, DashElementClamped, ColorSpaceUnsupported, IccAlternateUsed, IccStockFallback, IccAlternateMismatch, IndexedHivalClamped, TintTransformDropped, FunctionUnsupported, PostScriptStackAbuse, PostScriptMalformedProc, ShadingUnsupported, MeshDecodeMalformed, MeshTruncated, TilingStepInvalid, TilingRangeOverflow, ImageBadBitDepth, ImageBadDimensions, ImageDimensionsFromCodec, JpxColorSpaceOverride, ImageDecodeFailed, MaskDropped, ImageStreamTruncated, ColorKeyArrayShort, MediaBoxDefaulted, OptionalContentPolicyUnknown, TextObjectDegenerate, TextObjectDropped, TextObjectDuplicate, TextCharcodesUnmapped(u32), TextCharcodeZero, TextActualTextUnprintable, TextActualTextCharDropped, TextHyphenNoPrevChar, NavigationCycle, TreeDepthExceeded, NameTreeLimitsRepaired, NameTreeMalformed, LegacyNamedDest, DestPageUnresolved, AnnotSubtypeUnknown, AppearanceGenerated, QuadPointsTruncated, InkPathDropped, DefaultAppearanceMalformed, FormResourcesInvalid, FieldSkippedNoType, FieldSkippedNoName, StructElementDropped, PageLabelStyleUnknown, ScriptLimitReached, ScriptFailed, TimeLimitReached,
}
Expand description

What was repaired.

Grows as each crate lands, but a variant earns its place by having a recording site: it names a condition some crate actually detects and recovers from, and there is a record call to prove it. #[non_exhaustive] makes both directions non-breaking, and the enum has shrunk as well as grown: a variant is added when a port reaches the condition, not before.

A variant with no recording site is worse than no variant: it reads as a promise that Document::diagnostics() reports the condition, and a caller matching on it waits for a row that never comes.

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

HeaderOffset

The %PDF- header was not at offset 0; the given offset became the origin for every offset in the file.

§

BadStartXref

startxref was missing or pointed at something that is not a cross-reference section.

§

XrefRebuilt

The cross-reference table was rebuilt by scanning the whole file.

§

XrefPrevLoop

The /Prev chain of cross-reference sections looped back on itself.

§

XrefEntriesShifted

A cross-reference table’s entries did not agree with the objects found at the offsets they name.

§

XrefStreamEntryDropped

A cross-reference stream entry was dropped (bad field type, generation beyond u16, or a segment running past the stream).

§

RootRecovered

The trailer’s /Root was missing or unusable and the catalog was found another way.

§

LengthMismatch

A stream’s /Length did not match the bytes before endstream.

§

KeywordResync

An endstream/endobj keyword was missing and the reader resynced.

§

MalformedDict

A dictionary body was malformed: closed by endobj, or a key/value pair was unparsable and skipped.

§

MalformedArray

An array element was unparsable and the array was kept partially.

§

StreamInCompositeDropped

A stream appeared as a dictionary value or array element, which ISO 32000-1 §7.3.8.1 forbids; it was dropped.

§

ObjNumMismatch

The object at a cross-reference offset carried a different object number than the table claimed.

§

ObjStmEntryDropped

An object-stream offset pair was garbage and that entry was skipped.

§

UndecodableStream

A stream’s filter chain was invalid, so the raw bytes were used.

§

PageTreeRepaired

The page tree needed repair: a guessed /Type, a wrong /Count, or a kid that pointed back at an ancestor.

§

PageTreeDepthExceeded

The page tree was deeper than the depth cap and the walk stopped.

§

PasswordReencoded

The password was accepted only after re-encoding it.

§

CMapNameUnknown

An /Encoding named no built-in CMap; the font fell back to two-byte codes mapped to themselves.

§

CMapTableMissing

An /Encoding name matched a known CMap family but no built-in table carries that exact name, so the decoder is right and the CID map is not.

§

CMapUsecmapUnknown

An embedded CMap’s usecmap, or a stream’s /UseCMap, named a CMap that is not one of the built-in ones, so nothing was inherited.

§

CMapUsecmapDepth

A /UseCMap chain ran deeper than Limits::max_name_tree_depth; the rest of the chain was not followed.

§

CMapCodespaceDropped

A codespace range’s bounds were discarded: a block declaring exactly one range keeps only its width.

§

CMapTruncatedCodespace

A codespace bound had no closing > and was read at whatever width its digits implied.

§

CMapReversedRange

A begincidrange named a start code above its end code, so it mapped nothing.

§

CMapWideMappingsDropped

Character-code mappings at or above 0x1_0000 were dropped because the CMap’s coding scheme cannot produce codes that wide.

§

CMapRangeLimit

A CMap program declared more ranges than Limits::max_cmap_ranges allows; the rest were dropped.

§

CMapOperandOverflow

More operands arrived for one CMap construct than it takes.

§

Type1PfbTruncated

A PFB container’s segment chain ended early: a length running past the blob, a missing 0x80 marker, or no end-of-file record. The segments read so far were kept.

§

Type1HexTruncated

A PFA font program’s hexadecimal private section ended at a byte that is not a hex digit, so the tail was dropped.

§

Type1EncodingGlyphMissing

A Type 1 /Encoding entry named a glyph the /CharStrings dictionary does not define, so that character code maps to nothing.

§

Type1CharstringAborted

A Type 1 charstring could not be interpreted to completion — an unknown operator, a stack underflow, a missing subroutine, or a recursion depth cap. Whatever path had been built is kept.

§

Type1BlendInconsistent

A Multiple-Master font’s /WeightVector, /BlendDesignPositions, /BlendDesignMap and /BlendAxisTypes did not agree on the number of axes or masters, so the font was treated as non-variable.

§

ToUnicodeBlockRejected

A /ToUnicode bfchar or bfrange block declared a different number of entries than it contained, or contained a character code the format cannot express, so every mapping in that block was discarded.

§

FontProgramUnreadable

An embedded font program could not be read by any backend, so the font was treated as if it had none and went to substitution.

§

CidToGidStreamShort

A /CIDToGIDMap stream was shorter than the CIDs indexing into it, so glyphs past its end resolve to nothing.

§

FontWidthsTruncated

A /W, /W2 or /Widths array was malformed and parsing stopped early or dropped a record; the widths read so far were kept.

§

GsubUnreadable

An OpenType GSUB table could not be read, so vertical glyph substitution is unavailable and upright forms are drawn instead.

§

FontSubstitutionFailed

No system or embedded face could be found for a font, and even the built-in fallback failed to parse.

§

UnknownOperator

A content-stream keyword named no operator; it and its operands were dropped.

§

OperandsDropped

More than sixteen operands accumulated before one operator, so the oldest were evicted and the rest silently renumbered.

§

OperandCountMismatch

An operator that demands an exact operand count did not get it, so it did nothing at all.

§

UnbalancedRestore

A Q arrived with no matching q; the graphics state was left alone.

§

UnbalancedMarkedContent

An EMC arrived with no matching BMC/BDC.

§

FormRecursionRefused

A form XObject was refused because it re-entered a content buffer already being parsed, or because too many parses were in flight. The stream was consumed and contributed no objects.

§

InlineImageAbandoned

A BI was followed by a keyword other than ID, so the inline image was abandoned and the bytes re-read as ordinary content.

§

InlineImageResync

The scan for an inline image’s EI absorbed bytes past the end of its inferred sample data.

§

InlineImageUnsupported

An inline image named a filter whose length cannot be inferred (JPXDecode, JBIG2Decode, or an unknown name), so it produced nothing.

§

BadTextRenderMode

A Tr operand outside 0..=7 was ignored, leaving the previous text rendering mode in place.

§

DashPatternDropped

A dash pattern was abandoned in favour of a solid line: an element was not finite, or the whole cycle fell below the device threshold.

§

DashElementClamped

A dash element at or below one part in a million was replaced by 0.1.

§

ColorSpaceUnsupported

A colorspace could not be built, so the operator naming it did nothing.

§

IccAlternateUsed

An ICC profile was not usable and its /Alternate space was used instead.

§

IccStockFallback

An ICC profile was not usable and no /Alternate served, so the stock device space for its /N was used.

§

IccAlternateMismatch

An ICC space’s /Alternate declared a different component count than its /N, so the alternate was discarded.

§

IndexedHivalClamped

An /Indexed space’s /hival was outside 0..=255 and was clamped.

§

TintTransformDropped

A Separation space’s tint transform failed to load or produced too few outputs; the space kept working without it.

§

FunctionUnsupported

A function could not be built, so whatever named it has no transform.

§

PostScriptStackAbuse

A PostScript calculator program pushed past its stack or popped an empty one; the values involved were dropped or read as zero.

§

PostScriptMalformedProc

A PostScript if or ifelse was not preceded by the procedures it needs, aborting that procedure.

§

ShadingUnsupported

A shading failed validation and paints nothing.

§

MeshDecodeMalformed

A mesh shading’s /Decode array was not exactly the length its component count requires.

§

MeshTruncated

A mesh stream ran out mid-record; the vertices read so far were kept.

§

TilingStepInvalid

A tiling pattern’s /XStep or /YStep was zero or not finite, so it draws nothing.

§

TilingRangeOverflow

A tiling pattern’s tile indices did not fit an i32, so it draws nothing.

§

ImageBadBitDepth

An image’s /BitsPerComponent was not one of 1, 2, 4, 8 or 16.

§

ImageBadDimensions

An image’s /Width or /Height was zero, negative, or beyond the dimension cap.

§

ImageDimensionsFromCodec

A codec reported dimensions differing from the image dictionary’s, and the codec’s were used.

§

JpxColorSpaceOverride

A JPEG 2000 codestream’s own colour space replaced the one the image dictionary named.

§

ImageDecodeFailed

A codec refused an embedded image, so it paints nothing.

§

MaskDropped

An image’s mask could not be loaded; the base image was kept unmasked.

§

ImageStreamTruncated

An image’s sample data ended before its last scanline; the remainder was zero-filled.

§

ColorKeyArrayShort

A colour-key /Mask array held fewer than two entries per component, so the ranges it did not state default to zero.

§

MediaBoxDefaulted

A page’s /MediaBox was missing or empty, so US Letter was used.

§

OptionalContentPolicyUnknown

An optional-content membership dictionary named a /P policy that is none of the four defined ones, which makes its content invisible.

§

TextObjectDegenerate

A text object’s bounding box had no width, so the object was dropped whole and contributed no characters.

§

TextObjectDropped

A text object was dropped because the one before it showed no glyphs — a quirk of the batching, not a property of the dropped object.

§

TextObjectDuplicate

A text object repeated one of the five text objects before it closely enough to be a redraw, and was dropped.

§

TextCharcodesUnmapped(u32)

Character codes in one text object had no Unicode mapping and were emitted as raw code points. Carries how many, because a font with a broken /ToUnicode would otherwise record one per character and flood the sink.

§

TextCharcodeZero

Character code zero appeared, which emits a NUL into the character stream and nothing into the text.

§

TextActualTextUnprintable

A marked-content /ActualText held no printable character, so the object it covered emitted nothing at all.

§

TextActualTextCharDropped

An /ActualText character at or above U+FFFD was skipped, though the box progression still stepped past it.

§

TextHyphenNoPrevChar

A soft hyphen was called for with no preceding character to attach it to. The C++ dereferences an empty container here; we emit nothing.

§

NavigationCycle

An outline, /Next action chain, or field /Parent walk revisited a node it had already seen; the walk stopped there.

§

TreeDepthExceeded

A name, number, structure or field tree exceeded its depth cap. The lookup answers “not found” rather than recursing further.

§

NameTreeLimitsRepaired

A name-tree node’s /Limits array was shorter than two entries, or held its bounds the wrong way round, and was read as repaired.

§

NameTreeMalformed

A name-tree leaf’s /Names array had an odd length, so its last key has no value.

§

LegacyNamedDest

A named destination resolved only through the pre-1.2 /Dests dictionary, not the name tree.

§

DestPageUnresolved

A destination’s page could not be turned into an index.

§

AnnotSubtypeUnknown

An annotation’s /Subtype matched no known spelling.

§

AppearanceGenerated

An appearance stream was generated for an annotation that had none.

§

QuadPointsTruncated

A /QuadPoints array’s length is not a multiple of eight; the tail is ignored.

§

InkPathDropped

An /InkList sub-array was too short to draw, or had an odd length.

§

DefaultAppearanceMalformed

A /DA string held no Tf operator, so the font name is empty and the size is zero.

§

FormResourcesInvalid

/DR /Font is not a dictionary of font dictionaries, so no form appearance can be generated.

§

FieldSkippedNoType

A form field carries no /FT on itself or its parent.

§

FieldSkippedNoName

A form field’s fully-qualified name came out empty, so it was dropped: the name is a field’s identity and its only address.

§

StructElementDropped

A structure element was dropped: its page did not match, or its parent could not be linked.

§

PageLabelStyleUnknown

A page label’s /S names no known numbering style, so the label is its prefix alone.

§

ScriptLimitReached

A document’s script exhausted one of the Limits script bounds — loop iterations, recursion depth or stack — and was stopped.

The hook it was running then takes its refusing answer, not its permissive one: a script that ran out of budget did not say “accept”, and inventing an acceptance on its behalf is what would let a hostile file walk past a validator. A build without the script feature can never record this.

§

ScriptFailed

A document’s script threw, or would not parse, and was abandoned.

An ordinary outcome for untrusted input rather than an error: the rest of the document is unaffected, and the hook takes its refusing answer for the same reason as DiagKind::ScriptLimitReached.

§

TimeLimitReached

Limits::deadline passed inside an operation that cannot fail — the content interpreter or the text extractor — which stopped where it was and returned what it had. The result is partial: the objects before the stop, or an empty text page.

Recorded once per stop. The fallible entry points (open, page load, render) answer LimitExceeded::Time instead of recording this, so a render that fails on the deadline still carries the interpreter’s record of where the build stopped.

Implementations§

Source§

impl DiagKind

Source

pub fn message(&self) -> &'static str

One lower-case clause naming what was repaired, for a human reading a report.

The Debug spelling is the variant identifier and is what --json carries, because a machine consumer wants a token that survives rewording; this is the other half, and the two are deliberately not interchangeable.

The match is exhaustive with no wildcard arm: #[non_exhaustive] binds downstream crates, not this one, so a variant added without a clause here fails to compile. That is the point — it is the same gate the enum’s own doc comment asks for, applied to the wording.

use pdfrum_common::DiagKind;

assert_eq!(
    DiagKind::XrefRebuilt.message(),
    "cross-reference table rebuilt by scanning the file",
);

Trait Implementations§

Source§

impl Clone for DiagKind

Source§

fn clone(&self) -> DiagKind

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 DiagKind

Source§

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

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

impl Display for DiagKind

Source§

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

The message clause, with any count the variant carries appended: character codes had no Unicode mapping (3).

Source§

impl Eq for DiagKind

Source§

impl Hash for DiagKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DiagKind

Source§

fn eq(&self, other: &DiagKind) -> 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 DiagKind

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.