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() {
let document = document(
let document = Document::parse(
"<?xml version=\"1.0\"?>
<TEST>
<block1>Background Mark 1</block1>

View File

@ -26,74 +26,74 @@ impl<R> Reader<R> {
}
}
impl<R> Reader<R>
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<Option<String>, String>) -> Result<Element, 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())),
},
}
}
// impl<R> Reader<R>
// 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<Option<String>, String>) -> Result<Element, 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())),
// },
// }
// }
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<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);
// }
// },
// crate::xml::Element::NotEmpty(_, _, _) => todo!(),
// }
// // Ok(element)
// todo!()
// }
// pub async fn read_start(&self) -> Result<impl From<Element>, 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<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!()
// }
// pub async fn read_end(&self) -> Result<(), Error> {
// todo!()
// }
// }
// impl<R: AsyncBufRead> Stream for Reader<R> {
// type Item = impl From<Element>;

View File

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