mod local;
use crate::{Error, Project};
use std::sync::Arc;
use tracing::{debug, instrument};
pub trait Store: Sized {
fn from_project(project: Arc<Project>) -> Result<Self, Error>;
fn get(&self, name: &str) -> Result<String, Error>;
fn get_bytes(&self, name: &str) -> Result<Vec<u8>, Error>;
fn set(&mut self, name: &str, value: &str) -> Result<(), Error>;
fn set_bytes(&mut self, name: &str, value: &[u8]) -> Result<(), Error>;
}
#[instrument(skip(project))]
pub fn get_store(project: Arc<Project>) -> Result<impl Store, Error> {
debug!("Retrieve parameter store");
match project.store.store_type.as_str() {
"local" => Ok(local::Local::from_project(project)?),
_ => Err(Error::LoadStoreError("invalid store type")),
}
}