Skip to content

Commit 7e91cda

Browse files
committed
fix(hm-config): rustfmt + satisfy clippy/test for Backend enum
1 parent 85d75a3 commit 7e91cda

2 files changed

Lines changed: 12 additions & 27 deletions

File tree

crates/hm-config/src/lib.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,26 @@ pub mod creds;
1515

1616
pub const DEFAULT_API_URL: &str = "https://api.harmont.dev";
1717

18-
/// Execution backend for `hm run`. Closed set parsed at the config boundary so
19-
/// invalid values are rejected at deserialize time instead of mis-dispatching
20-
/// later, and every consumer match is exhaustively checked by the compiler.
21-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
18+
/// Execution backend for `hm run`.
19+
///
20+
/// Closed set parsed at the config boundary so invalid values are rejected at
21+
/// deserialize time instead of mis-dispatching later, and every consumer match
22+
/// is exhaustively checked by the compiler.
23+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
2224
#[serde(rename_all = "lowercase")]
2325
pub enum Backend {
26+
#[default]
2427
Docker,
2528
Cloud,
2629
}
2730

28-
impl Default for Backend {
29-
fn default() -> Self {
30-
Backend::Docker
31-
}
32-
}
33-
3431
impl Backend {
3532
/// Stable lowercase wire/CLI name (matches the `serde` representation).
3633
#[must_use]
37-
pub fn as_str(self) -> &'static str {
34+
pub const fn as_str(self) -> &'static str {
3835
match self {
39-
Backend::Docker => "docker",
40-
Backend::Cloud => "cloud",
36+
Self::Docker => "docker",
37+
Self::Cloud => "cloud",
4138
}
4239
}
4340
}
@@ -78,7 +75,7 @@ impl Default for Preferences {
7875
}
7976
}
8077

81-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78+
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
8279
pub struct Config {
8380
#[serde(default)]
8481
pub backend: Backend,
@@ -88,16 +85,6 @@ pub struct Config {
8885
pub preferences: Preferences,
8986
}
9087

91-
impl Default for Config {
92-
fn default() -> Self {
93-
Self {
94-
backend: Backend::default(),
95-
cloud: CloudConfig::default(),
96-
preferences: Preferences::default(),
97-
}
98-
}
99-
}
100-
10188
impl Config {
10289
/// XDG-aware user config path (`~/.config/hm/config.toml`).
10390
///

crates/hm/src/commands/init.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,7 @@ pub async fn handle(args: InitArgs) -> Result<()> {
304304
hm_config::Config::load_from_paths(None, Some(&project_config)).unwrap_or_default();
305305
match cfg.backend {
306306
hm_config::Backend::Cloud => {
307-
tracing::info!(
308-
"next step: run `hm run` to execute your pipeline on Harmont Cloud"
309-
);
307+
tracing::info!("next step: run `hm run` to execute your pipeline on Harmont Cloud");
310308
}
311309
hm_config::Backend::Docker => {
312310
tracing::info!("next step: run `hm run` to execute your pipeline locally");

0 commit comments

Comments
 (0)