use sled::Db;
use crate::{
table::{Table, TableLayout},
Error,
};
#[derive(Debug, Clone)]
pub struct Base(Db);
impl Base {
pub fn inner(&self) -> &Db {
&self.0
}
pub fn table<T>(&self) -> Table<T>
where
T: TableLayout,
{
Table::new(self)
}
}
pub fn open<P>(path: P) -> Result<Base, Error>
where
P: AsRef<std::path::Path>,
{
let db = sled::open(path).map_err(Error::SledErr)?;
Ok(Base(db))
}