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§
Sourcefn detect(&self, content: &str) -> bool
fn detect(&self, content: &str) -> bool
Check if content contains a version field this engine handles.
Sourcefn read_version(&self, content: &str) -> Option<String>
fn read_version(&self, content: &str) -> Option<String>
Extract the current version string from file content.
Sourcefn write_version(
&self,
content: &str,
new_version: &str,
) -> Result<String, VersionFileError>
fn write_version( &self, content: &str, new_version: &str, ) -> Result<String, VersionFileError>
Return updated file content with new_version replacing the old value.