pub fn parse(input: &[u8]) -> Result<Exchange, StepError>Expand description
Examples found in repository?
examples/recovery_probe.rs (line 7)
3fn main() {
4 let path = std::env::args().nth(1).expect("path");
5 let bytes = std::fs::read(&path).expect("read");
6
7 match openbim_step::parse(&bytes) {
8 Ok(_) => println!("strict: OK (unexpected)"),
9 Err(error) => println!("strict: {error}"),
10 }
11
12 let outcome = openbim_step::parse_with(&bytes, openbim_step::ParseOptions::lenient())
13 .expect("lenient parse");
14 println!(
15 "lenient: {} records, {} diagnostics",
16 outcome.exchange.data.records.len(),
17 outcome.diagnostics.len()
18 );
19 for diagnostic in &outcome.diagnostics {
20 println!(" {diagnostic}");
21 let span = diagnostic.span();
22 println!(
23 " dropped bytes: {:?}",
24 String::from_utf8_lossy(&bytes[span.start..span.end])
25 );
26 }
27 let boundaries = outcome
28 .exchange
29 .data
30 .records
31 .iter()
32 .filter(|record| {
33 record
34 .as_simple()
35 .is_some_and(|simple| simple.name == "IFCRELSPACEBOUNDARY")
36 })
37 .count();
38 println!("IfcRelSpaceBoundary: {boundaries}");
39 println!("schema: {:?}", outcome.exchange.header.standard().schema);
40}