Skip to main content

StepReader

Struct StepReader 

Source
pub struct StepReader { /* private fields */ }
Expand description

A STEP codec carrying an explicit parse policy.

Implementations§

Source§

impl StepReader

Source

pub const fn new(options: ParseOptions) -> Self

A reader applying options.

Source

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.

Source

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.

Source

pub const fn on_malformed_record(self, policy: OnMalformed) -> Self

Sets the malformed-record policy.

Source

pub const fn options(&self) -> ParseOptions

The policy this reader applies.

Trait Implementations§

Source§

impl Clone for StepReader

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 Codec for StepReader

Source§

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.

Source§

fn name(&self) -> &'static str

Human-readable name for diagnostics, e.g. STEP.
Source§

fn extensions(&self) -> &'static [&'static str]

Conventional file extensions, lower-case, without the dot.
Source§

fn detect(&self, bytes: &[u8]) -> bool

Does this look like a file this codec can read? Read more
Source§

fn read_bytes(&self, bytes: &[u8]) -> Result<Model, ModelError>

Parse a model from bytes. Read more
Source§

fn read_owned(&self, bytes: Vec<u8>) -> Result<Model, ModelError>

Parse a model from a buffer the model may keep. Read more
Source§

fn write(&self, model: &Model, out: &mut dyn Write) -> Result<(), ModelError>

Serialize a model.
Source§

fn read_from(&self, reader: &mut dyn Read) -> Result<Model, ModelError>

Parse from any reader. Override when the format can stream.
Source§

fn write_path(&self, model: &Model, path: &Path) -> Result<(), ModelError>

Serialize to a file on disk.
Source§

fn write_bytes(&self, model: &Model) -> Result<Vec<u8>, ModelError>

Serialize to a byte vector.
Source§

impl Copy for StepReader

Source§

impl Debug for StepReader

Source§

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

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

impl Default for StepReader

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.