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.

CIM/XML names its vocabulary in the document, so the vintage is a fact to be read rather than a parameter to be guessed. Returns None when no compiled-in vintage recognises the namespaces — a document this build has no feature for, or not a CIM/XML document 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 of a set before loading any, so an unbounded sniff would be a second, uncounted pass over the input.