summaryrefslogtreecommitdiffstats
path: root/src/version.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/version.rs')
-rw-r--r--src/version.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/version.rs b/src/version.rs
index 078927d..ae91149 100644
--- a/src/version.rs
+++ b/src/version.rs
@@ -81,11 +81,24 @@ pub struct CompatibilityRule {
pub os: Option<OSRestriction>
}
+pub trait FeatureMatcher {
+ fn matches(&self, feature: &str) -> bool;
+}
+
+impl<F> FeatureMatcher for F
+where
+ F: Fn(&str) -> bool
+{
+ fn matches(&self, feature: &str) -> bool {
+ self(feature)
+ }
+}
+
impl CompatibilityRule {
- pub fn features_match(&self, checker: fn(&str) -> bool) -> bool {
+ pub fn features_match(&self, checker: impl FeatureMatcher) -> bool {
if let Some(m) = self.features.as_ref() {
for (feat, expect) in m {
- if checker(feat) != *expect {
+ if checker.matches(feat) != *expect {
return false;
}
}
@@ -206,6 +219,16 @@ pub struct Library {
pub url: Option<String> // old format
}
+impl LibraryDownloads {
+ pub fn get_download_info(&self, classifier: Option<&str>) -> Option<&DownloadInfo> {
+ if let Some(classifier) = classifier {
+ self.classifiers.as_ref()?.get(classifier)
+ } else {
+ self.artifact.as_ref()
+ }
+ }
+}
+
#[derive(Deserialize, Debug, Clone)]
pub struct ClientLogging {
pub argument: String,