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
#[derive(Debug, PartialEq)]
pub enum Path {
WebResource(String),
Local(String),
}
impl<T> From<T> for Path where T: AsRef<str> {
fn from(path: T) -> Path {
let path_str = path.as_ref();
if path_str.contains("www") {
Path::WebResource(path_str.to_owned())
} else {
Path::Local(path_str.to_owned())
}
}
}
pub struct Observer {
resource_paths: Vec<Path>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn check_web_resource_for_path() {
let a: Path = Path::from("www.google.com".to_owned());
assert_eq!(a, Path::WebResource("www.google.com".to_owned()))
}
#[test]
fn check_local_path() {
let a: Path = Path::from("/home/chinmay_dd/defragger.txt".to_owned());
assert_eq!(a, Path::Local("/home/chinmay_dd/defragger.txt".to_owned()))
}
}