4 releases

0.2.2 Mar 15, 2021
0.2.1 Feb 2, 2021
0.2.0 Nov 5, 2020
0.1.0 Nov 5, 2020

#278 in Parser implementations

Download history 463/week @ 2021-07-04 593/week @ 2021-07-11 272/week @ 2021-07-18 494/week @ 2021-07-25 557/week @ 2021-08-01 348/week @ 2021-08-08 381/week @ 2021-08-15 412/week @ 2021-08-22 243/week @ 2021-08-29 333/week @ 2021-09-05 504/week @ 2021-09-12 531/week @ 2021-09-19 430/week @ 2021-09-26 562/week @ 2021-10-03 678/week @ 2021-10-10 824/week @ 2021-10-17

114 downloads per month
Used in 10 crates (2 directly)

MIT license

31KB
662 lines

nom_stl

CircleCI

What

nom_stl is a binary and ASCII STL parser, written in pure Rust, with only one runtime dependency: the nom parser combinator library. nom_stl automatically differentiates between ASCII and binary STLs. It parses a 30M binary STL in <20ms.

Use

let file = std::fs::File::open("./fixtures/Root_Vase.stl").unwrap();
let mut root_vase = BufReader::new(&file);
let mesh: Mesh = parse_stl(&mut root_vase)?;
assert_eq!(mesh.triangles.len(), 596_736);

nom_stl accepts STL bytes in a wide variety of argument formats: it will try to parse any collection of bytes that implements Read and Seek.

Running the tests

$ cargo test

To make the tests run faster (but increase build time), you can run the tests in release mode. To do this, run the following:

$ cargo test --release

Running the benchmarks

$ cargo bench

What does it need

  • A solid public API
  • Better tests, with better input data rather than 0's for some of the smaller parsers
  • Testing around parsing Windows/DOS line-ending files
  • Property testing (https://crates.io/crates/quickcheck)
  • Latest Nom (5.1)
  • Buffered IO
  • Generic normal and vertex types
  • Real documentation/rustdoc
  • A license
  • A home

Creative Commons

Attribution and thanks goes to the following people for licensing their files Creative Commons so we could include them in this project:

Dependencies

~705KB
~14K SLoC