use boxferry_model::Identifier;
use podman_lens::{ResourceGraph, ResourceInventory};
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct PodmanPromotionPolicy {
effective_named_volume_mounts: bool,
effective_named_networks: bool,
}
impl PodmanPromotionPolicy {
#[must_use]
pub const fn conservative() -> Self {
Self {
effective_named_volume_mounts: false,
effective_named_networks: false,
}
}
#[must_use]
pub const fn with_effective_named_volume_mounts(mut self, enabled: bool) -> Self {
self.effective_named_volume_mounts = enabled;
self
}
#[must_use]
pub const fn with_effective_named_networks(mut self, enabled: bool) -> Self {
self.effective_named_networks = enabled;
self
}
#[must_use]
pub const fn promotes_effective_named_volume_mounts(self) -> bool {
self.effective_named_volume_mounts
}
#[must_use]
pub const fn promotes_effective_named_networks(self) -> bool {
self.effective_named_networks
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PodmanSource {
application_name: Identifier,
inventory: ResourceInventory,
graph: ResourceGraph,
promotion_policy: PodmanPromotionPolicy,
}
impl PodmanSource {
#[must_use]
pub const fn new(application_name: Identifier, inventory: ResourceInventory, graph: ResourceGraph) -> Self {
Self {
application_name,
inventory,
graph,
promotion_policy: PodmanPromotionPolicy::conservative(),
}
}
#[must_use]
pub const fn application_name(&self) -> &Identifier {
&self.application_name
}
#[must_use]
pub const fn inventory(&self) -> &ResourceInventory {
&self.inventory
}
#[must_use]
pub const fn graph(&self) -> &ResourceGraph {
&self.graph
}
#[must_use]
pub const fn with_promotion_policy(mut self, policy: PodmanPromotionPolicy) -> Self {
self.promotion_policy = policy;
self
}
#[must_use]
pub const fn promotion_policy(&self) -> PodmanPromotionPolicy {
self.promotion_policy
}
}