display client info and unlock errors to user
This commit is contained in:
37
src-tauri/src/config.rs
Normal file
37
src-tauri/src/config.rs
Normal 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
|
||||
}
|
Reference in New Issue
Block a user