Struct abi_stable::sabi_types::version::VersionNumber [−][src]
Expand description
The parsed (<major>.<minor>.<patch>
) version number of a library.
Post 1.0 major version
Major versions are mutually incompatible for both users and implementors.
Minor allow users to have a version less than or equal to that of the implementor, and disallows implementors from making changes that would break any previous minor release (with the same major number).
Patch cannot change the api/abi of the library at all,fixes only.
Example
use abi_stable::sabi_types::VersionNumber;
let v0_1_0 = VersionNumber {
major: 0,
minor: 1,
patch: 0,
};
let v0_1_5 = VersionNumber {
major: 0,
minor: 1,
patch: 5,
};
let v0_1_8 = VersionNumber {
major: 0,
minor: 1,
patch: 8,
};
let v0_2_0 = VersionNumber {
major: 0,
minor: 2,
patch: 0,
};
assert!(v0_1_0.is_compatible(v0_1_5), "'{}' '{}'", v0_1_0, v0_1_5);
assert!(v0_1_5.is_compatible(v0_1_8), "'{}' '{}'", v0_1_5, v0_1_8);
assert!(!v0_1_8.is_compatible(v0_2_0), "'{}' '{}'", v0_1_8, v0_2_0);
Fields
major: u32
minor: u32
patch: u32
Implementations
Attempts to convert a VersionStrings
into a VersionNumber
Errors
This returns a ParseVersionError
if the string is not correctly formatted.
Example
use abi_stable::sabi_types::{VersionNumber, VersionStrings};
static VERSION: VersionStrings = VersionStrings::new("10.5.20");
assert_eq!(
VersionNumber::new(VERSION),
Ok(VersionNumber {
major: 10,
minor: 5,
patch: 20
})
);
let err_version = VersionStrings::new("not a version number");
assert!(VersionNumber::new(err_version).is_err());
Whether the self
version number is compatible with the
library_implementor
version number.
This uses modified semver rules where:
-
For 0.y.z ,y is interpreted as a major version, z is interpreted as the minor version,
-
For x.y.z ,x>=1,y is interpreted as a minor version.
-
Libraries are compatible so long as they are the same major version with a minor_version >=
self
.
Example
use abi_stable::sabi_types::VersionNumber;
let v0_1_0 = VersionNumber {
major: 0,
minor: 1,
patch: 0,
};
let v0_1_5 = VersionNumber {
major: 0,
minor: 1,
patch: 5,
};
let v0_1_8 = VersionNumber {
major: 0,
minor: 1,
patch: 8,
};
let v0_2_0 = VersionNumber {
major: 0,
minor: 2,
patch: 0,
};
assert!(v0_1_0.is_compatible(v0_1_5), "'{}' '{}'", v0_1_0, v0_1_5);
assert!(v0_1_5.is_compatible(v0_1_8), "'{}' '{}'", v0_1_5, v0_1_8);
assert!(!v0_1_8.is_compatible(v0_2_0), "'{}' '{}'", v0_1_8, v0_2_0);
Whether the self
version number is compatible with the
library version number.
This uses the same semver rules as cargo:
-
For 0.y.z ,y is interpreted as a major version, z is interpreted as the minor version,
-
For x.y.z ,x>=1,y is interpreted as a minor version.
-
Libraries are compatible so long as they are the same major version irrespective of their minor version.
Example
use abi_stable::sabi_types::VersionNumber;
let v0_1_0 = VersionNumber {
major: 0,
minor: 1,
patch: 0,
};
let v0_1_5 = VersionNumber {
major: 0,
minor: 1,
patch: 5,
};
let v0_1_8 = VersionNumber {
major: 0,
minor: 1,
patch: 8,
};
let v0_2_0 = VersionNumber {
major: 0,
minor: 2,
patch: 0,
};
let v0_2_8 = VersionNumber {
major: 0,
minor: 2,
patch: 8,
};
let v1_0_0 = VersionNumber {
major: 1,
minor: 0,
patch: 0,
};
let v1_5_0 = VersionNumber {
major: 1,
minor: 5,
patch: 0,
};
let v2_0_0 = VersionNumber {
major: 2,
minor: 0,
patch: 0,
};
fn is_compat_assert(l: VersionNumber, r: VersionNumber, are_they_compat: bool) {
assert_eq!(l.is_loosely_compatible(r), are_they_compat);
assert_eq!(r.is_loosely_compatible(l), are_they_compat);
}
is_compat_assert(v0_1_0, v0_1_5, true);
is_compat_assert(v0_1_5, v0_1_8, true);
is_compat_assert(v1_0_0, v1_5_0, true);
is_compat_assert(v0_1_8, v0_2_0, false);
is_compat_assert(v0_2_8, v1_0_0, false);
is_compat_assert(v2_0_0, v1_0_0, false);
is_compat_assert(v2_0_0, v1_5_0, false);
Trait Implementations
type StaticEquivalent = _static_VersionNumber
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
type IsNonZeroType = False
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
The layout of the type provided by implementors.
const
-equivalents of the associated types.
Auto Trait Implementations
impl RefUnwindSafe for VersionNumber
impl Send for VersionNumber
impl Sync for VersionNumber
impl Unpin for VersionNumber
impl UnwindSafe for VersionNumber
Blanket Implementations
Mutably borrows from an owned value. Read more
type ROwned = T
type ROwned = T
The owned type, stored in RCow::Owned
type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
Compares the address of self
with the address of other
. Read more
Emulates the pipeline operator, allowing method syntax in more places. Read more
The same as piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more
The same as piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
. Read more
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Performs a conversion with Into
.
using the turbofish .into_::<_>()
syntax. Read more
Performs a reference to reference conversion with AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more
Performs a mutable reference to mutable reference conversion with AsMut
,
using the turbofish .as_mut_::<_>()
syntax. Read more
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(
self
) -> <Self as CanTransmuteElement<T>>::TransmutedPtr where
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
type Type = T
type Type = T
This is always Self
.
Converts a value back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
Converts a value back to the original type.
Converts a reference back to the original type.
Converts a mutable reference back to the original type.
alloc
only.Converts a box back to the original type.
alloc
only.Converts an Arc back to the original type.
alloc
only.Converts an Rc back to the original type.