use std::sync::Arc;
use sled::Config;
pub mod index;
pub use index::Index;
pub mod query_builder;
pub use query_builder::{ConditionBuilder, QueryBuilder};
pub mod result;
pub use result::DbResult;
pub mod record;
pub use record::Record;
pub mod table;
pub use table::Table;
use table::{TableInner, TableType};
pub mod constraint;
pub use constraint::Constraint;
mod encoding;
mod subscriber;
pub struct TinyBase {
engine: sled::Db,
}
impl TinyBase {
pub fn new(path: Option<&str>, temporary: bool) -> Self {
Self {
engine: if let Some(path) = path {
Config::new().path(path).temporary(temporary)
} else {
Config::new().temporary(temporary)
}
.open()
.unwrap(),
}
}
pub fn open_table<T: TableType>(&self, name: &str) -> DbResult<Table<T>> {
Ok(Table(Arc::new(TableInner::new(&self.engine, name)?)))
}
}