#[cfg(feature = "diesel")]
pub(in crate::biome) mod diesel;
mod error;
pub(in crate::biome) mod memory;
pub use error::UserStoreError;
#[derive(Clone, Serialize)]
pub struct User {
id: String,
}
impl User {
#[cfg(feature = "rest-api")]
pub fn new(user_id: &str) -> Self {
User {
id: user_id.to_string(),
}
}
pub fn id(&self) -> String {
self.id.to_string()
}
}
pub trait UserStore: Send + Sync {
fn add_user(&self, user: User) -> Result<(), UserStoreError>;
fn update_user(&self, updated_user: User) -> Result<(), UserStoreError>;
fn remove_user(&self, id: &str) -> Result<(), UserStoreError>;
fn fetch_user(&self, id: &str) -> Result<User, UserStoreError>;
fn list_users(&self) -> Result<Vec<User>, UserStoreError>;
}
pub trait CloneBoxUserStore: UserStore {
fn clone_box(&self) -> Box<dyn CloneBoxUserStore>;
}
impl Clone for Box<dyn CloneBoxUserStore> {
fn clone(&self) -> Box<dyn CloneBoxUserStore> {
self.clone_box()
}
}