2024-11-19 14:52:14 +00:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
|
|
use futures::Sink;
|
|
|
|
use tokio::io::AsyncWrite;
|
2024-03-04 16:14:28 +00:00
|
|
|
|
|
|
|
use crate::{
|
2024-11-19 14:52:14 +00:00
|
|
|
element::{Element, Name, NamespaceDeclaration},
|
2024-03-04 16:14:28 +00:00
|
|
|
error::Error,
|
2024-11-19 14:52:14 +00:00
|
|
|
xml::{self, composers::Composer, parsers_complete::Parser, ETag},
|
2024-03-04 16:14:28 +00:00
|
|
|
};
|
|
|
|
|
2024-11-01 18:36:11 +00:00
|
|
|
// pub struct Writer<W, C = Composer> {
|
2024-03-04 16:14:28 +00:00
|
|
|
pub struct Writer<W> {
|
2024-11-19 14:52:14 +00:00
|
|
|
inner: W,
|
2024-03-04 16:14:28 +00:00
|
|
|
depth: Vec<Name>,
|
2024-11-19 14:52:14 +00:00
|
|
|
namespaces: Vec<HashSet<NamespaceDeclaration>>,
|
2024-03-04 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2024-11-19 14:52:14 +00:00
|
|
|
impl<W: AsyncWrite + Unpin> Writer<W> {
|
|
|
|
pub async fn write(&mut self, element: Element) -> Result<(), Error> {
|
2024-06-14 13:11:32 +01:00
|
|
|
todo!()
|
|
|
|
}
|
2024-11-19 14:52:14 +00:00
|
|
|
|
|
|
|
pub async fn write_start(&mut self, element: Element) -> Result<(), Error> {
|
2024-06-14 13:11:32 +01:00
|
|
|
todo!()
|
|
|
|
}
|
2024-11-19 14:52:14 +00:00
|
|
|
|
|
|
|
pub async fn write_end(&mut self) -> Result<(), Error> {
|
2024-06-14 13:11:32 +01:00
|
|
|
todo!()
|
2024-11-19 14:52:14 +00:00
|
|
|
// let e_tag;
|
|
|
|
// if let Some(name) = self.depth.pop() {
|
|
|
|
// if let Some(prefix) = name.namespace.prefix {
|
|
|
|
// e_tag = xml::ETag {
|
|
|
|
// name: xml::QName::PrefixedName(xml::PrefixedName {
|
|
|
|
// prefix: xml::Prefix::parse_full(&prefix)?,
|
|
|
|
// local_part: xml::LocalPart::parse_full(&name.name)?,
|
|
|
|
// }),
|
|
|
|
// };
|
|
|
|
// e_tag.write(&mut self.inner).await?;
|
|
|
|
// Ok(())
|
|
|
|
// } else {
|
|
|
|
// e_tag = xml::ETag {
|
|
|
|
// name: xml::QName::UnprefixedName(xml::UnprefixedName::parse_full(&name.name)?),
|
|
|
|
// };
|
|
|
|
// e_tag.write(&mut self.inner).await?;
|
|
|
|
// Ok(())
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// return Err(Error::NotInElement("".to_string()));
|
|
|
|
// }
|
2024-06-14 13:11:32 +01:00
|
|
|
}
|
2024-03-04 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<W: AsyncWrite, E: Into<Element>> Sink<E> for Writer<W> {
|
|
|
|
type Error = Error;
|
|
|
|
|
|
|
|
fn poll_ready(
|
|
|
|
self: std::pin::Pin<&mut Self>,
|
|
|
|
cx: &mut std::task::Context<'_>,
|
|
|
|
) -> std::task::Poll<Result<(), Self::Error>> {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn start_send(self: std::pin::Pin<&mut Self>, item: E) -> Result<(), Self::Error> {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn poll_flush(
|
|
|
|
self: std::pin::Pin<&mut Self>,
|
|
|
|
cx: &mut std::task::Context<'_>,
|
|
|
|
) -> std::task::Poll<Result<(), Self::Error>> {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn poll_close(
|
|
|
|
self: std::pin::Pin<&mut Self>,
|
|
|
|
cx: &mut std::task::Context<'_>,
|
|
|
|
) -> std::task::Poll<Result<(), Self::Error>> {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|