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
impl FullVersion
Sourcepub fn new(
pkgver: PackageVersion,
pkgrel: PackageRelease,
epoch: Option<Epoch>,
) -> Self
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()?)),
);
Sourcepub fn vercmp(&self, other: &FullVersion) -> i8
pub fn vercmp(&self, other: &FullVersion) -> i8
Compares self
to another FullVersion
and returns a number.
1
ifself
is newer thanother
0
ifself
andother
are equal-1
ifself
is older thanother
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
);
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
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
impl Clone for FullVersion
Source§fn clone(&self) -> FullVersion
fn clone(&self) -> FullVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for FullVersion
impl Debug for FullVersion
Source§impl<'de> Deserialize<'de> for FullVersion
impl<'de> Deserialize<'de> for FullVersion
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>,
Source§impl Display for FullVersion
impl Display for FullVersion
Source§impl From<&FullVersion> for Version
impl From<&FullVersion> for Version
Source§fn from(value: &FullVersion) -> Self
fn from(value: &FullVersion) -> Self
Creates a Version
from a FullVersion
reference.
Source§impl From<FullVersion> for Version
impl From<FullVersion> for Version
Source§fn from(value: FullVersion) -> Self
fn from(value: FullVersion) -> Self
Creates a Version
from a FullVersion
.
Source§impl FromStr for FullVersion
impl FromStr for FullVersion
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
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§impl Ord for FullVersion
impl Ord for FullVersion
Source§fn cmp(&self, other: &Self) -> Ordering
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);