diff options
Diffstat (limited to 'src/stanza/sasl.rs')
-rw-r--r-- | src/stanza/sasl.rs | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/stanza/sasl.rs b/src/stanza/sasl.rs index bbf3f41..50ffd83 100644 --- a/src/stanza/sasl.rs +++ b/src/stanza/sasl.rs @@ -7,6 +7,7 @@ use crate::error::SASLError; use crate::JabberError; use super::Element; +use super::IntoElement; const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-sasl"; @@ -16,7 +17,7 @@ pub struct Auth<'e> { pub sasl_data: &'e str, } -impl<'e> Auth<'e> { +impl<'e> IntoElement<'e> for Auth<'e> { fn event(&self) -> Event<'e> { let mut start = BytesStart::new("auth"); start.push_attribute(("xmlns", XMLNS)); @@ -34,15 +35,6 @@ impl<'e> Auth<'e> { } } -impl<'e> Into<Element<'e>> for Auth<'e> { - fn into(self) -> Element<'e> { - Element { - event: self.event(), - children: self.children(), - } - } -} - #[derive(Debug)] pub struct Challenge { pub sasl_data: Vec<u8>, @@ -54,7 +46,7 @@ impl<'e> TryFrom<&Element<'e>> for Challenge { fn try_from(element: &Element<'e>) -> Result<Challenge, Self::Error> { if let Event::Start(start) = &element.event { if start.name() == QName(b"challenge") { - let sasl_data: &Element<'_> = super::child(element)?; + let sasl_data: &Element<'_> = element.child()?; if let Event::Text(sasl_data) = &sasl_data.event { let s = sasl_data.clone(); let s = s.into_inner(); @@ -101,7 +93,7 @@ pub struct Response<'e> { pub sasl_data: &'e str, } -impl<'e> Response<'e> { +impl<'e> IntoElement<'e> for Response<'e> { fn event(&self) -> Event<'e> { let mut start = BytesStart::new("response"); start.push_attribute(("xmlns", XMLNS)); @@ -118,15 +110,6 @@ impl<'e> Response<'e> { } } -impl<'e> Into<Element<'e>> for Response<'e> { - fn into(self) -> Element<'e> { - Element { - event: self.event(), - children: self.children(), - } - } -} - #[derive(Debug)] pub struct Success { pub sasl_data: Option<Vec<u8>>, @@ -139,7 +122,7 @@ impl<'e> TryFrom<&Element<'e>> for Success { match &element.event { Event::Start(start) => { if start.name() == QName(b"success") { - match super::child(element) { + match element.child() { Ok(sasl_data) => { if let Event::Text(sasl_data) = &sasl_data.event { return Ok(Success { |