diff options
author | 2024-12-03 03:51:26 +0000 | |
---|---|---|
committer | 2024-12-03 03:51:26 +0000 | |
commit | 7c2577d196c059ab6e2d5b0efe5e036bdad75be7 (patch) | |
tree | 7649b705f0af85a8b521d8fa849f9ed77e2c201c /src/stanza/stream.rs | |
parent | be198ca15bbaf633c1535db5bae7091520546aed (diff) | |
download | luz-7c2577d196c059ab6e2d5b0efe5e036bdad75be7.tar.gz luz-7c2577d196c059ab6e2d5b0efe5e036bdad75be7.tar.bz2 luz-7c2577d196c059ab6e2d5b0efe5e036bdad75be7.zip |
implement remaining rfc6120 xml schemas
Diffstat (limited to 'src/stanza/stream.rs')
-rw-r--r-- | src/stanza/stream.rs | 30 |
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()) + } +} |