diff options
Diffstat (limited to '')
| -rw-r--r-- | stanza/Cargo.toml | 1 | ||||
| -rw-r--r-- | stanza/src/lib.rs | 2 | ||||
| -rw-r--r-- | stanza/src/xep_0115.rs | 42 | 
3 files changed, 45 insertions, 0 deletions
| diff --git a/stanza/Cargo.toml b/stanza/Cargo.toml index 3ffa59f..d63703f 100644 --- a/stanza/Cargo.toml +++ b/stanza/Cargo.toml @@ -15,6 +15,7 @@ xep_0004 = []  xep_0030 = []  xep_0059 = []  xep_0060 = ["xep_0004", "dep:chrono"] +xep_0115 = []  xep_0128 = ["xep_0004"]  xep_0131 = []  xep_0172 = [] diff --git a/stanza/src/lib.rs b/stanza/src/lib.rs index ced847e..3ecace0 100644 --- a/stanza/src/lib.rs +++ b/stanza/src/lib.rs @@ -17,6 +17,8 @@ pub mod xep_0030;  pub mod xep_0059;  #[cfg(feature = "xep_0060")]  pub mod xep_0060; +#[cfg(feature = "xep_0115")] +pub mod xep_0115;  #[cfg(feature = "xep_0131")]  pub mod xep_0131;  #[cfg(feature = "xep_0172")] diff --git a/stanza/src/xep_0115.rs b/stanza/src/xep_0115.rs new file mode 100644 index 0000000..c4eee54 --- /dev/null +++ b/stanza/src/xep_0115.rs @@ -0,0 +1,42 @@ +use peanuts::{ +    element::{FromElement, IntoElement}, +    Element, +}; + +pub const XMLNS: &str = "http://jabber.org/protocol/caps"; + +pub struct C { +    ext: Option<String>, +    hash: String, +    node: String, +    ver: String, +} + +impl FromElement for C { +    fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { +        element.check_name("c")?; +        element.check_namespace(XMLNS)?; + +        let ext = element.attribute_opt("ext")?; +        let hash = element.attribute("hash")?; +        let node = element.attribute("node")?; +        let ver = element.attribute("ver")?; + +        Ok(Self { +            ext, +            hash, +            node, +            ver, +        }) +    } +} + +impl IntoElement for C { +    fn builder(&self) -> peanuts::element::ElementBuilder { +        Element::builder("c", Some(XMLNS)) +            .push_attribute_opt("ext", self.ext.clone()) +            .push_attribute("hash", self.hash.clone()) +            .push_attribute("node", self.node.clone()) +            .push_attribute("ver", self.ver.clone()) +    } +} | 
