diff options
| author | 2025-04-03 09:45:41 +0100 | |
|---|---|---|
| committer | 2025-04-03 09:45:41 +0100 | |
| commit | 9b18e40d8ba5f891e077daa039632f81d5fd2f86 (patch) | |
| tree | 3b34d3449088cd1defb84ff8d10134e31c588ef0 /stanza/src | |
| parent | f3bdd599425424de8dbff5e4e89b7bcdef205c85 (diff) | |
| download | luz-9b18e40d8ba5f891e077daa039632f81d5fd2f86.tar.gz luz-9b18e40d8ba5f891e077daa039632f81d5fd2f86.tar.bz2 luz-9b18e40d8ba5f891e077daa039632f81d5fd2f86.zip | |
feat(stanza): xep-0128: service discovery extensions
Diffstat (limited to '')
| -rw-r--r-- | stanza/src/xep_0030/info.rs | 18 | ||||
| -rw-r--r-- | stanza/src/xep_0300.rs | 10 | ||||
| -rw-r--r-- | stanza/src/xep_0390.rs | 2 | 
3 files changed, 23 insertions, 7 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,          })      }  } diff --git a/stanza/src/xep_0300.rs b/stanza/src/xep_0300.rs index 9efad46..71a2c36 100644 --- a/stanza/src/xep_0300.rs +++ b/stanza/src/xep_0300.rs @@ -1,16 +1,16 @@ -use std::str::FromStr; +use std::{convert::Infallible, str::FromStr};  use peanuts::{      element::{FromElement, IntoElement}, -    DeserializeError, Element, +    Element,  };  pub const XMLNS: &str = "urn:xmpp:hashes:2";  #[derive(Debug, Clone)]  pub struct Hash { -    algo: Algo, -    hash: String, +    pub algo: Algo, +    pub hash: String,  }  impl FromElement for Hash { @@ -82,7 +82,7 @@ pub enum Algo {  }  impl FromStr for Algo { -    type Err = DeserializeError; +    type Err = Infallible;      fn from_str(s: &str) -> Result<Self, Self::Err> {          match s { diff --git a/stanza/src/xep_0390.rs b/stanza/src/xep_0390.rs index a05a659..bcd331d 100644 --- a/stanza/src/xep_0390.rs +++ b/stanza/src/xep_0390.rs @@ -8,7 +8,7 @@ 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>); +pub struct C(pub Vec<Hash>);  impl FromElement for C {      fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { | 
