pub struct Version {
pub pkgver: PackageVersion,
pub epoch: Option<Epoch>,
pub pkgrel: Option<PackageRelease>,
}Expand description
A version of a package
A Version generically tracks an optional Epoch, a PackageVersion and an optional
PackageRelease.
See alpm-package-version for details on the format.
§Notes
- If
PackageReleaseshould be mandatory for your use-case, useFullVersioninstead. - If
PackageReleaseshould not be used in your use-case, useMinimalVersioninstead.
§Examples
use std::str::FromStr;
use alpm_types::{Epoch, PackageRelease, PackageVersion, Version};
let version = Version::from_str("1:2-3")?;
assert_eq!(version.epoch, Some(Epoch::from_str("1")?));
assert_eq!(version.pkgver, PackageVersion::new("2".to_string())?);
assert_eq!(version.pkgrel, Some(PackageRelease::new(3, None)));Fields§
§pkgver: PackageVersionThe version of the package
epoch: Option<Epoch>The epoch of the package
pkgrel: Option<PackageRelease>The release of the package
Implementations§
Source§impl Version
impl Version
Sourcepub fn new(
pkgver: PackageVersion,
epoch: Option<Epoch>,
pkgrel: Option<PackageRelease>,
) -> Self
pub fn new( pkgver: PackageVersion, epoch: Option<Epoch>, pkgrel: Option<PackageRelease>, ) -> Self
Create a new Version
Sourcepub fn vercmp(a: &Version, b: &Version) -> i8
pub fn vercmp(a: &Version, b: &Version) -> i8
Compare two Versions and return a number
The comparison algorithm is based on libalpm/ pacman’s vercmp behavior.
1ifais newer thanb0ifaandbare considered to be the same version-1ifais older thanb
§Examples
use std::str::FromStr;
use alpm_types::Version;
assert_eq!(
Version::vercmp(&Version::from_str("1.0.0")?, &Version::from_str("0.1.0")?),
1
);
assert_eq!(
Version::vercmp(&Version::from_str("1.0.0")?, &Version::from_str("1.0.0")?),
0
);
assert_eq!(
Version::vercmp(&Version::from_str("0.1.0")?, &Version::from_str("1.0.0")?),
-1
);Trait Implementations§
Source§impl AlpmParser for Version
impl AlpmParser for Version
Source§impl<'de> Deserialize<'de> for Version
impl<'de> Deserialize<'de> for Version
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 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<&MinimalVersion> for Version
impl From<&MinimalVersion> for Version
Source§fn from(value: &MinimalVersion) -> Self
fn from(value: &MinimalVersion) -> Self
Creates a Version from a MinimalVersion 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 From<MinimalVersion> for Version
impl From<MinimalVersion> for Version
Source§fn from(value: MinimalVersion) -> Self
fn from(value: MinimalVersion) -> Self
Creates a Version from a MinimalVersion.
Source§impl Ord for Version
impl Ord for Version
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Version
impl PartialOrd for Version
Source§impl TryFrom<&Version> for FullVersion
impl TryFrom<&Version> for FullVersion
Source§impl TryFrom<&Version> for MinimalVersion
impl TryFrom<&Version> for MinimalVersion
Source§impl TryFrom<Version> for FullVersion
impl TryFrom<Version> for FullVersion
Source§impl TryFrom<Version> for MinimalVersion
impl TryFrom<Version> for MinimalVersion
impl Eq for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnsafeUnpin for Version
impl UnwindSafe for Version
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U> ParserUntil for Uwhere
U: AlpmParser,
impl<U> ParserUntil for Uwhere
U: AlpmParser,
Source§fn parser_until<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, U, ErrMode<ContextError>>
fn parser_until<'a, P>( delimiter: P, ) -> impl Parser<&'a str, U, ErrMode<ContextError>>
Returns a [Parser] that parses Self until the given delimiter parser
matches.
§Note
Does not consume the delimiter.
Source§fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
Source§impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
Source§fn parser_until_inclusive<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, U, ErrMode<ContextError>>
fn parser_until_inclusive<'a, P>( delimiter: P, ) -> impl Parser<&'a str, U, ErrMode<ContextError>>
Returns a [Parser] that parses the whole input and consumes the given delimiter parser.
Delegates to ParserUntil::parser_until and consumes the delimiter.