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
use std::collections::BTreeMap;
use error::{Error, ProtoError};
use convert::FromMap;
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
pub struct Mount {
pub name: String,
pub storage: String,
}
impl FromMap for Mount {
fn from_map(map: BTreeMap<String, String>) -> Result<Mount, Error> {
Ok(Mount {
name: try!(map.get("mount")
.map(|s| s.to_owned())
.ok_or(Error::Proto(ProtoError::NoField("mount")))),
storage: try!(map.get("storage")
.map(|s| s.to_owned())
.ok_or(Error::Proto(ProtoError::NoField("storage")))),
})
}
}
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
pub struct Neighbor {
pub name: String,
pub storage: String,
}
impl FromMap for Neighbor {
fn from_map(map: BTreeMap<String, String>) -> Result<Neighbor, Error> {
Ok(Neighbor {
name: try!(map.get("name")
.map(|s| s.to_owned())
.ok_or(Error::Proto(ProtoError::NoField("name")))),
storage: try!(map.get("neighbor")
.map(|s| s.to_owned())
.ok_or(Error::Proto(ProtoError::NoField("neighbor")))),
})
}
}