kittycad_modeling_cmds/
traits.rs1use schemars::JsonSchema;
2use serde::{de::DeserializeOwned, Serialize};
3
4use crate::ModelingCmd;
5
6pub trait ModelingCmdVariant: Serialize {
8 type Output: ModelingCmdOutput;
10 fn into_enum(self) -> ModelingCmd;
12 fn name() -> &'static str;
14}
15
16pub trait ModelingCmdOutput: std::fmt::Debug + Serialize + DeserializeOwned + JsonSchema {}
18
19impl<CmdVariant> From<CmdVariant> for ModelingCmd
20where
21 CmdVariant: ModelingCmdVariant,
22{
23 fn from(value: CmdVariant) -> Self {
24 value.into_enum()
25 }
26}