serde-xml-rs

Crates.ioserde-xml-rs
lib.rsserde-xml-rs
version0.6.0
sourcesrc
created_at2017-02-17 17:40:07.847608
updated_at2022-08-31 18:35:59.526629
descriptionxml-rs based deserializer for Serde (compatible with 0.9+)
homepage
repositoryhttps://github.com/RReverser/serde-xml-rs
max_upload_size
id8556
size108,092
William Bartlett (punkstarman)

documentation

README

serde-xml-rs

Build Status

xml-rs based deserializer for Serde (compatible with 1.0)

Example usage

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);
}
Commit count: 113

cargo fmt