kittycad_modeling_cmds/format/
fbx.rs

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