1use anyhow::Error;
2use std::future::Future;
3use std::pin::Pin;
4
5pub struct TimerResult {
7 pub error: Option<Error>,
9 pub next: Option<i64>,
11}
12
13impl TimerResult {
14 pub const fn success() -> Self {
16 Self {
17 error: None,
18 next: None,
19 }
20 }
21
22 pub const fn with_next(next: i64) -> Self {
24 Self {
25 error: None,
26 next: Some(next),
27 }
28 }
29
30 pub fn failure(error: Error) -> Self {
32 Self {
33 error: Some(error),
34 next: None,
35 }
36 }
37}
38
39pub type TimerFuture = Pin<Box<dyn Future<Output = TimerResult> + Send>>;
41
42pub type TimerTarget = fn() -> TimerFuture;
44
45pub type TimerWrapper = std::sync::Arc<dyn Fn(TimerTarget) -> TimerFuture + Send + Sync>;