kittycad_modeling_cmds/format/
fbx.rs

1use crate::datetime::DateTimeLocal;
2
3use parse_display::{Display, FromStr};
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// Import models in FBX format.
8pub mod import {
9    use super::*;
10    /// Options for importing FBX.
11    #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
12    #[display("")]
13    #[serde(rename = "FbxImportOptions")]
14    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
15    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
16    pub struct Options {}
17}
18
19/// Export models in FBX format.
20pub mod export {
21    use super::*;
22
23    /// Options for exporting FBX.
24    #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
25    #[serde(rename = "FbxExportOptions")]
26    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
27    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
28    pub struct Options {
29        /// Specifies which kind of FBX will be exported.
30        pub storage: Storage,
31
32        /// Timestamp override.
33        ///
34        /// This is intended for local integration testing only; it is not provided as an option
35        /// in the JSON schema.
36        #[serde(skip)]
37        pub created: Option<DateTimeLocal>,
38    }
39
40    impl std::fmt::Display for Options {
41        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
42            write!(f, "storage: {}", self.storage)
43        }
44    }
45
46    impl std::str::FromStr for Options {
47        type Err = <Storage as std::str::FromStr>::Err;
48        fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
49            Ok(Self {
50                storage: <Storage as std::str::FromStr>::from_str(s)?,
51                created: None,
52            })
53        }
54    }
55
56    /// Describes the storage format of an FBX file.
57    #[derive(
58        Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
59    )]
60    #[display(style = "snake_case")]
61    #[serde(rename = "FbxStorage", rename_all = "snake_case")]
62    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
63    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
64    pub enum Storage {
65        /// ASCII FBX encoding.
66        Ascii,
67
68        /// Binary FBX encoding.
69        #[default]
70        Binary,
71    }
72}