Initial commit

main
Charlotte Som 2021-07-29 22:44:34 +01:00
commit 5e16bb6fd1
6 changed files with 1239 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1194
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

14
Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "simple_live_chat"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bincode = "1.3.3"
once_cell = "1.8.0"
serde = { version = "1.0.126", features = ["derive"] }
sled = "0.34.6"
tokio = { version = "1.9.0", features = ["full"] }
warp = "0.3.1"

10
src/db.rs Normal file
View File

@ -0,0 +1,10 @@
use std::sync::Mutex;
use once_cell::sync::Lazy;
use sled::Db;
pub static DB: Lazy<Mutex<Db>> = Lazy::new(|| {
let db_path = std::env::var("DB_PATH").unwrap_or_else(|_| "user-database.db".to_string());
Mutex::new(sled::open(db_path).unwrap())
});

14
src/main.rs Normal file
View File

@ -0,0 +1,14 @@
use warp::{Filter, Rejection, Reply};
mod db;
mod users;
async fn hello() -> Result<impl Reply, Rejection> {
Ok("Hello!".to_string())
}
#[tokio::main]
async fn main() {
let hello = warp::any().and_then(hello);
warp::serve(hello).run(([127, 0, 0, 1], 8000)).await;
}

6
src/users.rs Normal file
View File

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct User {
// TODO: What fields does a User need?
}