Skip to main content

sniff

Function sniff 

Source
pub fn sniff<R: BufRead>(input: R) -> Result<Option<&'static Schema>>
Expand description

Identify which schema vintage a document is written against, reading only its root.

Returns None when no compiled-in vintage recognises the namespaces: a vintage this build has no feature for, or not CIM/XML at all.

let file = std::io::BufReader::new(std::fs::File::open("EQ.xml")?);
let schema = cim_kit::reader::sniff(file)?.expect("a known CIM vintage");
let mut ds = cim_kit::Dataset::new(schema);

Only the first MiB is read: the vocabulary is declared on the root element, and detect_vintage sniffs every file before loading, so an unbounded sniff would be a second, uncounted pass over the input.