diff options
Diffstat (limited to 'stanza/src/bind.rs')
-rw-r--r-- | stanza/src/bind.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/stanza/src/bind.rs b/stanza/src/bind.rs index f72c510..3ce2246 100644 --- a/stanza/src/bind.rs +++ b/stanza/src/bind.rs @@ -1,8 +1,5 @@ use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-bind"; @@ -12,7 +9,7 @@ pub struct Bind { } impl FromElement for Bind { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("bind")?; element.check_namespace(XMLNS)?; @@ -23,7 +20,7 @@ impl FromElement for Bind { } impl IntoElement for Bind { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("bind", Some(XMLNS)).push_child_opt(self.r#type.clone()) } } @@ -35,7 +32,7 @@ pub enum BindType { } impl FromElement for BindType { - fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: peanuts::Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "resource") => { Ok(BindType::Resource(ResourceType::from_element(element)?)) @@ -47,7 +44,7 @@ impl FromElement for BindType { } impl IntoElement for BindType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { BindType::Resource(resource_type) => resource_type.builder(), BindType::Jid(full_jid_type) => full_jid_type.builder(), @@ -60,7 +57,7 @@ impl IntoElement for BindType { pub struct FullJidType(pub JID); impl FromElement for FullJidType { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("jid")?; element.check_namespace(XMLNS)?; @@ -71,7 +68,7 @@ impl FromElement for FullJidType { } impl IntoElement for FullJidType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("jid", Some(XMLNS)).push_text(self.0.clone()) } } @@ -81,7 +78,7 @@ impl IntoElement for FullJidType { pub struct ResourceType(pub String); impl FromElement for ResourceType { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("resource")?; element.check_namespace(XMLNS)?; @@ -92,7 +89,7 @@ impl FromElement for ResourceType { } impl IntoElement for ResourceType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("resource", Some(XMLNS)).push_text(self.0.clone()) } } |