Added a semver class
Auto updater improvements, not yet ready Registry and Epic Games auto-detection started
This commit is contained in:
31
src/semver.rs
Normal file
31
src/semver.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
//! # SemVer
|
||||
|
||||
//! A simple Semantic Versioning struct to handle comparisons and ordering
|
||||
|
||||
// Uses
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub struct SemVer {
|
||||
pub major: i32,
|
||||
pub minor: i32,
|
||||
pub patch: i32,
|
||||
}
|
||||
|
||||
impl fmt::Display for SemVer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for SemVer {
|
||||
fn from(s: &str) -> SemVer {
|
||||
let v: Vec<&str> = s.split('.').collect();
|
||||
|
||||
SemVer {
|
||||
major: v[0].parse().unwrap(),
|
||||
minor: v[1].parse().unwrap(),
|
||||
patch: v[2].parse().unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user