diff --git a/src/main.rs b/src/main.rs index b08c197..ef69011 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ -use peanuts::xml::document; +use peanuts::xml::parsers::Parser; +use peanuts::xml::Document; fn main() { - let document = document( + let document = Document::parse( " Background Mark 1 diff --git a/src/reader.rs b/src/reader.rs index b0d21db..313de4c 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -26,74 +26,74 @@ impl Reader { } } -impl Reader -where - R: AsyncBufReadExt + Unpin, -{ - /// 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 { - 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())), - }, - } - } +// impl Reader +// where +// R: AsyncBufReadExt + Unpin, +// { +// /// 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 { +// 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())), +// }, +// } +// } - let final; - match element { - crate::xml::Element::Empty(e) => { - let final = Element { - - } - }, - crate::xml::Element::NotEmpty(_, _, _) => todo!(), - } +// let final; +// match element { +// crate::xml::Element::Empty(e) => { +// let final = Element { - 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); +// } +// }, +// crate::xml::Element::NotEmpty(_, _, _) => todo!(), +// } - // // Ok(element) - // todo!() - // } - // pub async fn read_start(&self) -> Result, Error> { - // todo!() - // } - // pub async fn read_end(&self) -> Result<(), Error> { - // 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!() +// } +// pub async fn read_end(&self) -> Result<(), Error> { +// todo!() +// } +// } // impl Stream for Reader { // type Item = impl From; diff --git a/src/xml/mod.rs b/src/xml/mod.rs index b1d6ea5..d1b9ddf 100644 --- a/src/xml/mod.rs +++ b/src/xml/mod.rs @@ -1,6 +1,6 @@ use std::char; -mod parsers; +pub mod parsers; /// [1] NSAttName ::= PrefixedAttName | DefaultAttName #[derive(Clone, Debug)]