kittycad_modeling_cmds/
exec_kcl.rs1use bon::Builder;
2use kcl_error::{CompilationIssue, KclError};
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::shared::safe_filepath::SafeFilepath;
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default, Builder)]
10#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
11#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
12#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
13#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
14pub struct KclProject {
15 pub files: Vec<KclFile>,
17 pub entrypoint: SafeFilepath,
21}
22
23#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default, Builder)]
25#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
26#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
27#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
28#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
29pub struct KclFile {
30 pub path: SafeFilepath,
32 #[serde(
34 serialize_with = "serde_bytes::serialize",
35 deserialize_with = "serde_bytes::deserialize"
36 )]
37 pub contents: Vec<u8>,
38}
39
40#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
41#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
42#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
43#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
44pub struct ExecKclProjectOk {
46 }
49
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
51#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
52#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
53#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
54pub struct ExecKclProjectErr {
56 pub error: Option<KclError>,
58 pub non_fatal: Vec<CompilationIssue>,
60 }
63
64#[cfg(feature = "arbitrary")]
65impl<'a> arbitrary::Arbitrary<'a> for ExecKclProjectOk {
66 fn arbitrary(_u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
67 Ok(Self {})
68 }
69}
70
71#[cfg(feature = "arbitrary")]
72impl<'a> arbitrary::Arbitrary<'a> for ExecKclProjectErr {
73 fn arbitrary(_u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
74 Ok(Self {
75 error: Default::default(),
76 non_fatal: Default::default(),
77 })
78 }
79}