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<'a, const N: usize>(
&mut self,
name: &'a str,
ns: &str,
cx: Option<Context<N>>,
) -> Result<Element<'a, N>, Error>
pub fn write_start<'a, const N: usize>( &mut self, name: &'a str, ns: &str, cx: Option<Context<N>>, ) -> Result<Element<'a, N>, Error>
Write the opening tag for an element
Returns the namespace prefix if one was used.
The cx parameter can be used to specify namespace declarations for the element. When
passing in None, you’ll probably need to specify None::<Context<0>>.
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<const N: usize>(
&mut self,
element: Element<'_, N>,
) -> Result<(), Error>
pub fn write_close<const N: usize>( &mut self, element: Element<'_, N>, ) -> Result<(), Error>
Write the closing tag for an element
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