fix build

This commit is contained in:
cel 🌸 2024-10-31 20:54:19 +00:00
parent 793bc4bfea
commit ceb1bca7a4
3 changed files with 69 additions and 68 deletions

View File

@ -1,7 +1,8 @@
use peanuts::xml::document; use peanuts::xml::parsers::Parser;
use peanuts::xml::Document;
fn main() { fn main() {
let document = document( let document = Document::parse(
"<?xml version=\"1.0\"?> "<?xml version=\"1.0\"?>
<TEST> <TEST>
<block1>Background Mark 1</block1> <block1>Background Mark 1</block1>

View File

@ -26,74 +26,74 @@ impl<R> Reader<R> {
} }
} }
impl<R> Reader<R> // impl<R> Reader<R>
where // where
R: AsyncBufReadExt + Unpin, // R: AsyncBufReadExt + Unpin,
{ // {
/// could resursively read and include namespace tree with values to be shadowed within new local context // /// 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> { // async fn read_recursive(&mut self, namespaces: BTreeMap<Option<String>, String>) -> Result<Element, Error> {
let element; // let element;
let len; // let len;
loop { // loop {
let buf = self.inner.fill_buf().await?; // let buf = self.inner.fill_buf().await?;
let input = str::from_utf8(buf)?; // let input = str::from_utf8(buf)?;
match crate::xml::element(input) { // match crate::xml::element(input) {
Ok((rest, e)) => { // Ok((rest, e)) => {
element = e; // element = e;
len = buf.len() - rest.len(); // len = buf.len() - rest.len();
break; // break;
} // }
Err(e) => match e { // Err(e) => match e {
Err::Incomplete(_) => (), // Err::Incomplete(_) => (),
e => return Err::<E, Error>(Error::ParseError(input.to_owned())), // e => return Err::<E, Error>(Error::ParseError(input.to_owned())),
}, // },
} // }
} // }
let final; // let final;
match element { // match element {
crate::xml::Element::Empty(e) => { // crate::xml::Element::Empty(e) => {
let final = Element { // let final = Element {
} // }
}, // },
crate::xml::Element::NotEmpty(_, _, _) => todo!(), // crate::xml::Element::NotEmpty(_, _, _) => todo!(),
} // }
self.inner.consume(len); // self.inner.consume(len);
todo!() // todo!()
} // }
/// reads entire next prolog, element, or misc // /// reads entire next prolog, element, or misc
// pub async fn read<E: From<Element>>(&mut self) -> Result<E, Error> { // pub async fn read<E: From<Element>>(&mut self) -> Result<E, Error> {
// let element; // let element;
// let len; // let len;
// loop { // loop {
// let buf = self.inner.fill_buf().await?; // let buf = self.inner.fill_buf().await?;
// let input = str::from_utf8(buf)?; // let input = str::from_utf8(buf)?;
// match crate::xml::element(input) { // match crate::xml::element(input) {
// Ok((rest, e)) => { // Ok((rest, e)) => {
// element = e; // element = e;
// len = buf.len() - rest.len(); // len = buf.len() - rest.len();
// break; // break;
// } // }
// Err(e) => match e { // Err(e) => match e {
// Err::Incomplete(_) => (), // Err::Incomplete(_) => (),
// e => return Err::<E, Error>(Error::ParseError(input.to_owned())), // e => return Err::<E, Error>(Error::ParseError(input.to_owned())),
// }, // },
// } // }
// } // }
// self.inner.consume(len); // self.inner.consume(len);
// // Ok(element) // // Ok(element)
// todo!() // todo!()
// } // }
// pub async fn read_start(&self) -> Result<impl From<Element>, Error> { // pub async fn read_start(&self) -> Result<impl From<Element>, Error> {
// todo!() // todo!()
// } // }
// pub async fn read_end(&self) -> Result<(), Error> { // pub async fn read_end(&self) -> Result<(), Error> {
// todo!() // todo!()
// } // }
} // }
// impl<R: AsyncBufRead> Stream for Reader<R> { // impl<R: AsyncBufRead> Stream for Reader<R> {
// type Item = impl From<Element>; // type Item = impl From<Element>;

View File

@ -1,6 +1,6 @@
use std::char; use std::char;
mod parsers; pub mod parsers;
/// [1] NSAttName ::= PrefixedAttName | DefaultAttName /// [1] NSAttName ::= PrefixedAttName | DefaultAttName
#[derive(Clone, Debug)] #[derive(Clone, Debug)]