aboutsummaryrefslogtreecommitdiffstats
path: root/src/stanza/stream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/stanza/stream.rs')
-rw-r--r--src/stanza/stream.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/stanza/stream.rs b/src/stanza/stream.rs
index c49a2bc..4f3c435 100644
--- a/src/stanza/stream.rs
+++ b/src/stanza/stream.rs
@@ -6,11 +6,12 @@ use peanuts::{element::Name, Element};
use tracing::debug;
use crate::stanza::bind;
-use crate::{Error, JID};
+use crate::JID;
-use super::client;
use super::sasl::{self, Mechanisms};
use super::starttls::{self, StartTls};
+use super::stream_error::{Error as StreamError, Text};
+use super::{client, stream_error};
pub const XMLNS: &str = "http://etherx.jabber.org/streams";
@@ -162,3 +163,28 @@ impl FromElement for Feature {
}
}
}
+
+pub struct Error {
+ error: StreamError,
+ text: Option<Text>,
+}
+
+impl FromElement for Error {
+ fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> {
+ element.check_name("error")?;
+ element.check_namespace(XMLNS)?;
+
+ let error = element.pop_child_one()?;
+ let text = element.pop_child_opt()?;
+
+ Ok(Error { error, text })
+ }
+}
+
+impl IntoElement for Error {
+ fn builder(&self) -> ElementBuilder {
+ Element::builder("error", Some(XMLNS))
+ .push_child(self.error.clone())
+ .push_child_opt(self.text.clone())
+ }
+}