from_str

Function from_str 

Source
pub fn from_str<T>(input: &str) -> Result<T, DeserializeError<XmlError>>
where T: Facet<'static>,
Expand description

Deserialize a value from an XML string 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_str;

#[derive(Facet, Debug, PartialEq)]
struct Person {
    name: String,
    age: u32,
}

let xml = r#"<Person><name>Alice</name><age>30</age></Person>"#;
let person: Person = from_str(xml).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);