islands-core 0.1.3

Server-side SSR primitives for islands.rs: island markers, the page shell, the asset manifest, and streaming Suspense.
Documentation
use std::fmt;

#[derive(Debug)]
pub enum CoreError {
    Serialization(serde_json::Error),
    InvalidInput(String),
}

impl fmt::Display for CoreError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            CoreError::Serialization(e) => write!(f, "serialization error: {e}"),
            CoreError::InvalidInput(msg) => write!(f, "invalid input: {msg}"),
        }
    }
}

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

impl From<serde_json::Error> for CoreError {
    fn from(e: serde_json::Error) -> Self {
        CoreError::Serialization(e)
    }
}