#mesh #3d-mesh #stl #3d #ascii

stl_io

STL input and output for reading and writing STL (STereoLithography) files

26 releases

0.10.0 Nov 9, 2025
0.8.6 Nov 9, 2025
0.8.5 Feb 26, 2025
0.8.3 Nov 17, 2024
0.3.3 Jul 5, 2017

#28 in Graphics APIs

Download history 9755/week @ 2025-08-07 9977/week @ 2025-08-14 10982/week @ 2025-08-21 13049/week @ 2025-08-28 52707/week @ 2025-09-04 48789/week @ 2025-09-11 51397/week @ 2025-09-18 55022/week @ 2025-09-25 73566/week @ 2025-10-02 93951/week @ 2025-10-09 73074/week @ 2025-10-16 69579/week @ 2025-10-23 58517/week @ 2025-10-30 47630/week @ 2025-11-06 67198/week @ 2025-11-13 64368/week @ 2025-11-20

249,872 downloads per month
Used in 31 crates (23 directly)

MIT license

35KB
703 lines

stl_io

test workflow build workflow Cargo License: MIT Downloads

stl_io is crate for reading and writing STL (STereoLithography) files. It can read both, binary and ascii STL in a safe manner. Writing is limited to binary STL, which is more compact anyway.

Examples

Read STL file:

use std::fs::OpenOptions;
let mut file = OpenOptions::new().read(true).open("mesh.stl").unwrap();
let stl = stl_io::read_stl(&mut file).unwrap();

Write STL file:

use std::fs::OpenOptions;
let mesh = [stl_io::Triangle { normal: [1.0, 0.0, 0.0],
                               vertices: [[0.0, -1.0, 0.0],
                                          [0.0, 1.0, 0.0],
                                          [0.0, 0.0, 0.5]]}];
let mut file = OpenOptions::new().write(true).create_new(true).open("mesh.stl").unwrap();
stl_io::write_stl(&mut file, mesh.iter()).unwrap();

For more information, check out the Documentation.

License

Licensed under the MIT license.

Dependencies

~170KB