oxipdf-html 0.1.0

HTML+CSS → StyledTree adapter for the oxipdf PDF engine
Documentation
//! Error types for HTML → StyledTree conversion.

/// Error produced during HTML → StyledTree conversion.
#[derive(Debug)]
pub enum HtmlError {
    /// The HTML document has no renderable body content.
    EmptyDocument,
    /// A CSS value could not be parsed.
    CssParseError { detail: String },
    /// A `data:` URI could not be decoded.
    DataUriError { detail: String },
    /// The IR tree builder rejected the tree (validation failure).
    TreeBuildError(oxipdf_ir::error::InputValidationError),
}

impl std::fmt::Display for HtmlError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::EmptyDocument => write!(f, "HTML document has no renderable content"),
            Self::CssParseError { detail } => write!(f, "CSS parse error: {detail}"),
            Self::DataUriError { detail } => write!(f, "data URI error: {detail}"),
            Self::TreeBuildError(e) => write!(f, "tree build error: {e}"),
        }
    }
}

impl std::error::Error for HtmlError {}

impl From<oxipdf_ir::error::InputValidationError> for HtmlError {
    fn from(e: oxipdf_ir::error::InputValidationError) -> Self {
        Self::TreeBuildError(e)
    }
}