diff options
Diffstat (limited to 'stanza/src/xep_0030/info.rs')
| -rw-r--r-- | stanza/src/xep_0030/info.rs | 18 | 
1 files changed, 17 insertions, 1 deletions
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<String>,      pub features: Vec<Feature>,      pub identities: Vec<Identity>, +    #[cfg(feature = "xep_0128")] +    pub extensions: Vec<X>,      #[cfg(feature = "xep_0059")]      pub set: Option<Set>,  } @@ -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<String>,      /// non empty string      pub r#type: String, +    pub lang: Option<String>,  }  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,          })      }  }  | 
