diff options
Diffstat (limited to 'stanza/src/xep_0059.rs')
-rw-r--r-- | stanza/src/xep_0059.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/stanza/src/xep_0059.rs b/stanza/src/xep_0059.rs index 01dbc6c..6490ad1 100644 --- a/stanza/src/xep_0059.rs +++ b/stanza/src/xep_0059.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "http://jabber.org/protocol/rsm"; @@ -17,7 +14,7 @@ pub struct Set { } impl FromElement for Set { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("set")?; element.check_namespace(XMLNS)?; @@ -42,7 +39,7 @@ impl FromElement for Set { } impl IntoElement for Set { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("set", Some(XMLNS)) .push_child_opt(self.after.clone()) .push_child_opt(self.before.clone()) @@ -58,7 +55,7 @@ impl IntoElement for Set { pub struct After(pub String); impl FromElement for After { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("after")?; element.check_namespace(XMLNS)?; @@ -67,7 +64,7 @@ impl FromElement for After { } impl IntoElement for After { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("after", Some(XMLNS)); @@ -83,7 +80,7 @@ impl IntoElement for After { pub struct Before(pub String); impl FromElement for Before { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("before")?; element.check_namespace(XMLNS)?; @@ -92,7 +89,7 @@ impl FromElement for Before { } impl IntoElement for Before { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("before", Some(XMLNS)); @@ -108,7 +105,7 @@ impl IntoElement for Before { pub struct Count(pub i32); impl FromElement for Count { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("count")?; element.check_namespace(XMLNS)?; @@ -117,7 +114,7 @@ impl FromElement for Count { } impl IntoElement for Count { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("count", Some(XMLNS)).push_text(self.0) } } @@ -126,7 +123,7 @@ impl IntoElement for Count { pub struct Index(pub i32); impl FromElement for Index { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("index")?; element.check_namespace(XMLNS)?; @@ -135,7 +132,7 @@ impl FromElement for Index { } impl IntoElement for Index { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("index", Some(XMLNS)).push_text(self.0) } } @@ -144,7 +141,7 @@ impl IntoElement for Index { pub struct Last(pub String); impl FromElement for Last { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("last")?; element.check_namespace(XMLNS)?; @@ -153,7 +150,7 @@ impl FromElement for Last { } impl IntoElement for Last { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("last", Some(XMLNS)); @@ -169,7 +166,7 @@ impl IntoElement for Last { pub struct Max(pub i32); impl FromElement for Max { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("max")?; element.check_namespace(XMLNS)?; @@ -178,7 +175,7 @@ impl FromElement for Max { } impl IntoElement for Max { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("max", Some(XMLNS)).push_text(self.0) } } @@ -190,7 +187,7 @@ pub struct First { } impl FromElement for First { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("first")?; element.check_namespace(XMLNS)?; @@ -203,7 +200,7 @@ impl FromElement for First { } impl IntoElement for First { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("first", Some(XMLNS)).push_attribute_opt("index", self.index); |