+2
-20
upload/src/config.rs
+2
-20
upload/src/config.rs
···
1
-
pub enum Id {
2
-
Handle(String),
3
-
Did(String),
4
-
}
5
-
6
1
pub struct Config {
7
-
pub user: Id,
2
+
pub user: String,
8
3
pub pword: String,
9
-
pub dir: std::path::PathBuf,
4
+
pub dir: String,
10
5
}
11
6
12
7
pub enum ConfigErr {
···
44
39
&& let Some(pword) = pword.clone()
45
40
&& let Some(dir) = dir.clone()
46
41
{
47
-
// we do not validate that the did or handle is valid rn
48
-
// but if it contains a : then its definitely a did
49
-
let user = if user.contains(":") {
50
-
Id::Did(user)
51
-
} else {
52
-
Id::Handle(user)
53
-
};
54
-
55
-
let dir = std::path::Path::new(&dir);
56
-
if !dir.is_dir() {
57
-
return Err(ConfigErr::NotADirectory);
58
-
};
59
-
60
42
return Ok(Config {
61
43
user,
62
44
pword,