1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::prelude::Backend;

/// Wrapper struct for a database connection.
#[derive(Clone)]
pub struct Db<T: Backend> {
    pub(crate) inner: T,
}

#[cfg(feature = "mongodb")]
#[cfg_attr(docsrs, doc(cfg(feature = "mongodb")))]
impl<T: Backend> Db<T>
where
    T: Into<mongodb::Database>,
{
    pub fn new(db: T) -> Db<mongodb::Database> {
        Db { inner: db.into() }
    }
}

#[cfg(feature = "mongodb")]
impl From<mongodb::Database> for Db<mongodb::Database> {
    fn from(db: mongodb::Database) -> Self {
        Db { inner: db }
    }
}