diff options
Diffstat (limited to 'stanza/src/xep_0060/event.rs')
-rw-r--r-- | stanza/src/xep_0060/event.rs | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/stanza/src/xep_0060/event.rs b/stanza/src/xep_0060/event.rs index 1be011d..3cb124b 100644 --- a/stanza/src/xep_0060/event.rs +++ b/stanza/src/xep_0060/event.rs @@ -2,10 +2,7 @@ use std::str::FromStr; use chrono::{DateTime, Utc}; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use crate::xep_0004::X; #[cfg(feature = "xep_0084")] @@ -26,7 +23,7 @@ pub enum Event { } impl FromElement for Event { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("event")?; element.check_namespace(XMLNS)?; @@ -49,7 +46,7 @@ impl FromElement for Event { } impl IntoElement for Event { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("event", Some(XMLNS)); match self { @@ -70,7 +67,7 @@ pub struct Collection { } impl FromElement for Collection { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("node")?; element.check_namespace(XMLNS)?; @@ -82,7 +79,7 @@ impl FromElement for Collection { } impl IntoElement for Collection { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("collection", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_child(self.r#type.clone()) @@ -96,7 +93,7 @@ pub enum CollectionType { } impl FromElement for CollectionType { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "associate") => { Ok(CollectionType::Associate(Associate::from_element(element)?)) @@ -110,7 +107,7 @@ impl FromElement for CollectionType { } impl IntoElement for CollectionType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { CollectionType::Associate(associate) => associate.builder(), CollectionType::Disassociate(disassociate) => disassociate.builder(), @@ -124,7 +121,7 @@ pub struct Associate { } impl FromElement for Associate { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("associate")?; element.check_namespace(XMLNS)?; @@ -135,7 +132,7 @@ impl FromElement for Associate { } impl IntoElement for Associate { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("associate", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -146,7 +143,7 @@ pub struct Disassociate { } impl FromElement for Disassociate { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("disassociate")?; element.check_namespace(XMLNS)?; @@ -157,7 +154,7 @@ impl FromElement for Disassociate { } impl IntoElement for Disassociate { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("disassociate", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -169,7 +166,7 @@ pub struct Configuration { } impl FromElement for Configuration { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("configuration")?; element.check_namespace(XMLNS)?; @@ -185,7 +182,7 @@ impl FromElement for Configuration { } impl IntoElement for Configuration { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("configuration", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_child_opt(self.configuration.clone()) @@ -199,7 +196,7 @@ pub struct Delete { } impl FromElement for Delete { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("delete")?; element.check_namespace(XMLNS)?; @@ -212,7 +209,7 @@ impl FromElement for Delete { } impl IntoElement for Delete { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("delete", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_child_opt(self.redirect.clone()) @@ -226,7 +223,7 @@ pub struct Items { } impl FromElement for Items { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("items")?; element.check_namespace(XMLNS)?; @@ -243,7 +240,7 @@ impl FromElement for Items { } impl IntoElement for Items { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("items", Some(XMLNS)).push_attribute("node", self.node.clone()); @@ -268,7 +265,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -286,7 +283,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)) .push_attribute_opt("id", self.id.clone()) .push_attribute_opt("publisher", self.publisher.clone()) @@ -306,7 +303,7 @@ pub enum Content { } impl FromElement for Content { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { #[cfg(feature = "xep_0172")] (Some(xep_0172::XMLNS), "nick") => Ok(Content::Nick(Nick::from_element(element)?)), @@ -324,7 +321,7 @@ impl FromElement for Content { } impl IntoElement for Content { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { #[cfg(feature = "xep_0172")] Content::Nick(nick) => nick.builder(), @@ -343,7 +340,7 @@ pub struct Purge { } impl FromElement for Purge { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("purge")?; element.check_namespace(XMLNS)?; @@ -354,7 +351,7 @@ impl FromElement for Purge { } impl IntoElement for Purge { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("purge", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -365,7 +362,7 @@ pub struct Redirect { } impl FromElement for Redirect { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("redirect")?; element.check_namespace(XMLNS)?; @@ -376,7 +373,7 @@ impl FromElement for Redirect { } impl IntoElement for Redirect { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("redirect", Some(XMLNS)).push_attribute("uri", self.uri.clone()) } } @@ -387,7 +384,7 @@ pub struct Retract { } impl FromElement for Retract { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("retract")?; element.check_namespace(XMLNS)?; @@ -398,7 +395,7 @@ impl FromElement for Retract { } impl IntoElement for Retract { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("retract", Some(XMLNS)).push_attribute("id", self.id.clone()) } } @@ -413,7 +410,7 @@ pub struct Subscription { } impl FromElement for Subscription { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscription")?; element.check_namespace(XMLNS)?; @@ -434,7 +431,7 @@ impl FromElement for Subscription { } impl IntoElement for Subscription { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscription", Some(XMLNS)) .push_attribute_opt("expiry", self.expiry) .push_attribute("jid", self.jid.clone()) |