Skip to content

Commit f04ea2d

Browse files
refactor: derive_more full + smart-default cleanups (#10)
1 parent b988de2 commit f04ea2d

16 files changed

Lines changed: 49 additions & 38 deletions

File tree

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ semver = { version = "1", features = ["serde"] }
3434
uuid = { version = "1", features = ["serde", "v4"] }
3535
chrono = { version = "0.4", features = ["serde"] }
3636
thiserror = "2"
37-
derive_more = { version = "1", default-features = false, features = ["deref", "from", "display"] }
37+
derive_more = { version = "1", default-features = false, features = ["full"] }
38+
smart-default = "0.7"
3839
tokio = { version = "1", features = ["full"] }
3940
tokio-util = { version = "0.7", features = ["rt"] }
4041
extism = "1"

crates/hm-plugin-docker/src/image_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ pub(crate) fn resolve_image(
2525
parent_snapshot: Option<&SnapshotRef>,
2626
) -> String {
2727
if let Some(tag) = hit_tag {
28-
return tag.0.clone();
28+
return tag.to_string();
2929
}
3030
if let Some(snap) = parent_snapshot {
31-
return snap.0.clone();
31+
return snap.to_string();
3232
}
3333
if let Some(image) = &step.image {
3434
return image.clone();

crates/hm-plugin-docker/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn run_step(input: ExecutorInput) -> Result<StepResult, PluginError> {
134134
});
135135
match host::commit(DockerCommitArgs {
136136
container_id: cid.clone(),
137-
tag: target_tag.0.clone(),
137+
tag: target_tag.to_string(),
138138
}) {
139139
Ok(_) => Some(target_tag),
140140
Err(e) => {

crates/hm-plugin-protocol/src/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use uuid::Uuid;
99

1010
use crate::executor::SnapshotRef;
1111

12-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
12+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
1313
#[serde(rename_all = "snake_case")]
1414
pub enum StdStream {
1515
Stdout,
1616
Stderr,
1717
}
1818

19-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
19+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
2020
#[serde(tag = "kind", rename_all = "snake_case")]
2121
pub enum BuildEvent {
2222
BuildStart {

crates/hm-plugin-protocol/src/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct ArtifactRef {
3636

3737
/// Host-decided cache outcome. The executor honours this; it does
3838
/// not re-decide.
39-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
39+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
4040
#[serde(tag = "kind", rename_all = "snake_case")]
4141
pub enum CacheDecision {
4242
/// Boot from `tag`; skip running `cmd`.

crates/hm-plugin-protocol/src/hook.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct HookEvent {
1414
pub phase: HookPhase,
1515
}
1616

17-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
17+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
1818
#[serde(rename_all = "snake_case")]
1919
pub enum HookPhase {
2020
/// May return [`HookOutcome::Abort`] to fail the build.
@@ -23,7 +23,7 @@ pub enum HookPhase {
2323
After,
2424
}
2525

26-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
26+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
2727
#[serde(tag = "kind", rename_all = "snake_case")]
2828
pub enum HookOutcome {
2929
/// Continue the build.
@@ -37,7 +37,7 @@ pub enum HookOutcome {
3737
///
3838
/// The manifest declares *what* events the plugin wants, not the per-event
3939
/// payload. Kept in this file so plugin authors only import one module.
40-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema)]
40+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
4141
#[serde(rename_all = "snake_case")]
4242
pub enum HookEventKind {
4343
BuildStart,

crates/hm-plugin-protocol/src/host_abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
99

1010
use crate::executor::ArchiveId;
1111

12-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
12+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
1313
#[serde(rename_all = "snake_case")]
1414
pub enum Level {
1515
Trace,
@@ -19,7 +19,7 @@ pub enum Level {
1919
Error,
2020
}
2121

22-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
22+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
2323
#[serde(rename_all = "snake_case")]
2424
pub enum KvScope {
2525
/// Per-plugin, persistent across builds. Stored in

crates/hm-plugin-protocol/src/ir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Pipeline {
2424
pub steps: Vec<Step>,
2525
}
2626

27-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
27+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
2828
#[serde(tag = "type", rename_all = "snake_case")]
2929
pub enum Step {
3030
Command(Box<CommandStep>),

crates/hm-plugin-protocol/src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct PluginManifest {
4343
pub allowed_hosts: Vec<String>,
4444
}
4545

46-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema)]
46+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant)]
4747
#[serde(tag = "kind", rename_all = "snake_case")]
4848
pub enum Capability {
4949
Subcommand(SubcommandSpec),

0 commit comments

Comments
 (0)