From 5334cd4ed69d12e4265b8b97ae9e7ed02f78a9ff Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Sat, 5 Aug 2023 20:14:09 +0100 Subject: WIP: refactor Element type - namespace work --- src/stanza/bind.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/stanza/bind.rs') 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, } -impl<'e> IntoElement<'e> for Bind { +impl From 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)); -- cgit