diff options
Diffstat (limited to 'src/stanza/bind.rs')
-rw-r--r-- | src/stanza/bind.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/stanza/bind.rs b/src/stanza/bind.rs index f1bdc2d..5e9704f 100644 --- a/src/stanza/bind.rs +++ b/src/stanza/bind.rs @@ -1,10 +1,12 @@ +use std::collections::BTreeMap; + use quick_xml::{ events::{BytesStart, BytesText, Event}, name::QName, Reader, }; -use super::{Element, IntoElement}; +use super::{Element, IntoElement, Node}; use crate::{JabberError, JID}; const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-bind"; @@ -14,7 +16,30 @@ pub struct Bind { pub jid: Option<JID>, } -impl<'e> IntoElement<'e> for Bind { +impl From<Bind> for Element { + fn from(value: Bind) -> Self { + let mut namespace_declarations = Box::new(BTreeMap::new()); + namespace_declarations.insert(None, XMLNS.to_owned()); + let mut children = Vec::new(); + if let Some(resource) = value.resource { + children.push(Node::Element( + Element { prefix: None, localname: "", namespace: , namespace_declarations: , attributes: , children: } + ) + + ) + } + Self { + prefix: None, + localname: "bind".to_string(), + namespace: XMLNS.to_owned(), + namespace_declarations, + attributes: todo!(), + children: todo!(), + } + } +} + +impl IntoElement for Bind { fn event(&self) -> quick_xml::events::Event<'static> { let mut bind_event = BytesStart::new("bind"); bind_event.push_attribute(("xmlns", XMLNS)); |