add some tracing
This commit is contained in:
		
							parent
							
								
									aa940a8eac
								
							
						
					
					
						commit
						2dae043e8f
					
				| 
						 | 
				
			
			@ -256,6 +256,12 @@ version = "0.24.0"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "once_cell"
 | 
			
		||||
version = "1.20.2"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "parking_lot"
 | 
			
		||||
version = "0.12.3"
 | 
			
		||||
| 
						 | 
				
			
			@ -288,6 +294,7 @@ dependencies = [
 | 
			
		|||
 "futures",
 | 
			
		||||
 "nom",
 | 
			
		||||
 "tokio",
 | 
			
		||||
 "tracing",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
| 
						 | 
				
			
			@ -416,6 +423,37 @@ dependencies = [
 | 
			
		|||
 "syn",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "tracing"
 | 
			
		||||
version = "0.1.41"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "pin-project-lite",
 | 
			
		||||
 "tracing-attributes",
 | 
			
		||||
 "tracing-core",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "tracing-attributes"
 | 
			
		||||
version = "0.1.28"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "syn",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "tracing-core"
 | 
			
		||||
version = "0.1.33"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "once_cell",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "unicode-ident"
 | 
			
		||||
version = "1.0.12"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,3 +11,4 @@ circular = { version = "0.3.0", path = "../circular" }
 | 
			
		|||
futures = "0.3.30"
 | 
			
		||||
nom = "7.1.3"
 | 
			
		||||
tokio = { version = "1.36.0", features = ["io-util", "net", "io-std", "full"] }
 | 
			
		||||
tracing = "0.1.41"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,8 @@ use std::{
 | 
			
		|||
    str::FromStr,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
use tracing::debug;
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
    error::{DeserializeError, Error},
 | 
			
		||||
    xml::{self, parsers_complete::Parser, Attribute},
 | 
			
		||||
| 
						 | 
				
			
			@ -322,17 +324,28 @@ impl Element {
 | 
			
		|||
        let mut children = Vec::new();
 | 
			
		||||
        loop {
 | 
			
		||||
            let child = self.content.front();
 | 
			
		||||
            debug!("child: {:?}", child);
 | 
			
		||||
            if let Some(child) = child {
 | 
			
		||||
                match child {
 | 
			
		||||
                    Content::Element(element) => {
 | 
			
		||||
                        if let Ok(child) = <T as FromElement>::from_element(element.clone()) {
 | 
			
		||||
                            debug!("parsed child");
 | 
			
		||||
                            children.push(child);
 | 
			
		||||
                            self.content.pop_front();
 | 
			
		||||
                        } else {
 | 
			
		||||
                            debug!("failed to parse child");
 | 
			
		||||
                            return Ok(children);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    Content::Text(_) => return Ok(children),
 | 
			
		||||
                    Content::PI => {}
 | 
			
		||||
                    Content::Comment(_) => {}
 | 
			
		||||
                    Content::PI => {
 | 
			
		||||
                        self.content.pop_front();
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                    Content::Comment(_) => {
 | 
			
		||||
                        self.content.pop_front();
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                return Ok(children);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@ pub enum DeserializeError {
 | 
			
		|||
    FromStr(String),
 | 
			
		||||
    UnexpectedAttributes(HashMap<Name, String>),
 | 
			
		||||
    UnexpectedContent(VecDeque<Content>),
 | 
			
		||||
    UnexpectedElement(Element),
 | 
			
		||||
    MissingAttribute(Name),
 | 
			
		||||
    IncorrectName(String),
 | 
			
		||||
    IncorrectNamespace(String),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@ use std::{
 | 
			
		|||
    str::{self, FromStr},
 | 
			
		||||
};
 | 
			
		||||
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncReadExt};
 | 
			
		||||
use tracing::debug;
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
    declaration::{Declaration, VersionInfo},
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +22,7 @@ use crate::{
 | 
			
		|||
static MAX_STANZA_SIZE: usize = 65536;
 | 
			
		||||
 | 
			
		||||
/// streaming reader that tracks depth and available namespaces at current depth
 | 
			
		||||
#[derive(Debug)]
 | 
			
		||||
pub struct Reader<R> {
 | 
			
		||||
    inner: R,
 | 
			
		||||
    pub buffer: Buffer,
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +61,7 @@ impl<R> Reader<R>
 | 
			
		|||
where
 | 
			
		||||
    R: AsyncRead + Unpin,
 | 
			
		||||
{
 | 
			
		||||
    async fn read_buf<'s>(&mut self) -> Result<usize> {
 | 
			
		||||
    pub async fn read_buf<'s>(&mut self) -> Result<usize> {
 | 
			
		||||
        Ok(self.inner.read_buf(&mut self.buffer).await?)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -107,6 +109,7 @@ where
 | 
			
		|||
 | 
			
		||||
    pub async fn read<'s, T: FromElement>(&'s mut self) -> Result<T> {
 | 
			
		||||
        let element = self.read_element().await?;
 | 
			
		||||
        debug!("read element: {:?}", element);
 | 
			
		||||
        Ok(FromElement::from_element(element)?)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@ use crate::{
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
// pub struct Writer<W, C = Composer> {
 | 
			
		||||
#[derive(Debug)]
 | 
			
		||||
pub struct Writer<W> {
 | 
			
		||||
    inner: W,
 | 
			
		||||
    depth: Vec<Name>,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue