feat: Type-erase Database backend for simpler code
This commit is contained in:
parent
9933990fd3
commit
ccbd97b836
17 changed files with 108 additions and 117 deletions
|
|
@ -6,19 +6,19 @@ use crate::db::error::BoxedError;
|
|||
use crate::db::{DatabaseInterface, Domain, User, UserRef};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Database<D: DatabaseInterface> {
|
||||
pub inner: Arc<RwLock<D>>,
|
||||
pub struct Database {
|
||||
pub inner: Arc<RwLock<Box<dyn DatabaseInterface>>>,
|
||||
}
|
||||
|
||||
impl<D: DatabaseInterface> Database<D> {
|
||||
pub fn new(db: D) -> Self {
|
||||
impl Database {
|
||||
pub fn new(db: impl DatabaseInterface) -> Self {
|
||||
Self {
|
||||
inner: Arc::new(RwLock::new(db)),
|
||||
inner: Arc::new(RwLock::new(Box::new(db))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DatabaseInterface> Database<D> {
|
||||
impl Database {
|
||||
/// Return false if the user doesn't exist, or the password is wrong.
|
||||
///
|
||||
/// TODO: should we return something else when the account doesn't exist?
|
||||
|
|
|
|||
Loading…
Reference in a new issue