hms_common/
app_dir_client.rs1use std::{
2 io::{Error, ErrorKind},
3 path::PathBuf,
4};
5
6const APP_DIR: &str = ".hold_my_snip";
7
8pub trait AppDirClient {
9 fn get_app_dir_path(&self) -> Result<PathBuf, Error>;
10}
11
12pub struct DefaultAppDirClient;
13
14impl AppDirClient for DefaultAppDirClient {
15 fn get_app_dir_path(&self) -> Result<PathBuf, Error> {
16 dirs::home_dir()
17 .map(|hd| hd.join(APP_DIR))
18 .ok_or_else(|| Error::new(ErrorKind::NotFound, "Unable to locate home directory"))
19 }
20}