kittycad_modeling_cmds/format/
step.rs1use parse_display::{Display, FromStr};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use crate::coord;
6
7pub mod import {
9 use super::*;
10
11 #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
13 #[display("split_closed_faces: {split_closed_faces}")]
14 #[serde(default, rename = "StepImportOptions")]
15 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
16 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
17 pub struct Options {
18 pub split_closed_faces: bool,
22 }
23}
24
25pub mod export {
27 use super::*;
28
29 #[derive(Clone, Debug, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize)]
31 #[serde(rename = "StepExportOptions")]
32 #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
33 #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
34 pub struct Options {
35 pub coords: coord::System,
41 #[serde(skip)]
46 pub created: Option<chrono::DateTime<chrono::Utc>>,
47 }
48
49 impl Default for Options {
50 fn default() -> Self {
51 Self {
52 coords: *coord::KITTYCAD,
53 created: None,
54 }
55 }
56 }
57
58 impl std::fmt::Display for Options {
59 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
60 write!(f, "coords: {}", self.coords)
61 }
62 }
63
64 impl std::str::FromStr for Options {
65 type Err = <coord::System as std::str::FromStr>::Err;
66 fn from_str(s: &str) -> Result<Self, Self::Err> {
67 Ok(Self {
68 coords: <coord::System as std::str::FromStr>::from_str(s)?,
69 created: None,
70 })
71 }
72 }
73}