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.
Implementations§
Source§impl<V: Copy> Detected<V>
impl<V: Copy> Detected<V>
Sourcepub fn resolved(&self) -> Option<V>
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
);Sourcepub fn is_conflict(&self) -> bool
pub fn is_conflict(&self) -> bool
Whether detection found contradictory evidence.