Add encode/decode helpers for RuntimeStatusSnapshot
Intent: Provide shared, symmetrical serialization helpers for `RuntimeStatusSnapshot` in the `pika-cloud` crate so that every consumer deserializes lifecycle status through a well-known entry point instead of calling `serde_json` directly.
Affected files: crates/pika-cloud/src/lifecycle.rs
@@ -129,6 +129,14 @@ pub fn decode_runtime_terminal_result(bytes: &[u8]) -> serde_json::Result<Runtim
serde_json::from_slice(bytes)
}
+pub fn encode_runtime_status_pretty(status: &RuntimeStatusSnapshot) -> serde_json::Result<Vec<u8>> {
+ serde_json::to_vec_pretty(status)
+}
+
+pub fn decode_runtime_status(bytes: &[u8]) -> serde_json::Result<RuntimeStatusSnapshot> {
+ serde_json::from_slice(bytes)
+}
Two new public functions are introduced in crates/pika-cloud/src/lifecycle.rs:132-138, mirroring the existing decode_runtime_terminal_result / encode_runtime_terminal_result_pretty pair:
encode_runtime_status_pretty— serializes aRuntimeStatusSnapshotto pretty-printed JSON bytes.decode_runtime_status— deserializes JSON bytes back into aRuntimeStatusSnapshot.
Both delegate directly to serde_json and return its Result, keeping the API surface thin while centralizing the serialization contract in one place.