pub struct StepCodec;Expand description
The STEP physical file codec (.ifc).
The STEP physical file codec.
Strict: a record this codec cannot read is an error, because an authoring tool that silently drops entities corrupts the file it edits.
A consumer that would rather load a damaged export uses
StepCodec::lenient and reads Model::diagnostics to see what was
dropped.
use ifc_model::Codec;
use ifc_step::StepCodec;
// A damaged export: strict reading refuses it.
assert!(StepCodec.read_bytes(bytes).is_err());
// A viewer opts into recovery and reports what was lost.
let model = StepCodec::lenient().read_bytes(bytes)?;
assert_eq!(model.len(), 1);
assert_eq!(model.diagnostics().len(), 1);Implementations§
Source§impl StepCodec
impl StepCodec
Sourcepub const fn lenient() -> StepReader
pub const fn lenient() -> StepReader
A reader that skips unreadable data records and reports each one as a
Model diagnostic.
Header structure and the physical-file marker remain fatal: a file whose identity cannot be established is not partially readable.
Sourcepub const fn with_options(options: ParseOptions) -> StepReader
pub const fn with_options(options: ParseOptions) -> StepReader
A reader with an explicit malformed-record policy.
Trait Implementations§
Source§impl Codec for StepCodec
impl Codec for StepCodec
Source§fn extensions(&self) -> &'static [&'static str]
fn extensions(&self) -> &'static [&'static str]
Conventional file extensions, lower-case, without the dot.
Source§fn detect(&self, bytes: &[u8]) -> bool
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>
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>
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>
fn write(&self, model: &Model, out: &mut dyn Write) -> Result<(), ModelError>
Serialize a model.
Source§fn read_path(&self, path: &Path) -> Result<Model, ModelError>
fn read_path(&self, path: &Path) -> Result<Model, ModelError>
Parse a file from disk. Read more
Source§fn read_from(&self, reader: &mut dyn Read) -> Result<Model, ModelError>
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>
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>
fn write_bytes(&self, model: &Model) -> Result<Vec<u8>, ModelError>
Serialize to a byte vector.
impl Copy for StepCodec
Auto Trait Implementations§
impl Freeze for StepCodec
impl RefUnwindSafe for StepCodec
impl Send for StepCodec
impl Sync for StepCodec
impl Unpin for StepCodec
impl UnsafeUnpin for StepCodec
impl UnwindSafe for StepCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more