use sled::{Db, Tree}; use std::path::Path; const DB_DIR: &'static str = "db"; const DB_NAME_ADS: &'static str = "ads"; pub struct Dbs { pub db: Db, pub ads: Tree, } pub fn load_dbs(path: &Path) -> Dbs { //std::fs::create_dir_all(path.join(DB_DIR)).expect("Cannot create db dir"); let db = sled::open(path.join(DB_DIR)).expect("Cannot open db"); Dbs { ads: db.open_tree(DB_NAME_ADS).unwrap(), db, } }