Skip to main content

ReadOptions

Struct ReadOptions 

Source
pub struct ReadOptions {
    pub strictness: Strictness,
    pub assume_profile: Option<ProfileId>,
    pub report_deprecated: bool,
    pub report_non_conforming_mrids: bool,
    pub max_diagnostics: usize,
    pub max_input_bytes: u64,
}
Expand description

Options controlling a read.

Fields§

§strictness: Strictness§assume_profile: Option<ProfileId>

Profile to attribute the data to when the header does not declare one.

§report_deprecated: bool

Record Info diagnostics for deprecated classes and attributes.

§report_non_conforming_mrids: bool

Record a diagnostic for every identifier that is not a UUID.

§max_diagnostics: usize

Stop recording after this many diagnostics. Zero means no limit.

Bounds the report’s memory on a corrupt or hostile document. Past the cap reading continues and the report ends with a note saying it was truncated.

§max_input_bytes: u64

Stop reading after this many bytes of input. Zero means no limit.

Counts the bytes the parser accepts (for a zip archive, the decompressed bytes), summed across one load call, so all files of a directory or archive share one budget. Past it the read fails with Error::InputTooLarge, never a diagnostic. Defaults to ReadOptions::DEFAULT_MAX_INPUT_BYTES, so a small archive that inflates enormously cannot demand unbounded memory.

Implementations§

Source§

impl ReadOptions

Source

pub const DEFAULT_MAX_DIAGNOSTICS: usize = 10_000

How many diagnostics one read records before it stops recording.

Source

pub const DEFAULT_MAX_INPUT_BYTES: u64

How many bytes one load call accepts by default: 8 GiB.

Four times the largest published model set — QoCDC’s pan-European TC4 merge, about 2 GiB decompressed. Raise it with ReadOptions::with_max_input_bytes.

Source

pub fn lenient() -> ReadOptions

Tolerant defaults, suitable for real-world exchange files.

Source

pub fn strict() -> ReadOptions

Fail on anything the schema does not describe, and report every deviation.

Source

pub fn with_profile(self, profile: ProfileId) -> Self

Source

pub fn with_max_diagnostics(self, max: usize) -> Self

Cap the number of diagnostics one read records. Zero means no limit.

Source

pub fn with_max_input_bytes(self, max: u64) -> Self

Cap the bytes one load call accepts. Zero means no limit.

Trait Implementations§

Source§

impl Clone for ReadOptions

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 Debug for ReadOptions

Source§

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

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

impl Default for ReadOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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