apivolve_generator_api 0.1.1

Api for creating generators for Apivolve, an API evolution tool that helps keep your APIs backwards compatible yet clean.
Documentation
use ::semver::Version;

use crate::gen1::VersionEvolution;

pub type ErrMsg = String;

#[derive(Debug, Clone)]
pub enum GenResult {
    Ok,
    FinishEarly,
    Error(ErrMsg),
}

pub trait Generator {
    /// Will be called once at the start, only if there are any pending changes.
    fn generate_pending(&mut self, evolution: VersionEvolution) -> GenResult;

    /// Will be called for each version, from newest to oldest, after `generate_pending`.
    fn generate_version(&mut self, version: Version, evolution: VersionEvolution) -> GenResult;

    /// Will be called exactly once at the end if all prior steps were successful.
    fn finalize(self) -> Result<(), ErrMsg>;
}