display client info and unlock errors to user

This commit is contained in:
Joseph Montanaro
2022-12-21 13:42:12 -08:00
parent 69475604c0
commit 50f0985f4f
8 changed files with 95 additions and 27 deletions

37
src-tauri/src/config.rs Normal file
View File

@ -0,0 +1,37 @@
use std::net::Ipv4Addr;
use std::path::PathBuf;
pub struct AppConfig {
pub db_path: PathBuf,
pub listen_addr: Ipv4Addr,
pub listen_port: u16,
}
impl Default for AppConfig {
fn default() -> Self {
AppConfig {
db_path: get_or_create_db_path(),
listen_addr: Ipv4Addr::LOCALHOST,
listen_port: 19_923
}
}
}
fn get_or_create_db_path() -> PathBuf {
if cfg!(debug_assertions) {
return PathBuf::from("./creddy.db");
}
let mut parent = std::env::var("HOME")
.map(|h| {
let mut p = PathBuf::from(h);
p.push(".config");
p
})
.unwrap_or(PathBuf::from("."));
parent.push("creddy.db");
parent
}