use crate::Error;
use data_model::{Maze, User};
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use utoipa::ToSchema;
use uuid::Uuid;
pub trait UserStore {
fn init_default_admin_user(&mut self, username: &str, password_hash: &str) -> Result<User, Error>;
fn create_user(&mut self, user: &mut User) -> Result<(), Error>;
fn delete_user(&mut self, id: Uuid) -> Result<(), Error>;
fn update_user(&mut self, user: &mut User) -> Result<(), Error>;
fn get_user(&self, id: Uuid) -> Result<User, Error>;
fn find_user_by_name(&self, name: &str) -> Result<User, Error>;
fn find_user_by_api_key(&self, api_key: Uuid) -> Result<User, Error>;
fn get_users(&self) -> Result<Vec<User>, Error>;
}
#[derive(Serialize, Deserialize, ToSchema, Debug, PartialEq, Clone)]
pub struct MazeItem {
pub id: String,
pub name: String,
pub definition: Option<String>, }
pub trait MazeStore {
fn create_maze(&mut self, owner: &User, maze: &mut Maze) -> Result<(), Error>;
fn delete_maze(&mut self, owner: &User, id: &str) -> Result<(), Error>;
fn update_maze(&mut self, owner: &User, maze: &mut Maze) -> Result<(), Error>;
fn get_maze(&self, owner: &User, id: &str) -> Result<Maze, Error>;
fn find_maze_by_name(&self, owner: &User, name: &str) -> Result<MazeItem, Error>;
fn get_maze_items(&self, owner: &User, include_definitions: bool) -> Result<Vec<MazeItem>, Error>;
}
pub trait Manage {
fn empty(&mut self) -> Result<(), Error>;
}
pub trait Store: UserStore + MazeStore + Manage + Send + Sync {}
#[allow(dead_code)]
pub type SharedStore = Arc<RwLock<Box<dyn Store>>>;