Introduce RuntimeArtifactKind enum and unify error type
Intent: Replace three separate error variants (DecodeStatus, DecodeTerminalResult, DecodeEventLine) with a single Decode variant parameterized by a RuntimeArtifactKind enum, reducing duplication in error definitions and Display formatting.
Affected files: crates/pika-cloud/src/lifecycle.rs
@@ -77,28 +77,38 @@ impl LifecycleTerminalStatus {
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub enum RuntimeArtifactKind {
+ Status,
+ TerminalResult,
+ EventStream,
+}
@@ -77,28 +77,38 @@
#[derive(Debug)]
-pub enum RuntimeLifecycleLoadError {
+pub enum RuntimeArtifactLoadError {
Read {
path: PathBuf,
source: io::Error,
},
- DecodeStatus {
- source_name: String,
- source: serde_json::Error,
- },
- DecodeTerminalResult {
+ Decode {
+ kind: RuntimeArtifactKind,
source_name: String,
- source: serde_json::Error,
- },
- DecodeEventLine {
- path: PathBuf,
- line: usize,
+ line: Option<usize>,
source: serde_json::Error,
},
The old RuntimeLifecycleLoadError had three decode variants that each carried slightly different context but performed the same role. This step introduces:
RuntimeArtifactKind— aCopyenum with variantsStatus,TerminalResult, andEventStream, each providing a human-readablelabel()used in error messages.RuntimeArtifactLoadError(renamed fromRuntimeLifecycleLoadError) — collapses the three decode variants into a singleDecode { kind, source_name, line: Option<usize>, source }. The optionallinefield isSomeonly for event-stream decode errors, eliminating the need for a separateDecodeEventLinevariant.
The Display implementation now pattern-matches on line: None vs line: Some(line) to choose the appropriate format string, and interpolates kind.label() for the artifact type name. The Error::source() impl likewise simplifies to two arms.