Skip to main content

LoadOptions

Struct LoadOptions 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§duplicate_keys: DuplicateKeyPolicy

Which 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: StreamLengthPolicy

What 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: TerminatorPolicy

What to do when an indirect object’s endobj is missing (§7.3.10).

Defaults to TerminatorPolicy::RecoverAtNextHeader.

§unreadable_objects: UnreadableObjectPolicy

What 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

Source

pub fn new() -> Self

The defaults: open the file, decide the contradictions, report them.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

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 Copy for LoadOptions

Source§

impl Debug for LoadOptions

Source§

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

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

impl Default for LoadOptions

Source§

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.

Source§

impl Eq for LoadOptions

Source§

impl PartialEq for LoadOptions

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
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, 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.