Crates.io | async-xml |
lib.rs | async-xml |
version | 0.2.3 |
source | src |
created_at | 2022-07-04 21:37:28.20311 |
updated_at | 2022-11-07 10:57:43.67018 |
description | A crate for deserializing XML data asynchronously. |
homepage | https://github.com/relaxdays/async-xml |
repository | https://github.com/relaxdays/async-xml |
max_upload_size | |
id | 619213 |
size | 73,037 |
A crate based on tokio
and quick-xml
for deserializing XML data asynchronously. Includes derive-macros for deserializing things.
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,
}
Licensed under either of
at your option.
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.