pub struct Version {
pub date: Date,
pub changeset: u32,
pub label: Option<Label>,
}Expand description
Represents a version number conforming to the chronologic versioning scheme.
Fields§
§date: DateThe date of release, to be updated whenever a new release is made on a different date than the last release.
changeset: u32The changeset number, to be incremented when a change was released on the same day.
label: Option<Label>The optional label, which can have any format or follow a branch formatting (see Label
for more information).
The special label break is reserved to signal a release with breaking changes.
Implementations§
Source§impl Version
impl Version
Sourcepub fn parse(version: &str) -> Result<Self, ChronVerError>
pub fn parse(version: &str) -> Result<Self, ChronVerError>
Parse a string into a chronver object.
§Examples
use chronver::{Version, Label};
use time::macros::date;
// Basic version with just a date
assert_eq!(Version::parse("2020.03.05"), Ok(Version {
date: date!(2020-03-05),
changeset: 0,
label: None,
}));
// Version with a changeset
assert_eq!(Version::parse("2020.03.05.2"), Ok(Version {
date: date!(2020-03-05),
changeset: 2,
label: None,
}));
// And with label
assert_eq!(Version::parse("2020.03.05.2-new"), Ok(Version {
date: date!(2020-03-05),
changeset: 2,
label: Some(Label::Text("new".to_owned())),
}));§Errors
An error can occur in two cases. First, when the very first part of the version is not a
valid date in the format YYYY.MM.DD. Second, when a changeset follows the date but
it is not a valid u32 number.
Sourcepub fn update(&mut self)
pub fn update(&mut self)
Update the version to the current date or increment the changeset in case the date is the same. If a label exists, it will be removed.
Sourcepub fn is_breaking(&self) -> bool
pub fn is_breaking(&self) -> bool
Check whether the current version introduces breaking changes.
§Examples
use chronver::Version;
assert!(Version::parse("2020.03.05-break").unwrap().is_breaking());
assert!(!Version::parse("2020.03.05").unwrap().is_breaking());