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
66
67
68
69
70
71
use std::io;
extern crate data_encoding;
extern crate md5;
extern crate ring;
pub use archive::*;
pub use hash::*;
pub use stdext::*;
mod archive;
mod hash;
mod stdext;
pub trait ToIOResult<T> {
fn to_io_result(self) -> io::Result<T>;
}
impl<T, E: ToString> ToIOResult<T> for Result<T, E> {
fn to_io_result(self) -> io::Result<T> {
match self {
Ok(x) => Ok(x),
Err(err) => Err(io::Error::new(io::ErrorKind::Other, err.to_string())),
}
}
}
impl<T> ToIOResult<T> for Option<T> {
fn to_io_result(self) -> io::Result<T> {
match self {
Some(x) => Ok(x),
None => Err(io::Error::new(io::ErrorKind::Other, NONE)),
}
}
}
const NONE: &str = "None";
const FORMAT_TILDA: &str = "~";
const ENV_VAR_HOME: &str = "HOME";