Skip to main content

boxferry_podman/
output.rs

1//! Deterministic, reviewable Podman output that `BoxFerry` never executes.
2
3use std::fmt;
4
5use boxferry_engine::PlatformVersion;
6
7/// Serialized `PodmanLens` deployment artifact and runnable shell rendering.
8#[derive(Clone, Eq, PartialEq)]
9pub struct PodmanOutput {
10    target_version: PlatformVersion,
11    deployment_json: String,
12    commands_shell: String,
13}
14
15impl PodmanOutput {
16    pub(crate) const fn new(target_version: PlatformVersion, deployment_json: String, commands_shell: String) -> Self {
17        Self {
18            target_version,
19            deployment_json,
20            commands_shell,
21        }
22    }
23
24    /// Returns the exact reviewed Podman version selected for rendering.
25    #[must_use]
26    pub const fn target_version(&self) -> PlatformVersion {
27        self.target_version
28    }
29
30    /// Returns deterministic deployment-v1 JSON.
31    ///
32    /// The artifact is data, but may contain caller-authorized public application values.
33    #[must_use]
34    pub fn deployment_json(&self) -> &str {
35        &self.deployment_json
36    }
37
38    /// Returns the deterministic Podman command script.
39    ///
40    /// This crate never executes the script. Running it performs the rendered Podman operations,
41    /// so callers must review it and select the intended Podman connection first.
42    #[must_use]
43    pub fn commands_shell(&self) -> &str {
44        &self.commands_shell
45    }
46}
47
48impl fmt::Debug for PodmanOutput {
49    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
50        formatter
51            .debug_struct("PodmanOutput")
52            .field("target_version", &self.target_version)
53            .field("deployment_json", &"[REDACTED]")
54            .field("deployment_json_bytes", &self.deployment_json.len())
55            .field("commands_shell", &"[REDACTED]")
56            .field("commands_shell_bytes", &self.commands_shell.len())
57            .finish()
58    }
59}