pub struct Serializer<'xml, W: Write + ?Sized> { /* private fields */ }Expand description
XML serializer for writing structured XML output
Implementations§
Source§impl<'xml, W: Write + ?Sized> Serializer<'xml, W>
impl<'xml, W: Write + ?Sized> Serializer<'xml, W>
Sourcepub fn new(output: &'xml mut W) -> Self
pub fn new(output: &'xml mut W) -> Self
Create a new serializer writing to the given output
Sourcepub fn write_start(
&mut self,
name: &str,
ns: &str,
) -> Result<Option<&'static str>, Error>
pub fn write_start( &mut self, name: &str, ns: &str, ) -> Result<Option<&'static str>, Error>
Write the opening tag for an element
Returns the namespace prefix if one was used.
Sourcepub fn write_attr<V: ToXml + ?Sized>(
&mut self,
name: &str,
ns: &str,
value: &V,
) -> Result<(), Error>
pub fn write_attr<V: ToXml + ?Sized>( &mut self, name: &str, ns: &str, value: &V, ) -> Result<(), Error>
Write an attribute with the given name and value
Sourcepub fn write_str<V: Display + ?Sized>(&mut self, value: &V) -> Result<(), Error>
pub fn write_str<V: Display + ?Sized>(&mut self, value: &V) -> Result<(), Error>
Write a string value (text content or attribute value)
Sourcepub fn end_start(&mut self) -> Result<(), Error>
pub fn end_start(&mut self) -> Result<(), Error>
Complete the opening tag and transition to element content
Sourcepub fn write_close(
&mut self,
prefix: Option<&str>,
name: &str,
) -> Result<(), Error>
pub fn write_close( &mut self, prefix: Option<&str>, name: &str, ) -> Result<(), Error>
Write the closing tag for an element
Sourcepub fn push<const N: usize>(
&mut self,
new: Context<N>,
) -> Result<Context<N>, Error>
pub fn push<const N: usize>( &mut self, new: Context<N>, ) -> Result<Context<N>, Error>
Push a namespace context onto the stack
Returns the previous context to be restored later with pop.
Sourcepub fn pop<const N: usize>(&mut self, old: Context<N>)
pub fn pop<const N: usize>(&mut self, old: Context<N>)
Pop a namespace context from the stack, restoring the previous context
Sourcepub fn prefix(&self, ns: &str) -> Option<&'static str>
pub fn prefix(&self, ns: &str) -> Option<&'static str>
Get the prefix for a namespace URI, if any
Sourcepub fn default_ns(&self) -> &'static str
pub fn default_ns(&self) -> &'static str
Get the current default namespace URI
Auto Trait Implementations§
impl<'xml, W> Freeze for Serializer<'xml, W>where
W: ?Sized,
impl<'xml, W> RefUnwindSafe for Serializer<'xml, W>where
W: RefUnwindSafe + ?Sized,
impl<'xml, W> Send for Serializer<'xml, W>
impl<'xml, W> Sync for Serializer<'xml, W>
impl<'xml, W> Unpin for Serializer<'xml, W>where
W: ?Sized,
impl<'xml, W> UnsafeUnpin for Serializer<'xml, W>where
W: ?Sized,
impl<'xml, W> !UnwindSafe for Serializer<'xml, W>
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