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