From 9b18e40d8ba5f891e077daa039632f81d5fd2f86 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 3 Apr 2025 09:45:41 +0100 Subject: feat(stanza): xep-0128: service discovery extensions --- stanza/src/xep_0030/info.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'stanza/src/xep_0030') diff --git a/stanza/src/xep_0030/info.rs b/stanza/src/xep_0030/info.rs index 94cbabb..539934f 100644 --- a/stanza/src/xep_0030/info.rs +++ b/stanza/src/xep_0030/info.rs @@ -1,8 +1,10 @@ use peanuts::{ element::{FromElement, IntoElement}, - DeserializeError, Element, + DeserializeError, Element, XML_NS, }; +#[cfg(feature = "xep_0128")] +use crate::xep_0004::X; #[cfg(feature = "xep_0059")] use crate::xep_0059::Set; @@ -13,6 +15,8 @@ pub struct Query { pub node: Option, pub features: Vec, pub identities: Vec, + #[cfg(feature = "xep_0128")] + pub extensions: Vec, #[cfg(feature = "xep_0059")] pub set: Option, } @@ -30,12 +34,17 @@ impl FromElement for Query { #[cfg(feature = "xep_0059")] let set = element.child_opt()?; + #[cfg(feature = "xep_0128")] + let extensions = element.children()?; + Ok(Self { node, features, identities, #[cfg(feature = "xep_0059")] set, + #[cfg(feature = "xep_0128")] + extensions, }) } } @@ -50,6 +59,9 @@ impl IntoElement for Query { #[cfg(feature = "xep_0059")] let builder = builder.push_child_opt(self.set.clone()); + #[cfg(feature = "xep_0128")] + let builder = builder.push_children(self.extensions.clone()); + builder } } @@ -62,6 +74,7 @@ pub struct Identity { pub name: Option, /// non empty string pub r#type: String, + pub lang: Option, } impl FromElement for Identity { @@ -84,10 +97,13 @@ impl FromElement for Identity { return Err(DeserializeError::AttributeEmptyString("type".to_string())); } + let lang = element.attribute_opt_namespaced("lang", XML_NS)?; + Ok(Self { category, name, r#type, + lang, }) } } -- cgit