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: boolRecord Info diagnostics for deprecated classes and attributes.
report_non_conforming_mrids: boolRecord a diagnostic for every identifier that is not a UUID.
max_diagnostics: usizeStop 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: u64Stop 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
impl ReadOptions
Sourcepub const DEFAULT_MAX_DIAGNOSTICS: usize = 10_000
pub const DEFAULT_MAX_DIAGNOSTICS: usize = 10_000
How many diagnostics one read records before it stops recording.
Sourcepub const DEFAULT_MAX_INPUT_BYTES: u64
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.
Sourcepub fn lenient() -> ReadOptions
pub fn lenient() -> ReadOptions
Tolerant defaults, suitable for real-world exchange files.
Sourcepub fn strict() -> ReadOptions
pub fn strict() -> ReadOptions
Fail on anything the schema does not describe, and report every deviation.
pub fn with_profile(self, profile: ProfileId) -> Self
Sourcepub fn with_max_diagnostics(self, max: usize) -> Self
pub fn with_max_diagnostics(self, max: usize) -> Self
Cap the number of diagnostics one read records. Zero means no limit.
Sourcepub fn with_max_input_bytes(self, max: u64) -> Self
pub fn with_max_input_bytes(self, max: u64) -> Self
Cap the bytes one load call accepts. Zero means no limit.