Struct aws_smithy_xml::encode::XmlWriter
source · 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§
impl<'a> Freeze for XmlWriter<'a>
impl<'a> RefUnwindSafe for XmlWriter<'a>
impl<'a> Send for XmlWriter<'a>
impl<'a> Sync for XmlWriter<'a>
impl<'a> Unpin for XmlWriter<'a>
impl<'a> !UnwindSafe for XmlWriter<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more