use anyhow::Error;
use std::future::Future;
use std::pin::Pin;
pub struct TimerResult {
pub error: Option<Error>,
pub next: Option<i64>,
}
impl TimerResult {
pub const fn success() -> Self {
Self {
error: None,
next: None,
}
}
pub const fn with_next(next: i64) -> Self {
Self {
error: None,
next: Some(next),
}
}
pub fn failure(error: Error) -> Self {
Self {
error: Some(error),
next: None,
}
}
}
pub type TimerFuture = Pin<Box<dyn Future<Output = TimerResult> + Send>>;
pub type TimerTarget = fn() -> TimerFuture;
pub type TimerWrapper = std::sync::Arc<dyn Fn(TimerTarget) -> TimerFuture + Send + Sync>;