2022-08-10 01:56:22 +01:00
|
|
|
use std::fmt::Display;
|
2022-11-10 03:09:05 +00:00
|
|
|
//use std::sync::{LockResult, MutexGuard};
|
2022-08-10 01:56:22 +01:00
|
|
|
|
|
|
|
pub fn unwrap_maybe_fatal<T: Sized, E: Display>(result: Result<T, E>, message: &str) -> T {
|
|
|
|
match result {
|
|
|
|
Ok(x) => x,
|
|
|
|
Err(e) => {
|
|
|
|
log::error!("{}: {}", message, e);
|
|
|
|
panic!("{}: {}", message, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-10 03:09:05 +00:00
|
|
|
/*pub fn unwrap_lock<'a, T: Sized>(
|
2022-08-10 01:56:22 +01:00
|
|
|
result: LockResult<MutexGuard<'a, T>>,
|
|
|
|
lock_name: &str,
|
|
|
|
) -> MutexGuard<'a, T> {
|
|
|
|
match result {
|
|
|
|
Ok(x) => x,
|
|
|
|
Err(e) => {
|
|
|
|
log::error!("Failed to acquire {} lock: {}", lock_name, e);
|
|
|
|
panic!("Failed to acquire {} lock: {}", lock_name, e);
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 03:09:05 +00:00
|
|
|
}*/
|
2022-09-01 01:18:15 +01:00
|
|
|
|
|
|
|
pub fn settings_dir() -> std::path::PathBuf {
|
|
|
|
usdpl_back::api::dirs::home()
|
2022-11-29 00:04:03 +00:00
|
|
|
.unwrap_or_else(|| "/tmp/".into())
|
2022-09-01 01:18:15 +01:00
|
|
|
.join(".config/powertools/")
|
|
|
|
}
|