pub fn from_slice<T>(input: &[u8]) -> Result<T, DeserializeError<XmlError>>where
T: Facet<'static>,Expand description
Deserialize a value from XML bytes into an owned type.
This is the recommended default for most use cases. The input does not need to outlive the result, making it suitable for deserializing from temporary buffers (e.g., HTTP request bodies).
ยงExample
use facet::Facet;
use facet_xml::from_slice;
#[derive(Facet, Debug, PartialEq)]
struct Person {
name: String,
age: u32,
}
let xml = b"<Person><name>Alice</name><age>30</age></Person>";
let person: Person = from_slice(xml).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);