mx20022-parse 0.3.0

XML parsing and serialization for ISO 20022 MX financial messages via quick-xml and serde
Documentation
//! Error types for XML parsing and serialization.

use thiserror::Error;

/// Errors that can occur during ISO 20022 XML parsing or serialization.
#[derive(Debug, Error)]
pub enum ParseError {
    /// XML deserialization failed.
    #[error("XML deserialization error: {0}")]
    Deserialize(#[from] quick_xml::DeError),

    /// XML deserialization failed for a document whose envelope was
    /// successfully detected. `context` carries the dotted message
    /// identifier (e.g. `"pacs.008.001.13"`); `source` is the underlying
    /// `quick_xml` diagnostic.
    #[error("XML deserialization error in {context}: {source}")]
    DeserializeIn {
        /// Free-form description of the envelope being parsed.
        context: String,
        /// The underlying `quick_xml` deserialization error.
        #[source]
        source: quick_xml::DeError,
    },

    /// XML serialization failed.
    #[error("XML serialization error: {0}")]
    Serialize(#[from] quick_xml::SeError),

    /// An I/O error occurred.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// The XML document does not have a valid ISO 20022 envelope.
    #[error("invalid envelope: {0}")]
    InvalidEnvelope(String),
}