Skip to main content

Serializer

Struct Serializer 

Source
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>

Source

pub fn new(output: &'xml mut W) -> Self

Create a new serializer writing to the given output

Source

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>>.

Source

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

Source

pub fn write_str<V: Display + ?Sized>(&mut self, value: &V) -> Result<(), Error>

Write a string value (text content or attribute value)

Source

pub fn end_start(&mut self) -> Result<(), Error>

Complete the opening tag and transition to element content

Source

pub fn end_empty(&mut self) -> Result<(), Error>

Close an empty element (self-closing tag)

Source

pub fn write_close<const N: usize>( &mut self, element: Element<'_, N>, ) -> Result<(), Error>

Write the closing tag for an element

Source

pub fn prefix(&self, ns: &str) -> Option<&'static str>

Get the prefix for a namespace URI, if any

Source

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>
where W: Send + ?Sized,

§

impl<'xml, W> Sync for Serializer<'xml, W>
where W: Sync + ?Sized,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.