implement write end tag

This commit is contained in:
cel 🌸 2024-11-19 16:46:51 +00:00
parent caf8b7506e
commit 0175a2d365
1 changed files with 31 additions and 23 deletions

View File

@ -13,7 +13,7 @@ use crate::{
pub struct Writer<W> { pub struct Writer<W> {
inner: W, inner: W,
depth: Vec<Name>, depth: Vec<Name>,
namespaces: Vec<HashSet<NamespaceDeclaration>>, namespace_declarations: Vec<HashSet<NamespaceDeclaration>>,
} }
impl<W: AsyncWrite + Unpin> Writer<W> { impl<W: AsyncWrite + Unpin> Writer<W> {
@ -26,28 +26,36 @@ impl<W: AsyncWrite + Unpin> Writer<W> {
} }
pub async fn write_end(&mut self) -> Result<(), Error> { pub async fn write_end(&mut self) -> Result<(), Error> {
todo!() let e_tag;
// let e_tag; if let Some(name) = &self.depth.pop() {
// if let Some(name) = self.depth.pop() { let namespace_declarations_stack: Vec<_> =
// if let Some(prefix) = name.namespace.prefix { self.namespace_declarations.iter().flatten().collect();
// e_tag = xml::ETag { let namespace_declaration = namespace_declarations_stack
// name: xml::QName::PrefixedName(xml::PrefixedName { .iter()
// prefix: xml::Prefix::parse_full(&prefix)?, .rfind(|namespace_declaration| namespace_declaration.namespace == name.namespace)
// local_part: xml::LocalPart::parse_full(&name.name)?, // will always be in this vector
// }), .unwrap();
// }; let prefix = &namespace_declaration.prefix;
// e_tag.write(&mut self.inner).await?; if let Some(prefix) = &prefix {
// Ok(()) e_tag = xml::ETag {
// } else { name: xml::QName::PrefixedName(xml::PrefixedName {
// e_tag = xml::ETag { prefix: xml::Prefix::parse_full(prefix)?,
// name: xml::QName::UnprefixedName(xml::UnprefixedName::parse_full(&name.name)?), local_part: xml::LocalPart::parse_full(&name.local_name)?,
// }; }),
// e_tag.write(&mut self.inner).await?; };
// Ok(()) } else {
// } e_tag = xml::ETag {
// } else { name: xml::QName::UnprefixedName(xml::UnprefixedName::parse_full(
// return Err(Error::NotInElement("".to_string())); &name.local_name,
// } )?),
};
}
e_tag.write(&mut self.inner).await?;
self.namespace_declarations.pop();
Ok(())
} else {
return Err(Error::NotInElement("".to_string()));
}
} }
} }