redup_abstractions/
observation.rs1#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct Observation {
6 available: bool,
7 error: Option<String>,
8}
9
10impl Observation {
11 pub fn unknown() -> Self {
13 Self {
14 available: false,
15 error: None,
16 }
17 }
18
19 pub fn up() -> Self {
21 Self {
22 available: true,
23 error: None,
24 }
25 }
26
27 pub fn down(error: impl Into<String>) -> Self {
29 Self {
30 available: false,
31 error: Some(error.into()),
32 }
33 }
34
35 pub fn is_available(&self) -> bool {
37 self.available
38 }
39
40 pub fn error(&self) -> Option<&str> {
42 self.error.as_deref()
43 }
44}