Skip to main content

ParseOptions

Struct ParseOptions 

Source
#[non_exhaustive]
pub struct ParseOptions { pub on_malformed_record: OnMalformed, pub check_references: bool, pub accept_real_without_point: bool, }
Expand description

Malformed-record policy, re-exported so consumers need not depend on openbim-step directly to configure a reader. Parse behavior toggles.

Constructed with ParseOptions::default (strict) and adjusted through ParseOptions::on_malformed_record, so later options cannot break existing call sites.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§on_malformed_record: OnMalformed

Policy for unparsable data records.

§check_references: bool

Whether to report duplicate instance ids and references to ids that are never defined. Off by default: strict parsing means syntax only.

§accept_real_without_point: bool

Whether a data-section real written without its decimal point (1E-05) is read as a real. Off by default; see Self::accept_real_without_point.

Implementations§

Source§

impl ParseOptions

Source

pub const fn strict() -> ParseOptions

Strict options: any malformed record aborts the parse.

Source

pub const fn lenient() -> ParseOptions

Options that skip and report malformed data records, and read reals written without their decimal point (see Self::accept_real_without_point).

Source

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

Sets the malformed-record policy.

Source

pub const fn check_references(self, enabled: bool) -> ParseOptions

Enables or disables reference-integrity diagnostics.

When enabled, every data record whose instance id was already defined yields a DiagnosticKind::DuplicateId, and every record referencing an id that no record in the DATA section defines yields one DiagnosticKind::DanglingReference per distinct missing id. Forward references are legal (ISO 10303-21:2016 §11.2) and are only reported if the target is still undefined at ENDSEC. Ids compare numerically, so #07 and #7 name the same instance.

Nothing is dropped or rewritten, so these diagnostics never make an outcome lossy. The check keeps one entry per defined id, so memory is linear in the number of records, including for crate::parse_events_with.

Source

pub const fn accept_real_without_point(self, enabled: bool) -> ParseOptions

Enables or disables reading reals written without a decimal point.

ISO 10303-21 writes a real as [sign] digits "." [digits] [exponent], but some exporters omit the point before an exponent (1E-05, -2E3, 3e+2), including buildingSMART’s own IFC4.x alignment test files. Strict parsing refuses such a number with an error for which StepError::is_real_without_point holds. When enabled, a data record keeps it as the real it means, with the point inserted (1.E-05), and yields one DiagnosticKind::RealWithoutPoint over the number’s bytes. The stored value carries the point, so writing the model back produces valid Part 21.

Only complete numbers are read: 1E, 1E- and 1EE2 stay errors, as do numbers without leading digits such as .5E2. Text inside strings is never touched. The header section stays strict, as it does for every other recovery.

Trait Implementations§

Source§

impl Clone for ParseOptions

Source§

fn clone(&self) -> ParseOptions

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 Copy for ParseOptions

Source§

impl Debug for ParseOptions

Source§

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

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

impl Default for ParseOptions

Source§

fn default() -> ParseOptions

Returns the “default value” for a type. Read more
Source§

impl Eq for ParseOptions

Source§

impl Hash for ParseOptions

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ParseOptions

Source§

fn eq(&self, other: &ParseOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ParseOptions

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.