Skip to content

Commit

Permalink
Fix empty variant structs to have a field to work with ts-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtran committed Jan 2, 2025
1 parent 53c501a commit 61b162e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 25 deletions.
88 changes: 66 additions & 22 deletions modeling-cmds/src/def_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ define_modeling_cmd_enum! {

/// Start a new path.
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,

Check warning on line 61 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L61

Added line #L61 was not covered by tests
)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 63 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L63

Added line #L63 was not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct StartPath;
pub struct StartPath {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Move the path's "pen".
/// If you're in sketch mode, these coordinates are in the local coordinate system,
Expand Down Expand Up @@ -267,10 +271,14 @@ define_modeling_cmd_enum! {
}

/// Gets the default camera's camera settings
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 275 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L274-L275

Added lines #L274 - L275 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct DefaultCameraGetSettings;
pub struct DefaultCameraGetSettings {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Change what the default camera is looking at.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
Expand Down Expand Up @@ -549,10 +557,14 @@ define_modeling_cmd_enum! {
}

/// Removes all of the Objects in the scene
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 561 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L560-L561

Added lines #L560 - L561 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct SceneClearAll;
pub struct SceneClearAll {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Replaces current selection with these entities (by UUID).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
Expand Down Expand Up @@ -920,16 +932,24 @@ define_modeling_cmd_enum! {
/// Disable sketch mode.
/// If you are sketching on a face, be sure to not disable sketch mode until you have extruded.
/// Otherwise, your object will not be fused with the face.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 936 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L935-L936

Added lines #L935 - L936 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct SketchModeDisable;
pub struct SketchModeDisable {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Get the plane for sketch mode.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 946 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L945-L946

Added lines #L945 - L946 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct GetSketchModePlane;
pub struct GetSketchModePlane {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Get the plane for sketch mode.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
Expand Down Expand Up @@ -966,18 +986,26 @@ define_modeling_cmd_enum! {
/// Sets whether or not changes to the scene or its objects will be done as a "dry run"
/// In a dry run, successful commands won't actually change the model.
/// This is useful for catching errors before actually making the change.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 990 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L989-L990

Added lines #L989 - L990 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct EnableDryRun;
pub struct EnableDryRun {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Sets whether or not changes to the scene or its objects will be done as a "dry run"
/// In a dry run, successful commands won't actually change the model.
/// This is useful for catching errors before actually making the change.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 1002 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1001-L1002

Added lines #L1001 - L1002 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct DisableDryRun;
pub struct DisableDryRun {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Set the background color of the scene.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
Expand Down Expand Up @@ -1311,11 +1339,15 @@ define_modeling_cmd_enum! {

/// Use orthographic projection.
#[derive(
Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,

Check warning on line 1342 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1342

Added line #L1342 was not covered by tests
)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 1344 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1344

Added line #L1344 was not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct DefaultCameraSetOrthographic;
pub struct DefaultCameraSetOrthographic {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Use perspective projection.
#[derive(
Expand Down Expand Up @@ -1399,24 +1431,36 @@ define_modeling_cmd_enum! {
}

/// Clear the selection
#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 1435 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1434-L1435

Added lines #L1434 - L1435 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct SelectClear;
pub struct SelectClear {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Find all IDs of selected entities
#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 1445 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1444-L1445

Added lines #L1444 - L1445 were not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct SelectGet;
pub struct SelectGet {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Get the number of objects in the scene
#[derive(
Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,
Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant,

Check warning on line 1455 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1455

Added line #L1455 was not covered by tests
)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

Check warning on line 1457 in modeling-cmds/src/def_enum.rs

View check run for this annotation

Codecov / codecov/patch

modeling-cmds/src/def_enum.rs#L1457

Added line #L1457 was not covered by tests
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
pub struct GetNumObjects;
pub struct GetNumObjects {
#[cfg(feature = "ts-rs")]
/// Work around issue with ts-rs not allowing tag on an empty variant.
_fix_ts_rs: (),
}

/// Make a new path by offsetting an object by a given distance.
/// The new path's ID will be the ID of this command.
Expand Down
2 changes: 1 addition & 1 deletion modeling-session/examples/cube_png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn main() -> Result<()> {
let path_id = Uuid::new_v4();
let path = path_id.into();
session
.run_command(path, ModelingCmd::StartPath(StartPath {}))
.run_command(path, ModelingCmd::StartPath(StartPath::default()))
.await
.context("could not create path")?;

Expand Down
2 changes: 1 addition & 1 deletion modeling-session/examples/cube_png_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() -> Result<()> {
let path_id = Uuid::new_v4();
let path = path_id.into();
session
.run_command(path, StartPath {}.into())
.run_command(path, StartPath::default().into())
.await
.context("could not create path")?;

Expand Down
2 changes: 1 addition & 1 deletion modeling-session/examples/lsystem_png_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async fn main() -> Result<()> {
let path_id = Uuid::new_v4();
let path = path_id.into();
session
.run_command(path, ModelingCmd::from(StartPath {}))
.run_command(path, ModelingCmd::from(StartPath::default()))
.await
.context("could not create path")?;

Expand Down

0 comments on commit 61b162e

Please sign in to comment.