to_string_pretty

Function to_string_pretty 

Source
pub fn to_string_pretty<T: Facet<'static>>(
    value: &T,
) -> Result<String, XmlError>
Expand description

Serialize a value of type T to a pretty-printed XML string.

This is a convenience function that enables pretty-printing with default indentation.

ยงExample

#[derive(Facet)]
struct Person {
    #[facet(xml::attribute)]
    id: u32,
    #[facet(xml::element)]
    name: String,
}

let person = Person { id: 42, name: "Alice".into() };
let xml = to_string_pretty(&person)?;
// Output will have newlines and indentation