summaryrefslogtreecommitdiffstats
path: root/src/stanza/sasl.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-08-02 00:56:38 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2023-08-02 00:56:38 +0100
commitcd7bb95c0a31d187bfe25bad15043f0b33b111cf (patch)
treec5be0c651198abf736f8867a36906f9345f3a0ac /src/stanza/sasl.rs
parent322b2a3b46348ec1c5acbc538de93310c9030b96 (diff)
downloadluz-cd7bb95c0a31d187bfe25bad15043f0b33b111cf.tar.gz
luz-cd7bb95c0a31d187bfe25bad15043f0b33b111cf.tar.bz2
luz-cd7bb95c0a31d187bfe25bad15043f0b33b111cf.zip
implement resource binding
Diffstat (limited to '')
-rw-r--r--src/stanza/sasl.rs27
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 {