diff options
Diffstat (limited to 'stanza/src/xep_0030/items.rs')
-rw-r--r-- | stanza/src/xep_0030/items.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/stanza/src/xep_0030/items.rs b/stanza/src/xep_0030/items.rs index 7af2bbf..471f3e1 100644 --- a/stanza/src/xep_0030/items.rs +++ b/stanza/src/xep_0030/items.rs @@ -4,12 +4,17 @@ use peanuts::{ Element, }; +#[cfg(feature = "xep_0059")] +use crate::xep_0059::Set; + pub const XMLNS: &str = "http://jabber.org/protocol/disco#items"; #[derive(Debug, Clone)] pub struct Query { pub node: Option<String>, pub items: Vec<Item>, + #[cfg(feature = "xep_0059")] + pub set: Option<Set>, } impl FromElement for Query { @@ -21,15 +26,28 @@ impl FromElement for Query { let items = element.pop_children()?; - Ok(Self { node, items }) + #[cfg(feature = "xep_0059")] + let set = element.child_opt()?; + + Ok(Self { + node, + items, + #[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.items.clone()) + .push_children(self.items.clone()); + + #[cfg(feature = "xep_0059")] + let builder = builder.push_child_opt(self.set.clone()); + + builder } } |