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
use std::{path::Path, time::SystemTime};

use dyn_clone::DynClone;

use crate::errors::{DriverError, DriverResult};

#[cfg(feature = "disk")]
pub mod disk;

#[cfg(feature = "inmem")]
pub mod inmem;

#[cfg(feature = "aws_s3")]
pub mod aws_s3;

#[async_trait::async_trait]
pub trait Driver: DynClone + Sync + Send {
    async fn read(&self, path: &Path) -> DriverResult<Vec<u8>>;

    async fn file_exists(&self, path: &Path) -> DriverResult<bool>;

    async fn write(&self, path: &Path, content: Vec<u8>) -> DriverResult<()>;

    async fn delete(&self, path: &Path) -> DriverResult<()>;

    async fn delete_directory(&self, path: &Path) -> DriverResult<()>;

    async fn last_modified(&self, path: &Path) -> DriverResult<SystemTime>;
}