eframework/
rversion.rs

1use abi_stable::{StableAbi};
2
3///Represents a version number that is FFI friendly via [abi_stable](https://github.com/rodrimati1992/abi_stable_crates/).
4#[repr(C)]
5#[derive(Clone, StableAbi, Eq, PartialEq, Ord, PartialOrd)]
6pub struct RVersion {
7    /// The major version, to be incremented on incompatible changes.
8    pub major: u64,
9    /// The minor version, to be incremented when functionality is added in a
10    /// backwards-compatible manner.
11    pub minor: u64,
12    /// The patch version, to be incremented when backwards-compatible bug
13    /// fixes are made.
14    pub patch: u64
15}
16
17impl std::fmt::Display for RVersion {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        write!(f, "{}, {}, {}", self.major, self.minor, self.patch)
20    }
21}
22
23impl RVersion {
24
25    pub fn new(major: u64, minor: u64, patch: u64) -> RVersion {
26        RVersion { major, minor, patch }
27    }
28
29    ///Returns true if the two versions are compatible in a semantic versioning sense, AKA their major versions are the same.
30    pub fn is_compatible(&self, other_version: &RVersion) -> bool {
31        self.major == other_version.major
32    }
33}