use super::error::ParsingError; use super::types as dav; use super::versioningtypes::*; use super::xml::{IRead, QRead, Reader, DAV_URN}; impl QRead> for Report { async fn qread(xml: &mut Reader) -> Result { //@FIXME VersionTree not implemented //@FIXME ExpandTree not implemented E::ReportType::qread(xml).await.map(Report::Extension) } } impl QRead for Limit { async fn qread(xml: &mut Reader) -> Result { xml.open(DAV_URN, "limit").await?; let nres = xml.find().await?; xml.close().await?; Ok(Limit(nres)) } } impl QRead for NResults { async fn qread(xml: &mut Reader) -> Result { xml.open(DAV_URN, "nresults").await?; let sz = xml.tag_string().await?.parse::()?; xml.close().await?; Ok(NResults(sz)) } } #[cfg(test)] mod tests { use super::*; use crate::xml::Node; async fn deserialize>(src: &str) -> T { let mut rdr = Reader::new(quick_xml::NsReader::from_reader(src.as_bytes())) .await .unwrap(); rdr.find().await.unwrap() } #[tokio::test] async fn nresults() { let expected = NResults(100); let src = r#"100"#; let got = deserialize::(src).await; assert_eq!(got, expected); } #[tokio::test] async fn limit() { let expected = Limit(NResults(1024)); let src = r#" 1024 "#; let got = deserialize::(src).await; assert_eq!(got, expected); } }