aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-06-29 17:06:08 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2024-06-29 17:06:08 +0100
commit6b471061157ee1873d7ac4f3e30cd501d27dcb5a (patch)
tree8187081b398c715e72c461682d62db1eb428a39f /src/reader.rs
parent1f0103cbecc6a4dfe3f34fb6441d4d491b385142 (diff)
downloadpeanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.tar.gz
peanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.tar.bz2
peanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.zip
WIP: stream parsingHEADmain
Diffstat (limited to 'src/reader.rs')
-rw-r--r--src/reader.rs45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/reader.rs b/src/reader.rs
index 2785c88..b0d21db 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -1,6 +1,6 @@
use futures::Stream;
use nom::Err;
-use std::str;
+use std::{collections::BTreeMap, str};
use tokio::io::AsyncBufReadExt;
use crate::{
@@ -30,8 +30,8 @@ impl<R> Reader<R>
where
R: AsyncBufReadExt + Unpin,
{
- /// reads entire next prolog, element, or misc
- pub async fn read<'s>(&'s mut self) -> Result<crate::xml::Element<'s>, Error> {
+ /// could resursively read and include namespace tree with values to be shadowed within new local context
+ async fn read_recursive(&mut self, namespaces: BTreeMap<Option<String>, String>) -> Result<Element, Error> {
let element;
let len;
loop {
@@ -45,15 +45,48 @@ where
}
Err(e) => match e {
Err::Incomplete(_) => (),
- e => return Err(Error::ParseError(input.to_owned())),
+ e => return Err::<E, Error>(Error::ParseError(input.to_owned())),
},
}
}
- self.inner.consume(len);
- // Ok(element)
+ let final;
+ match element {
+ crate::xml::Element::Empty(e) => {
+ let final = Element {
+
+ }
+ },
+ crate::xml::Element::NotEmpty(_, _, _) => todo!(),
+ }
+
+ self.inner.consume(len);
todo!()
}
+ /// reads entire next prolog, element, or misc
+ // pub async fn read<E: From<Element>>(&mut self) -> Result<E, Error> {
+ // let element;
+ // let len;
+ // loop {
+ // let buf = self.inner.fill_buf().await?;
+ // let input = str::from_utf8(buf)?;
+ // match crate::xml::element(input) {
+ // Ok((rest, e)) => {
+ // element = e;
+ // len = buf.len() - rest.len();
+ // break;
+ // }
+ // Err(e) => match e {
+ // Err::Incomplete(_) => (),
+ // e => return Err::<E, Error>(Error::ParseError(input.to_owned())),
+ // },
+ // }
+ // }
+ // self.inner.consume(len);
+
+ // // Ok(element)
+ // todo!()
+ // }
// pub async fn read_start(&self) -> Result<impl From<Element>, Error> {
// todo!()
// }