Skip to main content

VersionFile

Trait VersionFile 

Source
pub trait VersionFile {
    // Required methods
    fn name(&self) -> &str;
    fn filenames(&self) -> &[&str];
    fn detect(&self, content: &str) -> bool;
    fn read_version(&self, content: &str) -> Option<String>;
    fn write_version(
        &self,
        content: &str,
        new_version: &str,
    ) -> Result<String, VersionFileError>;

    // Provided method
    fn extra_info(
        &self,
        _old_content: &str,
        _new_content: &str,
    ) -> Option<String> { ... }
}
Expand description

A version file engine that can detect, read, and write a version field inside a specific file format (e.g. Cargo.toml, package.json).

Required Methods§

Source

fn name(&self) -> &str

Human-readable name (e.g. "Cargo.toml").

Source

fn filenames(&self) -> &[&str]

Filenames to look for at the repository root.

Source

fn detect(&self, content: &str) -> bool

Check if content contains a version field this engine handles.

Source

fn read_version(&self, content: &str) -> Option<String>

Extract the current version string from file content.

Source

fn write_version( &self, content: &str, new_version: &str, ) -> Result<String, VersionFileError>

Return updated file content with new_version replacing the old value.

Provided Methods§

Source

fn extra_info(&self, _old_content: &str, _new_content: &str) -> Option<String>

Compare old and new file content and return optional extra information about side-effects (e.g. VERSION_CODE increment in gradle).

The default implementation returns None.

Implementors§