pub struct PackageVersion(pub(crate) String);
Expand description
A pkgver of a package
PackageVersion is used to denote the upstream version of a package.
A PackageVersion wraps a String
, which is guaranteed to only contain alphanumeric characters,
"_"
, "+"
or "."
, but to not start with a "_"
, a "+"
or a "."
character and to be at
least one char long.
NOTE: This implementation of PackageVersion is stricter than that of libalpm/pacman. It does not
allow empty strings ""
, or chars that are not in the allowed set, or "."
as the first
character.
§Examples
use std::str::FromStr;
use alpm_types::PackageVersion;
assert!(PackageVersion::new("1".to_string()).is_ok());
assert!(PackageVersion::new("1.1".to_string()).is_ok());
assert!(PackageVersion::new("foo".to_string()).is_ok());
assert!(PackageVersion::new("0".to_string()).is_ok());
assert!(PackageVersion::new(".0.1".to_string()).is_err());
assert!(PackageVersion::new("_1.0".to_string()).is_err());
assert!(PackageVersion::new("+1.0".to_string()).is_err());
Tuple Fields§
§0: String
Implementations§
Trait Implementations§
Source§impl Clone for PackageVersion
impl Clone for PackageVersion
Source§fn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PackageVersion
impl Debug for PackageVersion
Source§impl Display for PackageVersion
impl Display for PackageVersion
Source§impl FromStr for PackageVersion
impl FromStr for PackageVersion
Source§impl Ord for PackageVersion
impl Ord for PackageVersion
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
This block implements the logic to determine which of two package versions is newer or whether they’re considered equal.
This logic is surprisingly complex as it mirrors the current C-alpmlib implementation for backwards compatibility reasons. https://gitlab.archlinux.org/pacman/pacman/-/blob/a2d029388c7c206f5576456f91bfbea2dca98c96/lib/libalpm/version.c#L83-217