Skip to content

Commit 804247d

Browse files
refactor(hm-plugin-protocol): Mark the wire-protocol BuildEvent enum #[non_exhaustive] (#123)
1 parent 80b729e commit 804247d

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub enum StdStream {
3030
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, DeriveJsonSchema, derive_more::IsVariant,
3131
)]
3232
#[serde(tag = "kind", rename_all = "snake_case")]
33+
#[non_exhaustive]
3334
pub enum BuildEvent {
3435
BuildStart {
3536
run_id: Uuid,

crates/hm-render/src/human.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ where
126126
duration_ms,
127127
} => format!("build: end exit={exit_code} duration={duration_ms}ms\n").into_bytes(),
128128

129-
BuildEvent::BuildAccepted { build, watch_url } => {
130-
if let Some(url) = watch_url {
131-
let n = build.number.map(|n| format!("#{n} ")).unwrap_or_default();
132-
format!("build {n}\u{2192} {url}\n").into_bytes()
133-
} else {
134-
return;
135-
}
129+
BuildEvent::BuildAccepted {
130+
build,
131+
watch_url: Some(url),
132+
} => {
133+
let n = build.number.map(|n| format!("#{n} ")).unwrap_or_default();
134+
format!("build {n}\u{2192} {url}\n").into_bytes()
136135
}
137136

138137
BuildEvent::ChainFailed {
@@ -152,6 +151,8 @@ where
152151
)
153152
.into_bytes()
154153
}
154+
155+
_ => return, // unknown future event: no visible output
155156
};
156157

157158
let _ = self.out.write_all(&bytes);

crates/hm-render/src/progress.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,14 @@ where
336336
}
337337
}
338338

339-
BuildEvent::BuildAccepted { build, watch_url } => {
340-
if let Some(url) = watch_url {
341-
let n = build.number.map(|n| format!("#{n} ")).unwrap_or_default();
342-
let _ = writeln!(self.out, "build {n}\u{2192} {url}");
343-
}
339+
BuildEvent::BuildAccepted {
340+
build,
341+
watch_url: Some(url),
342+
} => {
343+
let n = build.number.map(|n| format!("#{n} ")).unwrap_or_default();
344+
let _ = writeln!(self.out, "build {n}\u{2192} {url}");
344345
}
345346

346-
BuildEvent::ChainFailed { .. } => {}
347-
348347
BuildEvent::BuildEnd {
349348
exit_code,
350349
duration_ms,
@@ -373,6 +372,8 @@ where
373372
);
374373
}
375374
}
375+
376+
_ => {} // unknown future event: no progress update
376377
}
377378
}
378379
}

0 commit comments

Comments
 (0)