From 6b471061157ee1873d7ac4f3e30cd501d27dcb5a Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Sat, 29 Jun 2024 17:06:08 +0100 Subject: WIP: stream parsing --- src/reader.rs | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'src/reader.rs') 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 Reader where R: AsyncBufReadExt + Unpin, { - /// reads entire next prolog, element, or misc - pub async fn read<'s>(&'s mut self) -> Result, 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, String>) -> Result { 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::(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>(&mut self) -> Result { + // 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::(Error::ParseError(input.to_owned())), + // }, + // } + // } + // self.inner.consume(len); + + // // Ok(element) + // todo!() + // } // pub async fn read_start(&self) -> Result, Error> { // todo!() // } -- cgit