2024-03-04 16:14:28 +00:00
|
|
|
use futures::Stream;
|
2024-06-12 10:15:48 +01:00
|
|
|
use tokio::io::AsyncBufRead;
|
2024-03-04 16:14:28 +00:00
|
|
|
|
|
|
|
use crate::{
|
|
|
|
element::{Element, Name, Namespace},
|
|
|
|
error::Error,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// streaming reader that tracks depth and available namespaces at current depth
|
|
|
|
pub struct Reader<R> {
|
|
|
|
stream: R,
|
|
|
|
// holds which tags we are in atm over depth
|
|
|
|
depth: Vec<Name>,
|
|
|
|
namespaces: Vec<(usize, Namespace)>,
|
|
|
|
}
|
|
|
|
|
2024-06-12 10:15:48 +01:00
|
|
|
impl<R> Reader<R>
|
|
|
|
where
|
|
|
|
R: AsyncBufRead,
|
|
|
|
{
|
|
|
|
pub async fn read(&self) -> Result<impl From<Element>, Error> {
|
|
|
|
let buf = self.stream.poll_fill_buf().await?;
|
|
|
|
todo!()
|
|
|
|
}
|
2024-03-04 16:14:28 +00:00
|
|
|
pub async fn read_start(&self) -> Result<impl From<Element>, Error> {}
|
|
|
|
pub async fn read_end(&self) -> Result<(), Error> {}
|
|
|
|
}
|
|
|
|
|
2024-06-12 10:15:48 +01:00
|
|
|
impl<R: AsyncBufRead> Stream for Reader<R> {
|
2024-03-04 16:14:28 +00:00
|
|
|
type Item = impl From<Element>;
|
|
|
|
|
|
|
|
async fn poll_next(
|
|
|
|
self: std::pin::Pin<&mut Self>,
|
|
|
|
cx: &mut std::task::Context<'_>,
|
|
|
|
) -> std::task::Poll<Option<Self::Item>> {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|