#xml-data #deserialize #async

async-xml

A crate for deserializing XML data asynchronously

5 releases

0.2.3 Nov 7, 2022
0.2.2 Sep 12, 2022
0.2.1 Sep 12, 2022
0.2.0 Sep 9, 2022
0.0.0 Jul 4, 2022

#706 in Asynchronous

MIT/Apache

34KB
808 lines

async-xml

crates.io crates.io

A crate based on tokio and quick-xml for deserializing XML data asynchronously. Includes derive-macros for deserializing things.

Example

use async_xml::from_str;
use async_xml_derive::FromXml;

#[tokio::main]
async fn main() {
    let report: Report = from_str(r#"<report id="b"><data>text</data></report>"#)
        .await
        .unwrap();
    println!("deserialized: {:?}", report);
	// prints "Report { id: "b", data: Some(ReportData { data: "text" }) }"
}

#[derive(Debug, PartialEq, FromXml)]
#[async_xml(rename = "report")]
pub struct Report {
    #[async_xml(attribute)]
    pub id: String,
    #[async_xml(child)]
    pub data: Option<ReportData>,
}

#[derive(Debug, PartialEq, FromXml)]
#[async_xml(rename = "data")]
pub struct ReportData {
    #[async_xml(value)]
    pub data: String,
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the fork by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~9MB
~211K SLoC