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.

Lenient reading answers a malformed document with a diagnostic rather than an error, which means the report is proportional to how broken the input is: a file whose every element is unknown produces one finding per element, each carrying several owned strings. On a hostile or merely corrupt hundred-megabyte document that is memory the caller never asked for. Past the cap the reader keeps reading and stops recording, closing the report with a note saying so, so nothing is silently truncated. Zero means no limit.

§max_input_bytes: u64

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

The bytes counted are the ones the parser accepts — for a zip archive, the decompressed bytes of its entries — summed across one load call, so a directory or an archive of many entries shares one budget. Past it the read fails with Error::InputTooLarge, never with a diagnostic: what was read is not the model.

The default, ReadOptions::DEFAULT_MAX_INPUT_BYTES, is there because a dataset grows linearly in what it accepts, so without one a 2 MB archive that inflates to 50 GB is a request for 50 GB of 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: 2 GiB.

The largest document either published conformity corpus contains is 80 MB (RealGrid_EQ.xml) and the largest model set about 112 MiB, so this is roughly eighteen times the biggest real input there is — room for merged pan-European models, and still a bound. 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.