Skip to main content

alive_alter/
lib.rs

1#[cfg(feature = "yml")]
2pub use const_str;
3
4#[cfg(feature = "yml")]
5mod yml;
6
7#[cfg(feature = "yml")]
8pub use yml::yml;
9
10#[cfg(feature = "denoise")]
11pub mod denoise;
12
13#[cfg(feature = "title_txt")]
14mod title_txt;
15
16#[cfg(feature = "title_txt")]
17pub use title_txt::title_txt;
18
19mod warn;
20pub use warn::Warn;
21
22mod recover;
23pub use recover::Recover;
24
25pub enum Msg {
26  Warn(Warn),
27  Recover(Recover),
28  None,
29}
30
31#[macro_export]
32macro_rules! display {
33  ($self:ident,$f:ident) => {{
34    write!($f, " {} : {}", $self.watch_name, $self.host)?;
35    if !$self.tag_li.is_empty() {
36      write!($f, " ")?;
37      for (n, i) in $self.tag_li.iter().enumerate() {
38        if n > 0 {
39          write!($f, " ")?;
40        }
41        write!($f, "{}", i)?;
42      }
43    }
44    write!($f, " ⏲ {}", sts::readable($self.duration))?;
45  }};
46}
47
48use std::path::Path;
49
50use aok::Result;
51
52pub trait Load: Sized {
53  fn load(dir: &Path) -> impl std::future::Future<Output = Result<Self>> + Send;
54}
55
56impl<T: Default> Load for T {
57  async fn load(_dir: &Path) -> Result<Self> {
58    Ok(Default::default())
59  }
60}
61
62pub trait Alter {
63  fn warn(&self, warn: &Warn) -> impl std::future::Future<Output = Result<()>> + Send;
64
65  fn recover(&self, recover: &Recover) -> impl std::future::Future<Output = Result<()>> + Send;
66}