feat: Start dummy in-memory database
This commit is contained in:
parent
1ef02c58dd
commit
bdb5008914
9 changed files with 181 additions and 3 deletions
17
src/db/interface.rs
Normal file
17
src/db/interface.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use crate::db::error::*;
|
||||
use crate::db::{Database, User, UserRef};
|
||||
|
||||
impl<D: DatabaseInterface> DatabaseInterface for Database<D> {
|
||||
async fn get_user(&self, user: &UserRef) -> Option<User> {
|
||||
self.inner.read().await.get_user(user).await
|
||||
}
|
||||
|
||||
async fn create_user(&mut self, user: User) -> Result<(), UserAlreadyExists> {
|
||||
self.inner.write().await.create_user(user).await
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DatabaseInterface {
|
||||
async fn get_user(&self, user: &UserRef) -> Option<User>;
|
||||
async fn create_user(&mut self, user: User) -> Result<(), UserAlreadyExists>;
|
||||
}
|
||||
Loading…
Reference in a new issue