use std::sync::Arc; use super::DeploymentDescriptor; #[derive(Clone)] pub struct NodePlan { pub index: usize, pub id: [u8; 32], pub general: NodeConfig, } impl NodePlan { #[must_use] pub const fn index(&self) -> usize { self.index } } #[derive(Clone)] pub struct DeploymentPlan { pub config: TopologyShape, pub plans: Vec>, } impl DeploymentPlan { #[must_use] pub fn new(config: TopologyShape, plans: Vec>) -> Self { Self { config, plans } } #[must_use] pub const fn config(&self) -> &TopologyShape { &self.config } #[must_use] pub fn nodes(&self) -> &[NodePlan] { &self.plans } pub fn iter(&self) -> impl Iterator> { self.plans.iter() } } impl DeploymentDescriptor for DeploymentPlan where TopologyShape: Send + Sync + 'static, NodeConfig: Send + Sync + 'static, { fn node_count(&self) -> usize { self.plans.len() } } pub struct RuntimeTopology { nodes: Vec, } impl RuntimeTopology { #[must_use] pub fn from_nodes(nodes: Vec) -> Self { Self { nodes } } #[must_use] pub fn nodes(&self) -> &[Node] { &self.nodes } #[must_use] pub fn into_nodes(self) -> Vec { self.nodes } } impl Clone for RuntimeTopology where Node: Clone, { fn clone(&self) -> Self { Self { nodes: self.nodes.clone(), } } } impl From> for RuntimeTopology { fn from(nodes: Vec) -> Self { Self::from_nodes(nodes) } } pub type SharedTopology = Arc;