1#![no_std]
2
3extern crate alloc;
4
5use alloc::sync::Arc;
6
7use sled::Config;
8
9pub mod index;
10pub use index::Index;
11
12pub mod query_builder;
13pub use query_builder::{ConditionBuilder, QueryBuilder};
14
15pub mod result;
16pub use result::DbResult;
17
18pub mod record;
19pub use record::Record;
20
21pub mod table;
22pub use table::Table;
23use table::{TableInner, TableType};
24
25pub mod constraint;
26pub use constraint::Constraint;
27
28mod encoding;
29mod subscriber;
30
31pub struct TinyBase {
33 engine: sled::Db,
34}
35
36impl TinyBase {
37 pub fn new(path: Option<&str>, temporary: bool) -> Self {
44 Self {
45 engine: if let Some(path) = path {
46 Config::new().path(path).temporary(temporary)
47 } else {
48 Config::new().temporary(temporary)
49 }
50 .open()
51 .unwrap(),
52 }
53 }
54
55 pub fn open_table<T: TableType>(&self, name: &str) -> DbResult<Table<T>> {
65 Ok(Table(Arc::new(TableInner::new(&self.engine, name)?)))
66 }
67}