[][src]Struct alfred::xml::XMLWriter

pub struct XMLWriter<W: Write> { /* fields omitted */ }

Helper struct used to manage the XML serialization of Items.

When the XMLWriter is first created, the XML header is immediately written. When the XMLWriter is dropped, the XML footer is written and the Write is flushed.

Any errors produced by writing the footer are silently ignored. The close() method can be used to return any such error.

Methods

impl<W: Write> XMLWriter<W>[src]

pub fn new(w: W) -> Result<XMLWriter<W>>[src]

Returns a new XMLWriter that writes to the given Write.

The XML header is written immediately.

pub fn write_item(&mut self, item: &Item) -> Result<()>[src]

Writes an Item to the underlying Write.

If a previous write produced an error, any subsequent write will do nothing and return the same error. This is because the previous write may have partially completed, and attempting to write any more data will be unlikely to work properly.

pub fn close(self) -> Result<W>[src]

Consumes the XMLWriter and writes the XML footer.

This method can be used to get any error resulting from writing the footer. If this method is not used, the footer will be written when the XMLWriter is dropped and any error will be silently ignored.

As with write_item(), if a previous invocation of write_item() returned an error, close() will return the same error without attempting to write the XML footer.

When this method is used, the XML footer is written, but the Write is not flushed. When the XMLWriter is dropped without calling close(), the Write is flushed after the footer is written.

Trait Implementations

impl<W: Write> Drop for XMLWriter<W>[src]

Auto Trait Implementations

impl<W> Send for XMLWriter<W> where
    W: Send

impl<W> Unpin for XMLWriter<W> where
    W: Unpin

impl<W> Sync for XMLWriter<W> where
    W: Sync

impl<W> !UnwindSafe for XMLWriter<W>

impl<W> !RefUnwindSafe for XMLWriter<W>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]