2020-12-17 12:12:21 +01:00
|
|
|
use sled::Tree;
|
2020-10-26 23:43:18 +01:00
|
|
|
use std::path::Path;
|
|
|
|
|
2020-12-08 11:05:59 +01:00
|
|
|
const DB_DIR: &str = "db";
|
2020-10-26 23:43:18 +01:00
|
|
|
|
2020-12-08 11:05:59 +01:00
|
|
|
const DB_NAME_ADS: &str = "ads";
|
2020-11-02 10:57:50 +01:00
|
|
|
|
2020-12-17 12:12:21 +01:00
|
|
|
#[derive(Clone)]
|
2020-10-26 23:43:18 +01:00
|
|
|
pub struct Dbs {
|
2020-11-02 10:57:50 +01:00
|
|
|
pub ads: Tree,
|
2020-10-26 23:43:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn load_dbs(path: &Path) -> Dbs {
|
|
|
|
let db = sled::open(path.join(DB_DIR)).expect("Cannot open db");
|
|
|
|
|
2020-11-02 10:57:50 +01:00
|
|
|
Dbs {
|
|
|
|
ads: db.open_tree(DB_NAME_ADS).unwrap(),
|
|
|
|
}
|
2020-10-26 23:43:18 +01:00
|
|
|
}
|