diff options
author | 2025-04-01 20:42:51 +0100 | |
---|---|---|
committer | 2025-04-01 20:42:51 +0100 | |
commit | f7b88569987026bcfec6132ca97b1d8122f44edd (patch) | |
tree | e4c56b14a053ec17e00854ea5f7872a0c735bbfb /stanza/src/xep_0030/info.rs | |
parent | 132d932e6264774ad7d6eab9f52719848c5c91bb (diff) | |
download | luz-f7b88569987026bcfec6132ca97b1d8122f44edd.tar.gz luz-f7b88569987026bcfec6132ca97b1d8122f44edd.tar.bz2 luz-f7b88569987026bcfec6132ca97b1d8122f44edd.zip |
feat(stanza): xep-0059: result set management
Diffstat (limited to 'stanza/src/xep_0030/info.rs')
-rw-r--r-- | stanza/src/xep_0030/info.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/stanza/src/xep_0030/info.rs b/stanza/src/xep_0030/info.rs index 589fd08..94cbabb 100644 --- a/stanza/src/xep_0030/info.rs +++ b/stanza/src/xep_0030/info.rs @@ -3,6 +3,9 @@ use peanuts::{ DeserializeError, Element, }; +#[cfg(feature = "xep_0059")] +use crate::xep_0059::Set; + pub const XMLNS: &str = "http://jabber.org/protocol/disco#info"; #[derive(Debug, Clone)] @@ -10,6 +13,8 @@ pub struct Query { pub node: Option<String>, pub features: Vec<Feature>, pub identities: Vec<Identity>, + #[cfg(feature = "xep_0059")] + pub set: Option<Set>, } impl FromElement for Query { @@ -22,20 +27,30 @@ impl FromElement for Query { let features = element.children()?; let identities = element.children()?; + #[cfg(feature = "xep_0059")] + let set = element.child_opt()?; + Ok(Self { node, features, identities, + #[cfg(feature = "xep_0059")] + set, }) } } impl IntoElement for Query { fn builder(&self) -> peanuts::element::ElementBuilder { - Element::builder("query", Some(XMLNS)) + let builder = Element::builder("query", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_children(self.features.clone()) - .push_children(self.identities.clone()) + .push_children(self.identities.clone()); + + #[cfg(feature = "xep_0059")] + let builder = builder.push_child_opt(self.set.clone()); + + builder } } |