Struct FullVersion

Source
pub struct FullVersion {
    pub pkgver: PackageVersion,
    pub pkgrel: PackageRelease,
    pub epoch: Option<Epoch>,
}
Expand description

A package version with mandatory PackageRelease.

Tracks an optional Epoch, a PackageVersion and a PackageRelease. This reflects the full and full with epoch forms of alpm-package-version.

§Note

If PackageRelease should be optional for your use-case, use Version instead.

§Examples

use std::str::FromStr;

use alpm_types::FullVersion;

// A full version.
let version = FullVersion::from_str("1.0.0-1")?;

// A full version with epoch.
let version = FullVersion::from_str("1:1.0.0-1")?;

Fields§

§pkgver: PackageVersion

The version of the package

§pkgrel: PackageRelease

The release of the package

§epoch: Option<Epoch>

The epoch of the package

Implementations§

Source§

impl FullVersion

Source

pub fn new( pkgver: PackageVersion, pkgrel: PackageRelease, epoch: Option<Epoch>, ) -> Self

Creates a new FullVersion.

§Examples
use alpm_types::{Epoch, FullVersion, PackageRelease, PackageVersion};

// A full version.
let version = FullVersion::new(
    PackageVersion::new("1.0.0".to_string())?,
    PackageRelease::new(1, None),
    None,
);

// A full version with epoch.
let version = FullVersion::new(
    PackageVersion::new("1.0.0".to_string())?,
    PackageRelease::new(1, None),
    Some(Epoch::new(1.try_into()?)),
);
Source

pub fn vercmp(&self, other: &FullVersion) -> i8

Compares self to another FullVersion and returns a number.

  • 1 if self is newer than other
  • 0 if self and other are equal
  • -1 if self is older than other

This output behavior is based on the behavior of the vercmp tool.

Delegates to FullVersion::cmp for comparison. The rules and algorithms used for comparison are explained in more detail in alpm-package-version and alpm-pkgver.

§Examples
use std::str::FromStr;

use alpm_types::FullVersion;

assert_eq!(
    FullVersion::from_str("1.0.0-1")?.vercmp(&FullVersion::from_str("0.1.0-1")?),
    1
);
assert_eq!(
    FullVersion::from_str("1.0.0-1")?.vercmp(&FullVersion::from_str("1.0.0-1")?),
    0
);
assert_eq!(
    FullVersion::from_str("0.1.0-1")?.vercmp(&FullVersion::from_str("1.0.0-1")?),
    -1
);
Source

pub fn parser(input: &mut &str) -> ModalResult<Self>

Recognizes a FullVersion in a string slice.

Consumes all of its input.

§Errors

Returns an error if input is not a valid alpm-package-version (full or full with epoch).

Trait Implementations§

Source§

impl Clone for FullVersion

Source§

fn clone(&self) -> FullVersion

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FullVersion

Source§

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

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

impl<'de> Deserialize<'de> for FullVersion

Source§

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 FullVersion

Source§

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

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

impl From<&FullVersion> for Version

Source§

fn from(value: &FullVersion) -> Self

Creates a Version from a FullVersion reference.

Source§

impl From<FullVersion> for Version

Source§

fn from(value: FullVersion) -> Self

Creates a Version from a FullVersion.

Source§

impl FromStr for FullVersion

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Creates a new FullVersion from a string slice.

Delegates to FullVersion::parser.

§Errors

Returns an error if Version::parser fails.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl Ord for FullVersion

Source§

fn cmp(&self, other: &Self) -> Ordering

Compares self to another FullVersion.

The comparison rules and algorithms are explained in more detail in alpm-package-version and alpm-pkgver.

§Examples
use std::{cmp::Ordering, str::FromStr};

use alpm_types::FullVersion;

// Examples for "full"
let version_a = FullVersion::from_str("1.0.0-1")?;
let version_b = FullVersion::from_str("1.0.0-2")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Less);
assert_eq!(version_b.cmp(&version_a), Ordering::Greater);

let version_a = FullVersion::from_str("1.0.0-1")?;
let version_b = FullVersion::from_str("1.0.0-1")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Equal);

// Examples for "full with epoch"
let version_a = FullVersion::from_str("1:1.0.0-1")?;
let version_b = FullVersion::from_str("1.0.0-2")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Greater);
assert_eq!(version_b.cmp(&version_a), Ordering::Less);

let version_a = FullVersion::from_str("1:1.0.0-1")?;
let version_b = FullVersion::from_str("1:1.0.0-1")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Equal);
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FullVersion

Source§

fn eq(&self, other: &FullVersion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FullVersion

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for FullVersion

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&Version> for FullVersion

Source§

fn try_from(value: &Version) -> Result<Self, Self::Error>

Creates a FullVersion from a Version reference.

§Errors

Returns an error if value.pkgrel is None.

Source§

type Error = Error

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

impl TryFrom<Version> for FullVersion

Source§

fn try_from(value: Version) -> Result<Self, Self::Error>

Creates a FullVersion from a Version.

§Errors

Returns an error if value.pkgrel is None.

Source§

type Error = Error

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

impl Eq for FullVersion

Source§

impl StructuralPartialEq for FullVersion

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> 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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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