pub struct Version {
pub major: u64,
pub minor: u64,
pub patch: u64,
}Expand description
Represents a mod’s version, in (limited) semver format.
§Examples
use facti_lib::version::Version;
let my_version = Version { major: 1, minor: 2, patch: 3 };
println!("My version is: {}", my_version);Fields§
§major: u64The major part of the version number.
minor: u64The minor part of the version number.
patch: u64The patch part of the version number.
Factorio documentation and resources sometimes refer to this field as the “sub” part.
Implementations§
Source§impl Version
impl Version
pub fn new(major: u64, minor: u64, patch: u64) -> Self
Sourcepub fn parse(s: &str) -> Result<Self, ParseVersionError>
pub fn parse(s: &str) -> Result<Self, ParseVersionError>
Parses a version string into a Version.
Sourcepub fn matches(&self, spec: VersionSpec) -> bool
pub fn matches(&self, spec: VersionSpec) -> bool
Checks if this Version is compatible with the given VersionSpec.
§Examples
assert!(Version::new(1, 2, 3).matches(VersionSpec::parse("= 1.2.3")?));
assert!(Version::new(4, 1, 3).matches(VersionSpec::parse("> 4.0.0")?));
assert!(Version::new(0, 5, 1).matches(VersionSpec::parse("<= 1.0.0")?));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Version
impl<'de> Deserialize<'de> for Version
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<FactorioVersion> for Version
impl From<FactorioVersion> for Version
Source§fn from(value: FactorioVersion) -> Self
fn from(value: FactorioVersion) -> Self
Converts to this type from the input type.
Source§impl Ord for Version
impl Ord for Version
Source§impl PartialOrd for Version
impl PartialOrd for Version
impl Copy for Version
impl Eq for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more