Repository navigation
Remove ResolvedObject and Dictionary::get_or_err - #604
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ResolvedObject. It only wrapped aPdfObjectand re-checked that it was not a reference, which the resolve loop already guarantees.ObjectAccess::resolve,DictionaryContext::resolve_entryand the contextresolvenow returnPdfObject.FromPdfObjectimpls forResolvedObjectandPdfObject,PdfObject::reference, andObjectVariant::try_object_number.Dictionary::get_or_erris removed. Its callers used it asreader.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 likeArrayContext::new, for a second dictionary inside a decoder (/CFcrypt filters)EncryptObjectLoader::requiredfor the trailer/IDpage_tree.rsreads/Typewithrequiredand dispatches throughObjectContext::decodeinstead of callingfrom_pdf_objectdirectly.Behavior change
A missing required key now reports
ObjectReadError::MissingDictionaryKeywith the entry's location, instead ofObjectError::MissingRequiredKey. The missing-/IDtest assertion is updated to match. Conformance groups failures by message, so documents missing/Root,/Lengthor/IDmay get new issue keys.Test plan
cargo check --workspace --all-targetscargo clippy --workspace --all-targets -- -D warningscargo test --workspace, excludingpdf-conformanceandpdf-graphics-skia, which could not build locally because they need a Skia download; CI covers themcargo fmt --check🤖 Generated with Claude Code