drawingml 1.0.0

Shared DrawingML content model (shapes, fills, colors, lines) for the WordprocessingML/SpreadsheetML/PresentationML crates.
Documentation
//! Error type for `drawing`.

use thiserror::Error;

/// Errors that can occur while reading or writing DrawingML content.
///
/// Deliberately small: unlike `word-ooxml`/`excel-ooxml`, this crate never
/// touches an OPC package or a relationship (no `opc::Error` variant), and
/// has no part-resolution failure modes of its own yet (no `MissingXxxPart`
/// variants) — it only ever reads/writes XML fragments handed to it by a
/// future host crate.
#[derive(Debug, Error)]
pub enum Error {
    /// An error occurred while reading or writing XML.
    #[error("XML error: {0}")]
    Xml(#[from] xml_core::Error),

    /// A [`TextRun::Field`](crate::model::TextRun::Field)'s `id` is not a
    /// valid `ST_Guid`. ECMA-376's `CT_TextField` (the type behind
    /// `<a:fld id="..." type="...">`) requires `id` to be a GUID in
    /// `{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}` form (uppercase hex) —
    /// confirmed against the ISO/IEC 29500-4 `dml-main.xsd` schema. A
    /// non-GUID id writes schema-invalid XML that PowerPoint refuses to
    /// open without repairing (and, per observed behavior, can blank out
    /// unrelated slides in the same package during that repair).
    #[error(
        "text field id '{0}' is not a valid GUID — OOXML requires the form \
         `{{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}}` (uppercase hex); a non-GUID id \
         writes schema-invalid XML that PowerPoint/Word will refuse to open without repairing"
    )]
    InvalidFieldId(String),
}

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