bookyard-core 0.1.0

Core configuration and catalog model for Bookyard.
Documentation
use std::path::PathBuf;

pub type Result<T> = std::result::Result<T, BookyardError>;

#[derive(Debug, thiserror::Error)]
pub enum BookyardError {
    #[error("io error at {path}: {source}")]
    Io {
        path: PathBuf,
        source: std::io::Error,
    },

    #[error("failed to parse TOML at {path}: {source}")]
    TomlParse {
        path: PathBuf,
        source: toml::de::Error,
    },

    #[error("failed to write TOML: {0}")]
    TomlWrite(toml::ser::Error),

    #[error("duplicate book id: {0}")]
    DuplicateBookId(String),

    #[error("unsupported book source: {0}")]
    UnsupportedBookSource(PathBuf),

    #[error("unsupported book engine: {0}")]
    UnsupportedBookEngine(String),

    #[error("mdbook build failed for {id} with status {status}")]
    MdBookBuildFailed { id: String, status: String },
}

pub(crate) fn io_error(path: impl Into<PathBuf>, source: std::io::Error) -> BookyardError {
    BookyardError::Io {
        path: path.into(),
        source,
    }
}