microcad_export/stl/
exporter.rs1use microcad_lang::{
7 Id,
8 builtin::{ExportError, Exporter, FileIoInterface},
9 model::{Model, OutputType},
10 value::Value,
11};
12
13use crate::stl::{StlWriter, WriteStl};
14
15pub struct StlExporter;
17
18impl Exporter for StlExporter {
19 fn export(&self, model: &Model, filename: &std::path::Path) -> Result<Value, ExportError> {
20 let mut f = std::fs::File::create(filename)?;
21 let mut writer = StlWriter::new(&mut f)?;
22 model.write_stl(&mut writer)?;
23 Ok(Value::None)
24 }
25
26 fn output_type(&self) -> OutputType {
27 OutputType::Geometry3D
28 }
29}
30
31impl FileIoInterface for StlExporter {
32 fn id(&self) -> Id {
33 Id::new("stl")
34 }
35}