pub fn from_slice<'input, 'facet, T>(xml: &'input [u8]) -> Result<T, XmlError>where
T: Facet<'facet>,
'input: 'facet,Expand description
Deserialize an XML byte slice into a value of type T.
This is a convenience wrapper around from_str that first validates
that the input is valid UTF-8.
ยงExample
use facet::Facet;
use facet_xml as xml;
#[derive(Facet, Debug, PartialEq)]
struct Person {
#[facet(xml::attribute)]
id: u32,
#[facet(xml::element)]
name: String,
}
let xml_bytes = b"<Person id=\"42\"><name>Alice</name></Person>";
let person: Person = facet_xml::from_slice(xml_bytes).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.id, 42);