async-xml-derive

Crates.ioasync-xml-derive
lib.rsasync-xml-derive
version0.2.3
sourcesrc
created_at2022-07-04 21:33:16.767678
updated_at2022-11-07 10:57:10.534104
descriptionDerive macros for async-xml
homepagehttps://github.com/relaxdays/async-xml
repositoryhttps://github.com/relaxdays/async-xml
max_upload_size
id619208
size58,713
Sophie Tauchert (999eagle)

documentation

README

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.

Commit count: 40

cargo fmt