blob: 1c2ef69302a7054953950443442f40835f15a10f (
plain) (
tree)
|
|
use peanuts::{
element::{FromElement, IntoElement},
Element,
};
pub const XMLNS: &str = "http://jabber.org/protocol/caps";
#[derive(Debug, Clone)]
pub struct C {
pub ext: Option<String>,
pub hash: String,
pub node: String,
pub 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())
}
}
|