1use quick_xml::{XmlReader, Element};
2
3use fromxml::FromXml;
4use error::Error;
5
6#[derive(Debug, Default, Clone, PartialEq)]
8pub struct Cloud {
9 pub domain: String,
11 pub port: String,
13 pub path: String,
15 pub register_procedure: String,
17 pub protocol: String,
19}
20
21impl FromXml for Cloud {
22 fn from_xml<R: ::std::io::BufRead>(mut reader: XmlReader<R>,
23 element: Element)
24 -> Result<(Self, XmlReader<R>), Error> {
25 let mut domain = None;
26 let mut port = None;
27 let mut path = None;
28 let mut register_procedure = None;
29 let mut protocol = None;
30
31 for attr in element.attributes().with_checks(false).unescaped() {
32 if let Ok(attr) = attr {
33 match attr.0 {
34 b"domain" if domain.is_none() => {
35 domain = Some(try!(String::from_utf8(attr.1.into_owned())));
36 }
37 b"port" if port.is_none() => {
38 port = Some(try!(String::from_utf8(attr.1.into_owned())));
39 }
40 b"path" if path.is_none() => {
41 path = Some(try!(String::from_utf8(attr.1.into_owned())));
42 }
43 b"registerProcedure" if register_procedure.is_none() => {
44 register_procedure = Some(try!(String::from_utf8(attr.1.into_owned())));
45 }
46 b"protocol" if protocol.is_none() => {
47 protocol = Some(try!(String::from_utf8(attr.1.into_owned())));
48 }
49 _ => {}
50 }
51 }
52 }
53
54 skip_element!(reader);
55
56 let domain = domain.unwrap_or_default();
57 let port = port.unwrap_or_default();
58 let path = path.unwrap_or_default();
59 let register_procedure = register_procedure.unwrap_or_default();
60 let protocol = protocol.unwrap_or_default();
61
62 Ok((Cloud {
63 domain: domain,
64 port: port,
65 path: path,
66 register_procedure: register_procedure,
67 protocol: protocol,
68 }, reader))
69
70 }
71}