commit | fd010f1fc5dc8c3c7a659d71ce702b4149daba06 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sun Oct 03 09:04:46 2021 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sun Oct 03 09:04:46 2021 +0000 |
tree | 7b6f9d20d96c4c5c29bc92e4207af555ef14f372 | |
parent | c1bca75f37bfd3187272a955c1777922f7539a4b [diff] | |
parent | 633f134ff9020d4fafc19a35d0a7f5b13cc0a040 [diff] |
Snap for 7789152 from 633f134ff9020d4fafc19a35d0a7f5b13cc0a040 to main-cg-testing-release Change-Id: Ibefe0fdc357db7312ece9de6eb980e96db979933
xml-rs
based deserializer for Serde (compatible with 1.0)
use serde; use serde_derive::{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); }