Crates.io | serde-xml-rust |
lib.rs | serde-xml-rust |
version | 0.6.0 |
source | src |
created_at | 2024-01-24 23:25:52.087088 |
updated_at | 2024-01-24 23:25:52.087088 |
description | Maintained fork of xml-rs based deserializer for Serde (compatible with 0.9+) |
homepage | |
repository | https://github.com/cr8t/serde-xml-rs |
max_upload_size | |
id | 1113083 |
size | 109,414 |
xml-rs
based deserializer for Serde (compatible with 1.0)
use serde::{Deserialize, Serialize};
use serde_xml_rs::{from_str, to_string};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Item {
name: String,
source: String,
}
fn main() {
let src = r#"<Item><name>Banana</name><source>Store</source></Item>"#;
let should_be = Item {
name: "Banana".to_string(),
source: "Store".to_string(),
};
let item: Item = from_str(src).unwrap();
assert_eq!(item, should_be);
let reserialized_item = to_string(&item).unwrap();
assert_eq!(src, reserialized_item);
}