#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PackageRoster {
pub package: String,
pub applied: Vec<String>,
pub skipped: Vec<String>,
pub unconfigured: Vec<(String, String)>,
}
impl PackageRoster {
pub fn new(
package: &str,
applied: Vec<String>,
skipped: Vec<String>,
unconfigured: Vec<(String, String)>,
) -> Self {
Self {
package: package.to_string(),
applied,
skipped,
unconfigured,
}
}
pub fn agrees_with(&self, other: &Self) -> bool {
self.applied == other.applied
&& self.skipped == other.skipped
&& self.unconfigured == other.unconfigured
}
pub fn absences(&self) -> Vec<String> {
self.skipped
.iter()
.map(|name| format!("{name} (skipped)"))
.chain(
self.unconfigured
.iter()
.map(|(name, requirement)| format!("{name} ({requirement})")),
)
.collect()
}
}