xml-core 1.0.0

Low-level generic XML reading/writing, shared building block for all OOXML formats in the toolkit.
Documentation
//! Error type for `xml-core`.

use thiserror::Error;

/// Errors that can occur while reading or writing XML with `xml-core`.
#[derive(Debug, Error)]
pub enum Error {
    /// An I/O error occurred while reading or writing.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// The underlying XML parser reported an error (malformed XML).
    #[error("XML parsing error: {0}")]
    Xml(#[from] quick_xml::Error),

    /// Decoding the text content of an event failed (e.g. invalid encoding).
    #[error("text decoding error: {0}")]
    Decoding(#[from] quick_xml::encoding::EncodingError),

    /// Un-escaping already-decoded text failed (e.g. an unknown or
    /// malformed entity reference such as `&foo;`). Surfaced by
    /// [`crate::decode_text`]/[`crate::decode_attribute_value`], which pair
    /// `quick_xml`'s decoding with the matching un-escaping step — see
    /// their doc comments for why both are needed.
    #[error("XML unescaping error: {0}")]
    Unescaping(#[from] quick_xml::escape::EscapeError),
}

/// A [`Result`](std::result::Result) alias using [`Error`] as the error type.
pub type Result<T> = std::result::Result<T, Error>;