pub struct MinimalVersion {
pub pkgver: PackageVersion,
pub epoch: Option<Epoch>,
}Expand description
A package version without a PackageRelease.
Tracks an optional Epoch and a PackageVersion, but no PackageRelease.
This reflects the minimal and minimal with epoch forms of alpm-package-version.
§Notes
- If
PackageReleaseshould be optional for your use-case, useVersioninstead. - If
PackageReleaseshould be mandatory for your use-case, useFullVersioninstead.
§Examples
use std::str::FromStr;
use alpm_types::MinimalVersion;
// A minimal version.
let version = MinimalVersion::from_str("1.0.0")?;
// A minimal version with epoch.
let version = MinimalVersion::from_str("1:1.0.0")?;Fields§
§pkgver: PackageVersionThe version of the package
epoch: Option<Epoch>The epoch of the package
Implementations§
Source§impl MinimalVersion
impl MinimalVersion
Sourcepub fn new(pkgver: PackageVersion, epoch: Option<Epoch>) -> Self
pub fn new(pkgver: PackageVersion, epoch: Option<Epoch>) -> Self
Creates a new MinimalVersion.
§Examples
use alpm_types::{Epoch, MinimalVersion, PackageVersion};
// A minimal version.
let version = MinimalVersion::new(PackageVersion::new("1.0.0".to_string())?, None);
// A minimal version with epoch.
let version = MinimalVersion::new(
PackageVersion::new("1.0.0".to_string())?,
Some(Epoch::new(1)),
);Sourcepub fn vercmp(&self, other: &MinimalVersion) -> i8
pub fn vercmp(&self, other: &MinimalVersion) -> i8
Compares self to another MinimalVersion 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 MinimalVersion::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::MinimalVersion;
assert_eq!(
MinimalVersion::from_str("1.0.0")?.vercmp(&MinimalVersion::from_str("0.1.0")?),
1
);
assert_eq!(
MinimalVersion::from_str("1.0.0")?.vercmp(&MinimalVersion::from_str("1.0.0")?),
0
);
assert_eq!(
MinimalVersion::from_str("0.1.0")?.vercmp(&MinimalVersion::from_str("1.0.0")?),
-1
);Trait Implementations§
Source§impl AlpmParser for MinimalVersion
impl AlpmParser for MinimalVersion
Source§fn parser(input: &mut &str) -> ModalResult<Self>
fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes a MinimalVersion in a string slice.
§Errors
Returns an error if input does not begin with a valid alpm-package-version (minimal or
minimal with epoch).
Source§impl Clone for MinimalVersion
impl Clone for MinimalVersion
Source§fn clone(&self) -> MinimalVersion
fn clone(&self) -> MinimalVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MinimalVersion
impl Debug for MinimalVersion
Source§impl<'de> Deserialize<'de> for MinimalVersion
impl<'de> Deserialize<'de> for MinimalVersion
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 MinimalVersion
impl Display for MinimalVersion
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<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 FromStr for MinimalVersion
impl FromStr for MinimalVersion
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Creates a new MinimalVersion from a string slice.
Delegates to MinimalVersion::parser.
§Errors
Returns an error if Version::parser fails.
Source§impl Ord for MinimalVersion
impl Ord for MinimalVersion
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares self to another MinimalVersion.
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::MinimalVersion;
// Examples for "minimal"
let version_a = MinimalVersion::from_str("0.1.0")?;
let version_b = MinimalVersion::from_str("1.0.0")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Less);
assert_eq!(version_b.cmp(&version_a), Ordering::Greater);
let version_a = MinimalVersion::from_str("1.0.0")?;
let version_b = MinimalVersion::from_str("1.0.0")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Equal);
// Examples for "minimal with epoch"
let version_a = MinimalVersion::from_str("1:1.0.0")?;
let version_b = MinimalVersion::from_str("1.0.0")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Greater);
assert_eq!(version_b.cmp(&version_a), Ordering::Less);
let version_a = MinimalVersion::from_str("1:1.0.0")?;
let version_b = MinimalVersion::from_str("1:1.0.0")?;
assert_eq!(version_a.cmp(&version_b), Ordering::Equal);1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MinimalVersion
impl PartialEq for MinimalVersion
Source§fn eq(&self, other: &MinimalVersion) -> bool
fn eq(&self, other: &MinimalVersion) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for MinimalVersion
impl PartialOrd for MinimalVersion
Source§impl Serialize for MinimalVersion
impl Serialize for MinimalVersion
Source§impl TryFrom<&Version> for MinimalVersion
impl TryFrom<&Version> for MinimalVersion
Source§impl TryFrom<Version> for MinimalVersion
impl TryFrom<Version> for MinimalVersion
impl Eq for MinimalVersion
impl StructuralPartialEq for MinimalVersion
Auto Trait Implementations§
impl Freeze for MinimalVersion
impl RefUnwindSafe for MinimalVersion
impl Send for MinimalVersion
impl Sync for MinimalVersion
impl Unpin for MinimalVersion
impl UnsafeUnpin for MinimalVersion
impl UnwindSafe for MinimalVersion
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.