pub struct PackageVersion(/* private fields */);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 ASCII characters,
excluding the ‘:’, ‘/’, ‘-’, ‘<’, ‘>’, ‘=’, or any whitespace characters and must be at least
one character long.
NOTE: This implementation of PackageVersion is stricter than that of libalpm/pacman. It does not
allow empty strings "".
§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_ok());
assert!(PackageVersion::new("=1.0".to_string()).is_err());
assert!(PackageVersion::new("1<0".to_string()).is_err());Implementations§
Source§impl PackageVersion
impl PackageVersion
Sourcepub fn new(pkgver: String) -> Result<Self, Error>
pub fn new(pkgver: String) -> Result<Self, Error>
Create a new PackageVersion from a string and return it in a Result
Sourcepub fn segments(&self) -> VersionSegments<'_> ⓘ
pub fn segments(&self) -> VersionSegments<'_> ⓘ
Return an iterator over all segments of this version.
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes a PackageVersion in a string slice.
Consumes all of its input.
§Errors
Returns an error if input is not a valid alpm-pkgver.
Trait Implementations§
Source§impl Clone for PackageVersion
impl Clone for PackageVersion
Source§fn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
1.0.0§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<'de> Deserialize<'de> for PackageVersion
impl<'de> Deserialize<'de> for PackageVersion
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 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’s behavior for backwards compatibility reasons. https://gitlab.archlinux.org/pacman/pacman/-/blob/a2d029388c7c206f5576456f91bfbea2dca98c96/lib/libalpm/version.c#L83-217
1.21.0§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PackageVersion
impl PartialEq for PackageVersion
Source§impl PartialOrd for PackageVersion
impl PartialOrd for PackageVersion
Source§impl Serialize for PackageVersion
impl Serialize for PackageVersion
impl Eq for PackageVersion
Auto Trait Implementations§
impl Freeze for PackageVersion
impl RefUnwindSafe for PackageVersion
impl Send for PackageVersion
impl Sync for PackageVersion
impl Unpin for PackageVersion
impl UnwindSafe for PackageVersion
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)