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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::io;
extern crate data_encoding;
extern crate md5;
extern crate sha1;
extern crate sha2;
extern crate base64;
pub use archive::*;
pub use hash::*;
pub use stdext::*;
pub use converter::*;
pub use encoder::*;
pub use errors::*;
mod archive;
mod hash;
mod stdext;
mod converter;
mod encoder;
mod errors;
pub type Result<T> = std::result::Result<T, PhollaitsError>;
pub trait ToIOResult<T> {
fn to_io_result(self) -> io::Result<T>;
}
impl<T, E: ToString> ToIOResult<T> for std::result::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";