pub mod object; use std::collections::HashMap; use ecstore::store_api::ObjectInfo; use serde::{de::DeserializeOwned, Serialize}; use crate::{ auth::UserIdentity, cache::Cache, policy::{PolicyDoc, UserType, DEFAULT_POLICIES}, }; #[async_trait::async_trait] pub trait Store: Clone + Send + Sync + 'static { async fn load_iam_config(&self, path: impl AsRef + Send) -> crate::Result<(Item, ObjectInfo)> where Item: DeserializeOwned; async fn save_iam_config(&self, item: Item, path: impl AsRef + Send) -> crate::Result<()>; async fn load_all(&self, cache: &Cache) -> crate::Result<()>; fn get_default_policyes() -> HashMap { DEFAULT_POLICIES .iter() .map(|(n, p)| { ( n.to_string(), PolicyDoc { version: 1, policy: p.clone(), ..Default::default() }, ) }) .collect() } async fn load_users(&self, user_type: UserType) -> crate::Result>; async fn load_policy_docs(&self) -> crate::Result>; }