aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/xep_0115.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stanza/src/xep_0115.rs')
-rw-r--r--stanza/src/xep_0115.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/stanza/src/xep_0115.rs b/stanza/src/xep_0115.rs
new file mode 100644
index 0000000..c4eee54
--- /dev/null
+++ b/stanza/src/xep_0115.rs
@@ -0,0 +1,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())
+ }
+}