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
|
use peanuts::{
element::{FromElement, IntoElement},
Element,
};
pub const XMLNS: &str = "http://jabber.org/protocol/caps";
pub struct C {
ext: Option<String>,
hash: String,
node: String,
ver: String,
}
impl FromElement for C {
fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> {
element.check_name("c")?;
element.check_namespace(XMLNS)?;
let ext = element.attribute_opt("ext")?;
let hash = element.attribute("hash")?;
let node = element.attribute("node")?;
let ver = element.attribute("ver")?;
Ok(Self {
ext,
hash,
node,
ver,
})
}
}
impl IntoElement for C {
fn builder(&self) -> peanuts::element::ElementBuilder {
Element::builder("c", Some(XMLNS))
.push_attribute_opt("ext", self.ext.clone())
.push_attribute("hash", self.hash.clone())
.push_attribute("node", self.node.clone())
.push_attribute("ver", self.ver.clone())
}
}
|