tokio_cron_scheduler/store/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::JobSchedulerError;
use std::future::Future;
use std::pin::Pin;
use uuid::Uuid;
mod metadata_store;
mod notification_store;

pub use metadata_store::JobCodeGet;
pub use metadata_store::MetaDataStorage;
pub use notification_store::NotificationRunnableCodeGet;
pub use notification_store::NotificationStore;

pub trait InitStore {
    fn init(&mut self) -> Pin<Box<dyn Future<Output = Result<(), JobSchedulerError>> + Send>>;
    fn inited(&mut self) -> Pin<Box<dyn Future<Output = Result<bool, JobSchedulerError>> + Send>>;
}

pub trait DataStore<DATA>
where
    DATA: Sized,
{
    fn get(
        &mut self,
        id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<DATA>, JobSchedulerError>> + Send>>;

    fn add_or_update(
        &mut self,
        data: DATA,
    ) -> Pin<Box<dyn Future<Output = Result<(), JobSchedulerError>> + Send>>;

    fn delete(
        &mut self,
        guid: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), JobSchedulerError>> + Send>>;
}

pub trait CodeGet<CODE>
where
    CODE: Sized,
{
    fn get(
        &mut self,
        id: Uuid,
    ) -> Box<dyn Future<Output = Result<Pin<Box<CODE>>, JobSchedulerError>>>;
    fn notify_on_add(
        &mut self,
        id: Uuid,
    ) -> Box<dyn Future<Output = Result<(), JobSchedulerError>>>;
    fn notify_on_delete(
        &mut self,
        id: Uuid,
    ) -> Box<dyn Future<Output = Result<(), JobSchedulerError>>>;
}