web-api-cat 0.4.0

Bindings between boa-cat (JS engine) and the DOM (html-cat tree) plus fetch (net-cat). v0.4.0 installs `document.cookie` as a boa-cat 0.3 accessor pair: the getter reads a host-supplied projection, the setter records each `document.cookie = ...` RHS string (with attributes intact) into a hidden write log AND updates the visible projection so subsequent reads see the just-written cookie. Hosts call `set_document_cookie` to seed the projection pre-eval and `read_cookie_writes(&heap)` to recover each per-write Set-Cookie-style string post-eval -- preserving `Max-Age` / `Path` / `Domain` / `Secure` / `HttpOnly` semantics across multiple writes in one script. No mut, no Rc/Arc, no interior mutability, no panics. Seventh sub-crate of a Servo-replacement webview runtime targeting Tauri.
//! Bridge error type.

use boa_cat::Error as EngineError;
use html_cat::Error as HtmlError;
use net_cat::Error as NetError;

/// All errors `web-api-cat` can produce.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
    /// A JS engine error from boa-cat.
    Engine(EngineError),
    /// An HTML-parser error.
    Html(HtmlError),
    /// A network error from net-cat.
    Net(NetError),
}

impl From<EngineError> for Error {
    fn from(value: EngineError) -> Self {
        Self::Engine(value)
    }
}

impl From<HtmlError> for Error {
    fn from(value: HtmlError) -> Self {
        Self::Html(value)
    }
}

impl From<NetError> for Error {
    fn from(value: NetError) -> Self {
        Self::Net(value)
    }
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Engine(e) => write!(f, "engine error: {e}"),
            Self::Html(e) => write!(f, "html error: {e}"),
            Self::Net(e) => write!(f, "net error: {e}"),
        }
    }
}

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