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: PackageVersionThe version of the package
pkgrel: PackageReleaseThe 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.
1ifselfis newer thanother0ifselfandotherare equal-1ifselfis 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§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);1.21.0§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for FullVersion
impl PartialEq for FullVersion
Source§impl PartialOrd for FullVersion
impl PartialOrd for FullVersion
Source§impl Serialize for FullVersion
impl Serialize for FullVersion
Source§impl TryFrom<&Version> for FullVersion
impl TryFrom<&Version> for FullVersion
Source§impl TryFrom<Version> for FullVersion
impl TryFrom<Version> for FullVersion
impl Eq for FullVersion
impl StructuralPartialEq for FullVersion
Auto Trait Implementations§
impl Freeze for FullVersion
impl RefUnwindSafe for FullVersion
impl Send for FullVersion
impl Sync for FullVersion
impl Unpin for FullVersion
impl UnwindSafe for FullVersion
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)