pub struct Version { /* private fields */ }Implementations§
Source§impl Version
impl Version
pub fn new<T: AsRef<str>>(input: T) -> Self
Sourcepub fn is_latest(&self) -> bool
pub fn is_latest(&self) -> bool
Returns true if the version matches latest (case-insensitive).
The latest version is always the greatest of any versions.
§Examples
use winget_types::Version;
assert!(Version::new("latest").is_latest());
assert!(Version::new("LATEST").is_latest());
assert!(!Version::new("1.2.3").is_latest());
assert!(Version::new("latest") > Version::new("999.999.999"));Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Returns true if the version matches unknown (case-insensitive).
An unknown version is always the minimum of any versions.
§Examples
use winget_types::Version;
assert!(Version::new("unknown").is_unknown());
assert!(Version::new("UNKNOWN").is_unknown());
assert!(!Version::new("1.2.3").is_unknown());
assert!(Version::new("unknown") < Version::new("0"));Sourcepub fn closest<'iter, I, T>(&self, versions: I) -> Option<&'iter T>
pub fn closest<'iter, I, T>(&self, versions: I) -> Option<&'iter T>
Finds the closest version to this version from a given list of versions.
§Examples
use winget_types::Version;
let versions = [Version::new("1.2.5"), Version::new("1.2.0")];
let version = Version::new("1.2.3");
assert_eq!(version.closest(&versions).map(Version::as_str), Some("1.2.5"));Trait Implementations§
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 Ord for Version
impl Ord for Version
Source§impl PartialEq<PackageVersion> for Version
impl PartialEq<PackageVersion> for Version
Source§impl PartialEq<Version> for PackageVersion
impl PartialEq<Version> for PackageVersion
Source§impl PartialOrd for Version
impl PartialOrd for Version
Source§impl TryFrom<Version> for PackageVersion
impl TryFrom<Version> for PackageVersion
impl Eq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
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