pub struct PackageVersion(/* private fields */);Implementations§
Source§impl PackageVersion
impl PackageVersion
Sourcepub fn new<T: AsRef<str>>(version: T) -> Result<Self, PackageVersionError>
pub fn new<T: AsRef<str>>(version: T) -> Result<Self, PackageVersionError>
Creates a new PackageVersion from any type that implements AsRef<str>.
§Errors
Returns an Err if the PackageVersion is empty, more than 128 characters long, or
contains a disallowed character (control or one of DISALLOWED_CHARACTERS).
§Examples
use winget_types::PackageVersion;
let version = PackageVersion::new("1.2.3")?;
let other_version = PackageVersion::new("1.2.4.0")?;
assert!(version < other_version);Sourcepub unsafe fn new_unchecked<T: AsRef<str>>(version: T) -> Self
pub unsafe fn new_unchecked<T: AsRef<str>>(version: T) -> Self
Creates a new PackageVersion from any type that implements AsRef<str>, without checking
its validity.
§Safety
The package version must not be more than 128 characters long, or contain a disallowed
character (control, or one of DISALLOWED_CHARACTERS).
Sourcepub fn is_latest(&self) -> bool
pub fn is_latest(&self) -> bool
Returns true if the version matches latest (case-insensitive).
§Examples
use winget_types::PackageVersion;
assert!(PackageVersion::new("latest")?.is_latest());
assert!(PackageVersion::new("LATEST")?.is_latest());
assert!(!PackageVersion::new("1.2.3")?.is_latest());Sourcepub fn closest<'iter, I>(&self, versions: I) -> Option<&'iter Self>where
I: IntoIterator<Item = &'iter Self>,
pub fn closest<'iter, I>(&self, versions: I) -> Option<&'iter Self>where
I: IntoIterator<Item = &'iter Self>,
Finds the closest version to this version from a given list of package versions.
§Examples
use winget_types::PackageVersion;
let versions = [PackageVersion::new("1.2.5")?, PackageVersion::new("1.2.0")?];
let version = PackageVersion::new("1.2.3")?;
assert_eq!(version.closest(&versions).map(PackageVersion::as_str), Some("1.2.5"));Trait Implementations§
Source§impl Clone for PackageVersion
impl Clone for PackageVersion
Source§fn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PackageVersion
impl Debug for PackageVersion
Source§impl Default for PackageVersion
impl Default for PackageVersion
Source§fn default() -> PackageVersion
fn default() -> PackageVersion
Returns the “default value” for a type. Read more
Source§impl Display for PackageVersion
impl Display for PackageVersion
Source§impl<'ver> From<&'ver PackageVersion> for &'ver Version
impl<'ver> From<&'ver PackageVersion> for &'ver Version
Source§fn from(value: &'ver PackageVersion) -> Self
fn from(value: &'ver PackageVersion) -> Self
Converts to this type from the input type.
Source§impl FromStr for PackageVersion
impl FromStr for PackageVersion
Source§impl Hash for PackageVersion
impl Hash for PackageVersion
Source§impl Ord for PackageVersion
impl Ord for PackageVersion
Source§fn cmp(&self, other: &PackageVersion) -> Ordering
fn cmp(&self, other: &PackageVersion) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq<PackageVersion> for Version
impl PartialEq<PackageVersion> for Version
Source§impl PartialEq<Version> for PackageVersion
impl PartialEq<Version> for PackageVersion
Source§impl PartialEq for PackageVersion
impl PartialEq for PackageVersion
Source§impl PartialOrd for PackageVersion
impl PartialOrd for PackageVersion
Source§impl TryFrom<Version> for PackageVersion
impl TryFrom<Version> for PackageVersion
impl Eq for PackageVersion
impl StructuralPartialEq 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§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more