#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Observation {
available: bool,
error: Option<String>,
}
impl Observation {
pub fn unknown() -> Self {
Self {
available: false,
error: None,
}
}
pub fn up() -> Self {
Self {
available: true,
error: None,
}
}
pub fn down(error: impl Into<String>) -> Self {
Self {
available: false,
error: Some(error.into()),
}
}
pub fn is_available(&self) -> bool {
self.available
}
pub fn error(&self) -> Option<&str> {
self.error.as_deref()
}
}