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
use std::collections::BTreeMap;
use error::{Error, ProtoError};
use std::convert::From;
use convert::FromMap;
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
pub struct Output {
pub id: u32,
pub name: String,
pub enabled: bool,
}
impl FromMap for Output {
fn from_map(map: BTreeMap<String, String>) -> Result<Output, Error> {
Ok(Output {
id: get_field!(map, "outputid"),
name: try!(map.get("outputname")
.map(|v| v.to_owned())
.ok_or(Error::Proto(ProtoError::NoField("outputname")))),
enabled: get_field!(map, bool "outputenabled"),
})
}
}