Trait lenient_semver_version_builder::VersionBuilder [−][src]
pub trait VersionBuilder<'input> { type Out; fn new() -> Self; fn build(self) -> Self::Out; fn set_major(&mut self, major: u64) { ... } fn set_minor(&mut self, minor: u64) { ... } fn set_patch(&mut self, patch: u64) { ... } fn add_additional(&mut self, num: u64) { ... } fn add_pre_release(&mut self, pre_release: &'input str) { ... } fn add_build(&mut self, build: &'input str) { ... } }
Expand description
Trait to abstract over version building.
The methods to implement in this trait represent the components of semver::Version
,
but allow for parsing into a custom type.
The trait is generic over the lifetime of the input string, so that one could parse into a version without having to allocate.
Most methods have a default implementation that does nothing and ignores the input. This can be used to implement some form of validation without needing to keep the result.
Associated Types
Required methods
Construct a new version builder.
The function must not fail and the version (if returned from VersionBuilder::build
at this point)
should represent something akin to “0.0.0”
Provided methods
Set the major version component.
This method is the only required component and will be called
before VersionBuilder::build
.
Set the minor version component.
This component is optional and might not be called
before VersionBuilder::build
.
Set the patch version component.
This component is optional and might not be called
before VersionBuilder::build
.
fn add_additional(&mut self, num: u64)
[src]
fn add_additional(&mut self, num: u64)
[src]Add additional numeric components following patch and preceding pre-release.
For a version like 1.2.3.4.5
, this would call add_additional with 4
and 5
.
For strict semver versions, those values are invalid. For lenient semver, those values are better represented as build than pre-release, although they might be “in the same block” as pre-release. In terms of comparing versions, the values added here should still have an impact.
This component is optional and might not be called
before VersionBuilder::build
.
fn add_pre_release(&mut self, pre_release: &'input str)
[src]
fn add_pre_release(&mut self, pre_release: &'input str)
[src]The pre-release metadata.
The string might represent any alpha-numeric identifier, including numbers with or without leading zeroes. It is up to the implementor to parse those into more specific identifiers, if required.
This component is optional and might not be called
before VersionBuilder::build
.
This method might be called multiple times, although the default implementation produces only one identifier.
The build identifier.
The string might represent any alpha-numeric identifier, including numbers with or without leading zeroes. It is up to the implementor to parse those into more specific identifiers, if required.
This component is optional and might not be called
before VersionBuilder::build
.
This method might be called multiple times, although the default implementation produces only one identifier.
Implementations on Foreign Types
type Out = Self