#[non_exhaustive]pub struct LoadOptions {
pub duplicate_keys: DuplicateKeyPolicy,
pub stream_lengths: StreamLengthPolicy,
pub terminators: TerminatorPolicy,
pub unreadable_objects: UnreadableObjectPolicy,
}Expand description
How to load a document that contradicts itself (Pass 283.0).
§Why this type exists rather than a global setting
The operator’s ruling has two halves that pull in opposite directions:
a file with errors must open without intervention, and intervening must
always be possible. A default plus this struct is how both hold at once
— Default is what every existing caller already gets, and a shell that
wants to offer the operator a choice re-loads the same bytes with a
different policy and shows the difference.
Re-loading rather than patching in place is deliberate: a decision made during parsing is not a value that can be edited afterwards, because the discarded one was never built into the document. Carrying both would make every dictionary lookup ambiguous for the life of the session to serve a case that is one keystroke away from being re-read.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.duplicate_keys: DuplicateKeyPolicyWhich value wins when one dictionary names a key twice (§7.3.7).
Defaults to crate::parser::DuplicateKeyPolicy::KeepLast — see that
type for why last, and Document::load_anomalies for how a caller
learns a choice was made at all.
stream_lengths: StreamLengthPolicyWhat to do when a stream’s /Length cannot be used (§7.3.8.2).
Defaults to StreamLengthPolicy::RecoverFromEndstream, which only
acts when the stored value is unusable. Set
StreamLengthPolicy::Strict to refuse such a file instead.
terminators: TerminatorPolicyWhat to do when an indirect object’s endobj is missing (§7.3.10).
Defaults to TerminatorPolicy::RecoverAtNextHeader.
unreadable_objects: UnreadableObjectPolicyWhat to do when one object cannot be loaded at all.
Defaults to UnreadableObjectPolicy::TreatAsUndefined — §7.3.10’s
own answer for an object that is not there.
Implementations§
Source§impl LoadOptions
impl LoadOptions
Sourcepub const fn strict() -> Self
pub const fn strict() -> Self
Refuse every malformation instead of deciding it — the pre-Pass 283.0
behaviour, kept reachable.
For a caller whose job is to say whether a file is well-formed rather than to open it: a conformance checker, a fuzz harness, a gate.
Sourcepub const fn with_duplicate_keys(self, policy: DuplicateKeyPolicy) -> Self
pub const fn with_duplicate_keys(self, policy: DuplicateKeyPolicy) -> Self
Take the OTHER value for every duplicated key — the operator’s intervention, applied by re-loading the same bytes.
Trait Implementations§
Source§impl Clone for LoadOptions
impl Clone for LoadOptions
impl Copy for LoadOptions
Source§impl Debug for LoadOptions
impl Debug for LoadOptions
Source§impl Default for LoadOptions
impl Default for LoadOptions
Source§fn default() -> Self
fn default() -> Self
NOT the derived default. DuplicateKeyPolicy’s own Default is
Refuse, which is right for a parser and wrong for a loader: deriving
here would make LoadOptions::default() refuse the very files this
Pass exists to open, and the two types would silently disagree about
what “default” means.