pub struct Version {
pub major: u32,
pub minor: u32,
pub build: Option<u32>,
pub revision: Option<u32>,
}Expand description
A two-, three-, or four-part numeric version.
This type follows the important System.Version conventions used by
Nerdbank.GitVersioning: major and minor are always present, while build and
revision may be unspecified. An unspecified component compares less than
zero, just as the corresponding System.Version component (whose value is
-1) does.
Fields§
§major: u32The major version.
minor: u32The minor version.
build: Option<u32>The build component, or None when it is unspecified.
revision: Option<u32>The revision component, or None when it is unspecified.
Implementations§
Source§impl Version
impl Version
Sourcepub const fn new(major: u32, minor: u32) -> Self
pub const fn new(major: u32, minor: u32) -> Self
Creates a version with major and minor components.
Sourcepub const fn new_with_build(major: u32, minor: u32, build: u32) -> Self
pub const fn new_with_build(major: u32, minor: u32, build: u32) -> Self
Creates a version with major, minor, and build components.
Sourcepub const fn new_with_revision(
major: u32,
minor: u32,
build: u32,
revision: u32,
) -> Self
pub const fn new_with_revision( major: u32, minor: u32, build: u32, revision: u32, ) -> Self
Creates a version with all four components.
Sourcepub fn from_system_version_parts(
major: i32,
minor: i32,
build: i32,
revision: i32,
) -> Result<Self>
pub fn from_system_version_parts( major: i32, minor: i32, build: i32, revision: i32, ) -> Result<Self>
Creates a version from component values using -1 for unspecified
build and revision components.
Sourcepub const fn build_or_unspecified(self) -> i64
pub const fn build_or_unspecified(self) -> i64
Gets the build component using the System.Version value -1 when it
is unspecified.
Sourcepub const fn revision_or_unspecified(self) -> i64
pub const fn revision_or_unspecified(self) -> i64
Gets the revision component using the System.Version value -1 when
it is unspecified.
Sourcepub fn ensure_non_negative_components(self, field_count: usize) -> Result<Self>
pub fn ensure_non_negative_components(self, field_count: usize) -> Result<Self>
Returns a version where the specified number of components are guaranteed to be present. Applicable unspecified components become zero.
field_count must be between zero and four.
Sourcepub fn to_string_safe(self, field_count: usize) -> Result<String>
pub fn to_string_safe(self, field_count: usize) -> Result<String>
Converts this version to a string containing exactly field_count
components, replacing unspecified requested components with zero.
field_count must be between zero and four.
Sourcepub const fn component_count(self) -> usize
pub const fn component_count(self) -> usize
Gets the number of specified components.