pub struct FactorioVersion {
pub major: u64,
pub minor: u64,
pub patch: Option<u64>,
}Expand description
Represents a version of Factorio (the game).
In most cases, the patch field
should be left as None.
The game and its APIs may sometimes return a patch component, and some wrongly configured mods on the mod portal may also have it set (in error).
If you’re constructing a [ModInfo][facti_lib::ModInfo] struct,
you MUST NOT set the patch component, as that is considered invalid
and the mod portal will reject your mod. It may also make the game behave
in unexpected ways.
Fields§
§major: u64The major component of the version.
minor: u64The minor component of the version.
patch: Option<u64>The patch component of the version, if any.
Implementations§
Source§impl FactorioVersion
impl FactorioVersion
Sourcepub fn new(major: u64, minor: u64) -> Self
pub fn new(major: u64, minor: u64) -> Self
Constructs a FactorioVersion with just the major
and minor fields set.
This is most often the correct method to use.
pub fn with_patch(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 FactorioVersion from a string.
§Examples
let version = FactorioVersion::parse("1.2")?;
assert_eq!(version.major, 1);
assert_eq!(version.minor, 2);
assert!(version.patch.is_none());
let with_patch = FactorioVersion::parse("1.2.3")?;
assert_eq!(with_patch.major, 1);
assert_eq!(with_patch.minor, 2);
assert_eq!(with_patch.patch, Some(3));Trait Implementations§
Source§impl Clone for FactorioVersion
impl Clone for FactorioVersion
Source§fn clone(&self) -> FactorioVersion
fn clone(&self) -> FactorioVersion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FactorioVersion
impl Debug for FactorioVersion
Source§impl Default for FactorioVersion
impl Default for FactorioVersion
Source§impl<'de> Deserialize<'de> for FactorioVersion
impl<'de> Deserialize<'de> for FactorioVersion
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 Display for FactorioVersion
impl Display for FactorioVersion
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 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 From<FactorioVersion> for VersionReq
impl From<FactorioVersion> for VersionReq
Source§fn from(value: FactorioVersion) -> Self
fn from(value: FactorioVersion) -> Self
Converts to this type from the input type.
Source§impl From<FactorioVersion> for VersionSpec
impl From<FactorioVersion> for VersionSpec
Source§fn from(value: FactorioVersion) -> Self
fn from(value: FactorioVersion) -> Self
Converts to this type from the input type.
Source§impl FromStr for FactorioVersion
impl FromStr for FactorioVersion
Source§impl Hash for FactorioVersion
impl Hash for FactorioVersion
Source§impl Ord for FactorioVersion
impl Ord for FactorioVersion
Source§impl PartialEq for FactorioVersion
impl PartialEq for FactorioVersion
Source§impl PartialOrd for FactorioVersion
impl PartialOrd for FactorioVersion
Source§impl Serialize for FactorioVersion
impl Serialize for FactorioVersion
impl Copy for FactorioVersion
impl Eq for FactorioVersion
impl StructuralPartialEq for FactorioVersion
Auto Trait Implementations§
impl Freeze for FactorioVersion
impl RefUnwindSafe for FactorioVersion
impl Send for FactorioVersion
impl Sync for FactorioVersion
impl Unpin for FactorioVersion
impl UnwindSafe for FactorioVersion
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