diff options
author | 2025-04-03 06:15:55 +0100 | |
---|---|---|
committer | 2025-04-03 06:15:55 +0100 | |
commit | f3bdd599425424de8dbff5e4e89b7bcdef205c85 (patch) | |
tree | d6412aae282773dab26e91d93b0cd324e8774f5b /stanza | |
parent | 6664a9df01b8b6f89e72f9568f90ad7397ceae36 (diff) | |
download | luz-f3bdd599425424de8dbff5e4e89b7bcdef205c85.tar.gz luz-f3bdd599425424de8dbff5e4e89b7bcdef205c85.tar.bz2 luz-f3bdd599425424de8dbff5e4e89b7bcdef205c85.zip |
feat(stanza): xep-0390: entity capabilities 2.0
Diffstat (limited to 'stanza')
-rw-r--r-- | stanza/Cargo.toml | 1 | ||||
-rw-r--r-- | stanza/src/lib.rs | 2 | ||||
-rw-r--r-- | stanza/src/xep_0390.rs | 26 |
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()) + } +} |