aboutsummaryrefslogtreecommitdiff
path: root/server/src/database.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/database.rs')
-rw-r--r--server/src/database.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/server/src/database.rs b/server/src/database.rs
index 3ba8c52..8574189 100644
--- a/server/src/database.rs
+++ b/server/src/database.rs
@@ -1,13 +1,27 @@
+use std::path::PathBuf;
+
use anyhow::Context;
+use log::info;
+use typed_sled::Tree;
-#[derive(Debug)]
pub struct Database {
pub db: sled::Db,
+ pub users: Tree<String, User>,
+}
+
+pub struct User {
+ pub name: String,
+ pub display_name: String,
+ pub password: Vec<u8>,
}
impl Database {
- pub fn open(path: &str) -> Result<Self, anyhow::Error> {
+ pub fn open(path: &PathBuf) -> Result<Self, anyhow::Error> {
+ info!("opening database… (takes O(n) time sadly)");
let db = sled::open(path).context("opening database")?;
- Ok(Self { db })
+ Ok(Self {
+ users: typed_sled::Tree::open(&db, "users"),
+ db,
+ })
}
}