forge-ibl-bake 0.1.0

Drop in an HDRI, get wgpu/Bevy-ready IBL textures. No Blender, no Substance, no C++ build.
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0
// forge-ibl-bake ยท deveraux.dev
//! Typed error for every fallible operation in the bake pipeline.
//!
//! `BakeError` is the single error type returned by all public fns. It carries
//! the originating `std::io::Error` for I/O failures and a `String` message for
//! format violations. Callers can pattern-match without depending on any external
//! error crate. PROVEN: the graceful-failure discriminator tests verify each arm.

use std::fmt;

#[derive(Debug)]
pub enum BakeError {
    Io(std::io::Error),
    InvalidHdr(String),
    InvalidSize(String),
    UnsupportedFormat(u32),
}

impl fmt::Display for BakeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            BakeError::Io(e) => write!(f, "I/O error: {e}"),
            BakeError::InvalidHdr(s) => write!(f, "invalid HDR: {s}"),
            BakeError::InvalidSize(s) => write!(f, "invalid size: {s}"),
            BakeError::UnsupportedFormat(n) => write!(f, "unsupported VkFormat: {n}"),
        }
    }
}

impl std::error::Error for BakeError {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            BakeError::Io(e) => Some(e),
            _ => None,
        }
    }
}

impl From<std::io::Error> for BakeError {
    fn from(e: std::io::Error) -> Self {
        BakeError::Io(e)
    }
}