#![doc = include_str!("../examples/disk.rs")]
#![doc = include_str!("../examples/multi.rs")]
mod contents;
pub mod drivers;
pub mod errors;
pub mod multi_store;
pub mod store;
pub enum StoreConfig {
#[cfg(feature = "inmem")]
InMem(),
#[cfg(feature = "aws_s3")]
AwsS3(drivers::aws_s3::Config),
#[cfg(feature = "disk")]
Disk(drivers::disk::Config),
}
impl StoreConfig {
#[allow(clippy::unused_async)]
pub async fn build(self) -> errors::DriverResult<store::Store> {
let driver = match self {
#[cfg(feature = "inmem")]
Self::InMem() => {
Box::<drivers::inmem::InMemoryDriver>::default() as Box<dyn drivers::Driver>
}
#[cfg(feature = "aws_s3")]
Self::AwsS3(config) => {
Box::new(drivers::aws_s3::AwsS3::new(config)) as Box<dyn drivers::Driver>
}
#[cfg(feature = "disk")]
Self::Disk(config) => {
Box::new(drivers::disk::DiskDriver::new(config).await?) as Box<dyn drivers::Driver>
}
};
Ok(store::Store::new(driver))
}
#[must_use]
pub fn with_driver(driver: Box<dyn drivers::Driver>) -> store::Store {
store::Store::new(driver)
}
}