Skip to main content

Detected

Enum Detected 

Source
pub enum Detected<V> {
    Declared(V),
    Inferred(V),
    Conflict {
        declared: V,
        observed: V,
    },
}
Expand description

How a document’s version was determined.

§The trap this closes

Several openBIM schemas reuse one XML namespace across incompatible versions. IDS is the extreme case: every published version from 0.2 to 1.0 declares a byte-identical targetNamespace, and the differences are in attribute names and cardinality rather than element names. A reader that guesses wrong therefore does not fail — it silently yields a different specification.

So detection returns its evidence, and a file whose declared version disagrees with its actual shape produces Detected::Conflict rather than a silent pick.

Variants§

§

Declared(V)

The document stated its version and the content agreed.

§

Inferred(V)

The version was inferred from document shape; nothing declared it.

§

Conflict

The declared version and the observed shape disagree.

Never resolve this silently. Which one is correct is a policy decision belonging to the caller, not the parser.

Fields

§declared: V

What the document claimed.

§observed: V

What its shape indicates.

Implementations§

Source§

impl<V: Copy> Detected<V>

Source

pub fn resolved(&self) -> Option<V>

The version to use when the caller has no opinion about conflicts.

Returns None for Detected::Conflict — resolving that is the caller’s decision, and defaulting it here would reintroduce exactly the silent-wrong-parse failure this type exists to surface.

use openbim_core::Detected;
assert_eq!(Detected::Declared(1u8).resolved(), Some(1));
assert_eq!(
    Detected::Conflict { declared: 1u8, observed: 2 }.resolved(),
    None
);
Source

pub fn is_conflict(&self) -> bool

Whether detection found contradictory evidence.

Trait Implementations§

Source§

impl<V: Clone> Clone for Detected<V>

Source§

fn clone(&self) -> Detected<V>

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<V: Debug> Debug for Detected<V>

Source§

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

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

impl<V: Eq> Eq for Detected<V>

Source§

impl<V: PartialEq> PartialEq for Detected<V>

Source§

fn eq(&self, other: &Detected<V>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<V: PartialEq> StructuralPartialEq for Detected<V>

Auto Trait Implementations§

§

impl<V> Freeze for Detected<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for Detected<V>
where V: RefUnwindSafe,

§

impl<V> Send for Detected<V>
where V: Send,

§

impl<V> Sync for Detected<V>
where V: Sync,

§

impl<V> Unpin for Detected<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for Detected<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for Detected<V>
where V: UnwindSafe,

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<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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.