xml::writer

Struct EventWriter

Source
pub struct EventWriter<W> { /* private fields */ }
Expand description

A wrapper around an std::io::Write instance which emits XML document according to provided events.

Implementations§

Source§

impl<W: Write> EventWriter<W>

Source

pub fn new(sink: W) -> EventWriter<W>

Creates a new EventWriter out of an std::io::Write instance using the default configuration.

Source

pub fn new_with_config(sink: W, config: EmitterConfig) -> EventWriter<W>

Creates a new EventWriter out of an std::io::Write instance using the provided configuration.

Source

pub fn write<'a, E>(&mut self, event: E) -> Result<()>
where E: Into<XmlEvent<'a>>,

Writes the next piece of XML document according to the provided event.

Note that output data may not exactly correspond to the written event because of various configuration options. For example, XmlEvent::EndElement may correspond to a separate closing element or it may cause writing an empty element. Another example is that XmlEvent::CData may be represented as characters in the output stream.

Source

pub fn inner_mut(&mut self) -> &mut W

Returns a mutable reference to the underlying Writer.

Note that having a reference to the underlying sink makes it very easy to emit invalid XML documents. Use this method with care. Valid use cases for this method include accessing methods like Write::flush, which do not emit new data but rather change the state of the stream itself.

Source

pub fn into_inner(self) -> W

Unwraps this EventWriter, returning the underlying writer.

Note that this is a destructive operation: unwrapping a writer and then wrapping it again with EventWriter::new() will create a fresh writer whose state will be blank; for example, accumulated namespaces will be reset.

Auto Trait Implementations§

§

impl<W> Freeze for EventWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for EventWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for EventWriter<W>
where W: Send,

§

impl<W> Sync for EventWriter<W>
where W: Sync,

§

impl<W> Unpin for EventWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for EventWriter<W>
where W: UnwindSafe,

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.