Expand description
§Examples
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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<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);
}
Re-exports§
pub use ser::to_string;
pub use ser::to_string_with_namespaces;
pub use ser::to_writer;
pub use ser::Serializer;
pub use de::from_reader;
pub use de::from_str;
pub use de::Deserializer;
Modules§
Structs§
- Error
- The Error type.
- Event
Reader - A wrapper around an
std::io::Read
instance which provides pull-based XML parsing. - Parser
Config - Parser configuration structure.
Enums§
- Error
Kind - The kind of an error.
Functions§
- wrap_
primitives - Helper function for serializing lists of primitives as
item