Skip to main content

parse_stl_from_slice

Function parse_stl_from_slice 

Source
pub fn parse_stl_from_slice(input: &mut &[u8]) -> ModalResult<Stl>
Expand description

Parses STL data in memory.

The input must consist of exactly one GSI block followed by zero or more whole TTI blocks.

§Errors

Fails if the GSI block or a TTI block is invalid, or if there is trailing data that does not form a complete 128 byte TTI block. The error converts into ParseError.

§Example

use ebustl_parser::parser::parse_stl_from_slice;

let data = std::fs::read("stls/test.stl").expect("Read file");
let stl = parse_stl_from_slice(&mut data.as_slice()).expect("Parse stl from slice");
assert_eq!(13, stl.ttis.len());