Struct Version

Source
pub struct Version { /* private fields */ }
Expand description

Represents a version and compatibility rules.

Implementations§

Source§

impl Version

Source

pub const fn new(major: u64, minor: u64, patch: u64) -> Self

Creates a new version in the form major.minor.patch with a ruleset that is used to check other versions such that >=0.1.2, <0.2.0 or >=1.2.3, <2 depending on whether or not the major version is 0.

use distant_net::common::Version;

// Matching versions are compatible
let a = Version::new(1, 2, 3);
let b = Version::new(1, 2, 3);
assert!(a.is_compatible_with(&b));

// Version 1.2.3 is compatible with 1.2.4, but not the other way
let a = Version::new(1, 2, 3);
let b = Version::new(1, 2, 4);
assert!(a.is_compatible_with(&b));
assert!(!b.is_compatible_with(&a));

// Version 1.2.3 is compatible with 1.3.0, but not 2
let a = Version::new(1, 2, 3);
assert!(a.is_compatible_with(&Version::new(1, 3, 0)));
assert!(!a.is_compatible_with(&Version::new(2, 0, 0)));

// Version 0.1.2 is compatible with 0.1.3, but not the other way
let a = Version::new(0, 1, 2);
let b = Version::new(0, 1, 3);
assert!(a.is_compatible_with(&b));
assert!(!b.is_compatible_with(&a));

// Version 0.1.2 is not compatible with 0.2
let a = Version::new(0, 1, 2);
let b = Version::new(0, 2, 0);
assert!(!a.is_compatible_with(&b));
assert!(!b.is_compatible_with(&a));
Source

pub fn is_compatible_with(&self, other: &Self) -> bool

Returns true if this version is compatible with another version.

Source

pub const fn from_be_bytes(bytes: [u8; 24]) -> Self

Converts from a collection of bytes into a version using the byte form major/minor/patch using big endian.

Source

pub const fn to_be_bytes(&self) -> [u8; 24]

Converts the version into a byte form of major/minor/patch using big endian.

Trait Implementations§

Source§

impl Clone for Version

Source§

fn clone(&self) -> Version

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Version

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Version

Source§

fn default() -> Self

Default version is 0.0.0.

Source§

impl Display for Version

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Version> for Version

Source§

fn from(version: Version) -> Self

Creates a new Version using the major, minor, and patch information from semver::Version.

Source§

impl From<Version> for Version

Source§

fn from(version: Version) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes and produces Box<dyn Any>
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V