#serialization #required #deserialize #deserializer #serde-derive #derive-debug #partial-eq

serde-xml-any

基于xml-rs的Serde反序列化器,需要为serde_any进行的修改

1 个不稳定版本

使用旧的Rust 2015

0.0.3 2018年7月19日

#39#partial-eq

Download history 102/week @ 2024-04-15 162/week @ 2024-04-22 149/week @ 2024-04-29 104/week @ 2024-05-06 97/week @ 2024-05-13 78/week @ 2024-05-20 92/week @ 2024-05-27 114/week @ 2024-06-03 175/week @ 2024-06-10 74/week @ 2024-06-17 177/week @ 2024-06-24 53/week @ 2024-07-01 78/week @ 2024-07-08 73/week @ 2024-07-15 103/week @ 2024-07-22 151/week @ 2024-07-29

407 每月下载量
2 crates 中使用

MIT 协议

37KB
972 代码行

serde-xml-any

serde-xml-rs的修改版,需要为serde_any进行的修改。


lib.rs:

示例

extern crate serde;
extern crate serde_xml_rs;

#[macro_use]
extern crate serde_derive;

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);
}

依赖关系

~3–4.5MB
~92K SLoC