pub struct PackageRelease {
pub major: usize,
pub minor: Option<usize>,
}
Expand description
The release version of a package.
A PackageRelease
wraps a usize
for its major
version and an optional usize
for its
minor
version.
PackageRelease
is used to indicate the build version of a package.
It is mostly useful in conjunction with a PackageVersion
(see Version
).
Refer to alpm-pkgrel for more details on the format.
§Examples
use std::str::FromStr;
use alpm_types::PackageRelease;
assert!(PackageRelease::from_str("1").is_ok());
assert!(PackageRelease::from_str("1.1").is_ok());
assert!(PackageRelease::from_str("0").is_ok());
assert!(PackageRelease::from_str("a").is_err());
assert!(PackageRelease::from_str("1.a").is_err());
Fields§
§major: usize
The major version of this package release.
minor: Option<usize>
The optional minor version of this package release.
Implementations§
Source§impl PackageRelease
impl PackageRelease
Sourcepub fn new(major: usize, minor: Option<usize>) -> Self
pub fn new(major: usize, minor: Option<usize>) -> Self
Creates a new PackageRelease
from a major
and optional minor
integer version.
§Examples
use alpm_types::PackageRelease;
let release = PackageRelease::new(1, Some(2));
assert_eq!(format!("{release}"), "1.2");
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes a PackageRelease
in a string slice.
Consumes all of its input.
§Errors
Returns an error if input
does not contain a valid PackageRelease
.
Trait Implementations§
Source§impl Clone for PackageRelease
impl Clone for PackageRelease
Source§fn clone(&self) -> PackageRelease
fn clone(&self) -> PackageRelease
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PackageRelease
impl Debug for PackageRelease
Source§impl<'de> Deserialize<'de> for PackageRelease
impl<'de> Deserialize<'de> for PackageRelease
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 PackageRelease
impl Display for PackageRelease
Source§impl FromStr for PackageRelease
impl FromStr for PackageRelease
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Creates a PackageRelease
from a string slice.
Delegates to PackageRelease::parser
.
§Errors
Returns an error if PackageRelease::parser
fails.