pub struct StepReader { /* private fields */ }Expand description
A STEP codec carrying an explicit parse policy.
Implementations§
Source§impl StepReader
impl StepReader
Sourcepub const fn new(options: ParseOptions) -> Self
pub const fn new(options: ParseOptions) -> Self
A reader applying options.
Sourcepub const fn eager(self) -> Self
pub const fn eager(self) -> Self
Decodes every entity during the read, as before lazy loading.
For a consumer that will touch nearly every entity anyway and wants the source released after the read. Recovery and reference-check options always read eagerly.
Sourcepub unsafe fn read_path_mapped(&self, path: &Path) -> Result<Model, ModelError>
pub unsafe fn read_path_mapped(&self, path: &Path) -> Result<Model, ModelError>
Reads a memory-mapped file.
Avoids copying the file: pages are loaded from the page cache as they are touched and are not part of the process’s own heap. A lazily loaded model keeps the mapping and decodes from it for as long as it lives.
§Safety
The file must not be modified or truncated while the returned model
– or any clone of it – is alive. Truncation can end the process
with SIGBUS when an entity is decoded; a rewrite makes decoding
panic or, if the new bytes still parse, read other content. Prefer
Codec::read_path, which owns its copy, unless the file is known
to stay put.
§Errors
As Codec::read_path.
Sourcepub fn try_read_owned(&self, bytes: Vec<u8>) -> Result<Model, ReadFailure>
pub fn try_read_owned(&self, bytes: Vec<u8>) -> Result<Model, ReadFailure>
Reads bytes like Codec::read_owned and, when the read fails,
hands the buffer back with the error.
The buffer is not copied either way: a failed read returns the very
allocation that was passed in, so the caller can locate the error in
it (ReadFailure::location) or read it again under another policy.
§Errors
As Codec::read_owned, in a ReadFailure.
Sourcepub fn check(&self, bytes: &[u8]) -> Result<(), ModelError>
pub fn check(&self, bytes: &[u8]) -> Result<(), ModelError>
Whether Codec::read_bytes accepts bytes, and its error when it
does not, without building a model.
Exact, not a heuristic: the error is the one read_bytes returns for
the same input under the same options, and Ok means read_bytes
succeeds. Locate a syntax error with SyntaxLocation::locate.
A strict check keeps the id of every record it accepts, to refuse a repeated one, so its memory grows with the number of records (8 bytes and a hash slot each).
§Errors
The error read_bytes would return.
Sourcepub const fn on_malformed_record(self, policy: OnMalformed) -> Self
pub const fn on_malformed_record(self, policy: OnMalformed) -> Self
Sets the malformed-record policy.
Sourcepub const fn options(&self) -> ParseOptions
pub const fn options(&self) -> ParseOptions
The policy this reader applies.
Trait Implementations§
Source§impl Clone for StepReader
impl Clone for StepReader
Source§fn clone(&self) -> StepReader
fn clone(&self) -> StepReader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Codec for StepReader
impl Codec for StepReader
Source§fn read_path(&self, path: &Path) -> Result<Model, ModelError>
fn read_path(&self, path: &Path) -> Result<Model, ModelError>
Reads the file into a buffer the model owns.
Not memory-mapped: a lazily loaded model decodes from its source for
as long as it lives, and a mapping of a file that another process
changes in that time is undefined behaviour. The mapped read is
StepReader::read_path_mapped, an unsafe opt-in.