aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.rs
blob: 05afc734f00b4cce323eec521d8aebb59abd8c9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use futures::Stream;
use tokio::io::AsyncRead;

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)>,
}

impl<R: AsyncRead> Reader<R> {
    pub async fn read(&self) -> Result<impl From<Element>, Error> {}
    pub async fn read_start(&self) -> Result<impl From<Element>, Error> {}
    pub async fn read_end(&self) -> Result<(), Error> {}
}

impl<R: AsyncRead> Stream for Reader<R> {
    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!()
    }
}