aboutsummaryrefslogtreecommitdiffstats
path: root/stanza
diff options
context:
space:
mode:
Diffstat (limited to 'stanza')
-rw-r--r--stanza/Cargo.toml1
-rw-r--r--stanza/src/lib.rs2
-rw-r--r--stanza/src/xep_0390.rs26
3 files changed, 29 insertions, 0 deletions
diff --git a/stanza/Cargo.toml b/stanza/Cargo.toml
index c492f1b..1863aa5 100644
--- a/stanza/Cargo.toml
+++ b/stanza/Cargo.toml
@@ -20,3 +20,4 @@ xep_0172 = []
xep_0199 = []
xep_0203 = ["dep:chrono"]
xep_0300 = []
+xep_0390 = ["xep_0300"]
diff --git a/stanza/src/lib.rs b/stanza/src/lib.rs
index bc8d59a..ced847e 100644
--- a/stanza/src/lib.rs
+++ b/stanza/src/lib.rs
@@ -27,5 +27,7 @@ pub mod xep_0199;
pub mod xep_0203;
#[cfg(feature = "xep_0300")]
pub mod xep_0300;
+#[cfg(feature = "xep_0390")]
+pub mod xep_0390;
pub static XML_VERSION: VersionInfo = VersionInfo::One;
diff --git a/stanza/src/xep_0390.rs b/stanza/src/xep_0390.rs
new file mode 100644
index 0000000..a05a659
--- /dev/null
+++ b/stanza/src/xep_0390.rs
@@ -0,0 +1,26 @@
+use crate::xep_0300::Hash;
+use peanuts::{
+ element::{FromElement, IntoElement},
+ Element,
+};
+
+pub const XMLNS: &str = "urn:xmpp:caps";
+
+// TODO: have a vec which guarantees at least one item
+#[derive(Debug, Clone)]
+pub struct C(Vec<Hash>);
+
+impl FromElement for C {
+ fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> {
+ element.check_name("c")?;
+ element.check_namespace(XMLNS)?;
+
+ Ok(Self(element.pop_children()?))
+ }
+}
+
+impl IntoElement for C {
+ fn builder(&self) -> peanuts::element::ElementBuilder {
+ Element::builder("c", Some(XMLNS)).push_children(self.0.clone())
+ }
+}