Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions g_code/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod v5;

/// A cross-platform type used to store all configuration types.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this default, we'd need to create settings with empty objects, e.g. { "conversion": {} }

#[derive(Debug, Default, Clone, PartialEq)]
pub struct Settings {
pub conversion: GCodeConfig,
Expand All @@ -33,6 +34,7 @@ pub struct Settings {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
#[derive(Debug, Default, Clone, PartialEq)]
pub struct MachineConfig {
pub supported_functionality: SupportedFunctionality,
Expand All @@ -43,6 +45,7 @@ pub struct MachineConfig {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
#[derive(Debug, Clone, PartialEq)]
pub struct GCodeConfig {
#[cfg_attr(feature = "serde", serde(flatten))]
Expand All @@ -63,6 +66,7 @@ impl Default for GCodeConfig {

#[derive(Debug, Default, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct SupportedFunctionality {
/// Indicates support for G2/G3 circular interpolation.
///
Expand All @@ -71,17 +75,15 @@ pub struct SupportedFunctionality {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
#[derive(Debug, Default, Clone, PartialEq)]
/// Operations performed after G-Code generation.
pub struct PostprocessConfig {
/// Convenience field for [g_code::emit::FormatOptions] field
#[cfg_attr(feature = "serde", serde(default))]
pub checksums: bool,
/// Convenience field for [g_code::emit::FormatOptions] field
#[cfg_attr(feature = "serde", serde(default))]
pub line_numbers: bool,
/// Convenience field for [g_code::emit::FormatOptions] field
#[cfg_attr(feature = "serde", serde(default))]
pub newline_before_comment: bool,
}

Expand Down
4 changes: 1 addition & 3 deletions star/src/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,21 @@ mod visit;
/// High-level output configuration
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct ConversionConfig {
/// Dots per inch for pixels, picas, points, etc.
pub dpi: f64,
/// Set the origin point in millimeters for this conversion
#[cfg_attr(feature = "serde", serde(default = "zero_origin"))]

@AmadeusW AmadeusW Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK to remove because impl Default for ConversionConfig { on line 56 provides the zero_origin default. At the same time, this might be less obvious, so let me know what you think

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks!

pub origin: [Option<f64>; 2],
/// Set extra attribute to add when printing node name
pub extra_attribute_name: Option<String>,
/// Reorder paths to minimize travel time
#[cfg_attr(feature = "serde", serde(default))]
pub optimize_path_order: bool,
/// CSS selector to filter which SVG elements are converted.
///
/// Only the `:not`, `:is`, and `:has` pseudo classes are supported.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Selectors>
#[cfg_attr(feature = "serde", serde(default))]
pub selector_filter: Option<String>,
pub starting_point: [Option<f64>; 2],
}
Expand Down
Loading