pub struct XmlWriter<'a> { /* private fields */ }
Expand description

XmlWriter Abstraction

XmlWriter (and friends) make generating an invalid XML document a type error. Nested branches of the Xml document mutable borrow from the root. You cannot continue writing to the root until the nested branch is dropped and dropping the nested branch writes the terminator (e.g. closing element).

The one exception to this rule is names—it is possible to construct an invalid Xml Name. However, names are always known ahead of time and always static, so this would be obvious from the code.

Furthermore, once const panic stabilizes, we’ll be able to make an invalid XmlName a compiler error.

Examples

use aws_smithy_xml::encode::XmlWriter;
let mut s = String::new();
let mut doc = XmlWriter::new(&mut s);
let mut start_el = doc.start_el("Root")
    .write_ns("http://example.com", None);
let mut start_tag = start_el.finish();
start_tag.data("hello");
start_tag.finish();
assert_eq!(s, "<Root xmlns=\"http://example.com\">hello</Root>");

See tests/handwritten_serializers.rs for more usage examples.

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.