1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use std;
#[derive(Clone, Debug)]
pub struct AppInfo {
name: String,
author: String,
safe_name: String,
safe_author: String,
}
impl AppInfo {
pub fn new(name: &str, author: &str) -> Self {
AppInfo {
name: name.into(),
author: author.into(),
safe_name: name.into(),
safe_author: author.into(),
}
}
pub fn safe_name(&self) -> &str {
&self.safe_name
}
pub fn safe_author(&self) -> &str {
&self.safe_author
}
pub fn get_name(&self) -> &str {
&self.name
}
pub fn get_author(&self) -> &str {
&self.author
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum AppDirType {
UserConfig,
UserData,
UserCache,
SharedData,
SharedConfig,
}
impl AppDirType {
pub fn is_shared(&self) -> bool {
use AppDirType::*;
match *self {
SharedData | SharedConfig => true,
_ => false,
}
}
}
pub enum AppDirError {
Io(std::io::Error),
NotSupported,
}
impl From<std::io::Error> for AppDirError {
fn from(e: std::io::Error) -> Self {
AppDirError::Io(e)
}
}
pub type AppDirResult<T> = Result<T, AppDirError>;