changeset-manifest 0.0.5

Format-preserving Cargo.toml read/write operations
Documentation
use std::path::PathBuf;

use thiserror::Error;

#[derive(Debug, Error)]
pub enum ManifestError {
    #[error("failed to read manifest at '{path}'")]
    Read {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("failed to write manifest at '{path}'")]
    Write {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("failed to parse TOML at '{path}'")]
    Parse {
        path: PathBuf,
        #[source]
        source: toml_edit::TomlError,
    },

    #[error("missing required field '{field}' in '{path}'")]
    MissingField { path: PathBuf, field: String },

    #[error("expected version '{expected}' but found '{actual}' in '{path}'")]
    VerificationFailed {
        path: PathBuf,
        expected: String,
        actual: String,
    },

    #[error("invalid version string '{version}' in '{path}'")]
    InvalidVersion {
        path: PathBuf,
        version: String,
        #[source]
        source: semver::Error,
    },

    #[error("missing section '{section}' in manifest '{path}'")]
    MissingSection { path: PathBuf, section: String },

    #[error("expected '{section}' to be a table in manifest '{path}'")]
    InvalidSectionType { path: PathBuf, section: String },

    #[error("failed to parse YAML at '{path}'")]
    YamlParse {
        path: PathBuf,
        #[source]
        source: yaml_edit::YamlError,
    },

    #[error("failed to parse JSON at '{path}'")]
    JsonParse {
        path: PathBuf,
        #[source]
        source: jsonc_parser::errors::ParseError,
    },

    #[error("failed to decode JSON string at '{path}'")]
    JsonStringDecode {
        path: PathBuf,
        #[source]
        source: jsonc_parser::ParseStringErrorKind,
    },

    #[error("version path '{version_field_path}' not found in manifest at '{path}'")]
    VersionPathNotFound {
        path: PathBuf,
        version_field_path: String,
    },

    #[error("expected string at version path '{version_field_path}' in manifest at '{path}'")]
    VersionNotString {
        path: PathBuf,
        version_field_path: String,
    },
}