kittycad_modeling_cmds/format/step.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
use parse_display::{Display, FromStr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::coord;
/// Import models in STEP format.
pub mod import {
use super::*;
/// Options for importing STEP format.
#[derive(
Clone,
Debug,
Default,
Eq,
Hash,
PartialEq,
Serialize,
Deserialize,
JsonSchema,
Display,
FromStr,
)]
#[display("split_closed_faces: {split_closed_faces}")]
#[serde(default, rename = "StepImportOptions")]
pub struct Options {
/// Splits all closed faces into two open faces.
///
/// Defaults to `false` but is implicitly `true` when importing into the engine.
pub split_closed_faces: bool,
}
}
/// Export models in STEP format.
pub mod export {
use super::*;
/// Options for exporting STEP format.
#[derive(Clone, Debug, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize)]
#[serde(rename = "StepExportOptions")]
pub struct Options {
/// Co-ordinate system of output data.
///
/// Defaults to the [KittyCAD co-ordinate system].
///
/// [KittyCAD co-ordinate system]: ../coord/constant.KITTYCAD.html
pub coords: coord::System,
/// Timestamp override.
///
/// This is intended for local integration testing only; it is not provided as an option
/// in the JSON schema.
#[serde(skip)]
pub created: Option<chrono::DateTime<chrono::Utc>>,
}
impl Default for Options {
fn default() -> Self {
Self {
coords: *coord::KITTYCAD,
created: None,
}
}
}
impl std::fmt::Display for Options {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "coords: {}", self.coords)
}
}
impl std::str::FromStr for Options {
type Err = <coord::System as std::str::FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self {
coords: <coord::System as std::str::FromStr>::from_str(s)?,
created: None,
})
}
}
}