use crate::phase::Phase;
use crate::problem::Problem;
#[derive(Debug, Clone)]
pub struct HealthSnapshot {
phase: Phase,
problems: Vec<Problem>,
}
impl HealthSnapshot {
pub(crate) fn new(phase: Phase, problems: Vec<Problem>) -> Self {
Self { phase, problems }
}
pub fn phase(&self) -> Phase {
self.phase
}
pub fn problems(&self) -> &[Problem] {
&self.problems
}
pub fn is_degraded(&self) -> bool {
self.phase.is_serving() && !self.problems.is_empty()
}
}
impl PartialEq for HealthSnapshot {
fn eq(&self, other: &Self) -> bool {
self.phase == other.phase && self.problems == other.problems
}
}
impl Eq for HealthSnapshot {}