Skip to content

Remove ResolvedObject and Dictionary::get_or_err - #604

Merged
Velli20 merged 2 commits into
mainfrom
remove-resolved-object-and-get-or-err
Oct 25, 2026
Merged

Velli20 merged 2 commits into
mainfrom
remove-resolved-object-and-get-or-err

Conversation

@Velli20

@Velli20 Velli20 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove ResolvedObject. It only wrapped a PdfObject and re-checked that it was not a reference, which the resolve loop already guarantees. ObjectAccess::resolve, DictionaryContext::resolve_entry and the context resolve now return PdfObject.
  • Remove unused code: the FromPdfObject impls for ResolvedObject and PdfObject, PdfObject::reference, and ObjectVariant::try_object_number.
  • Read required entries in one call. Dictionary::get_or_err is removed. Its callers used it as reader.read::<T>(dictionary.get_or_err(key)?) and now use:
    • ObjectReader::required::<T>(dictionary, key) for a dictionary the caller holds (stream /Length, trailer /Root)
    • DictionaryContext::new(dictionary, access), now public like ArrayContext::new, for a second dictionary inside a decoder (/CF crypt filters)
    • EncryptObjectLoader::required for the trailer /ID
    • page_tree.rs reads /Type with required and dispatches through ObjectContext::decode instead of calling from_pdf_object directly.

Behavior change

A missing required key now reports ObjectReadError::MissingDictionaryKey with the entry's location, instead of ObjectError::MissingRequiredKey. The missing-/ID test assertion is updated to match. Conformance groups failures by message, so documents missing /Root, /Length or /ID may get new issue keys.

Test plan

  • cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace, excluding pdf-conformance and pdf-graphics-skia, which could not build locally because they need a Skia download; CI covers them
  • cargo fmt --check

🤖 Generated with Claude Code

Velli20 and others added 2 commits October 25, 2026 16:35
ResolvedObject only wrapped a PdfObject and re-checked that it was not a
reference, which the resolve loop already guarantees. Resolution now
returns PdfObject directly. The unused FromPdfObject impls for both
types, PdfObject::reference and ObjectVariant::try_object_number are
removed.

Required entries are read in one call instead of a raw get_or_err
lookup followed by a typed read: ObjectReader::required reads an entry
of a dictionary the caller holds, and DictionaryContext::new binds such
a dictionary to an active traversal, like ArrayContext::new. A missing
key now reports MissingDictionaryKey with the entry's location instead
of ObjectError::MissingRequiredKey.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Velli20
Velli20 merged commit 51ba721 into main Oct 25, 2026
10 checks passed
@Velli20
Velli20 deleted the remove-resolved-object-and-get-or-err branch October 25, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant