diff options
| author | 2025-01-13 03:05:17 -0600 | |
|---|---|---|
| committer | 2025-01-13 03:05:17 -0600 | |
| commit | 6d0fb7c0f2fc9bf144b50b6bb00328b3f7057832 (patch) | |
| tree | 38d2840748e5593522542a8fb1c48776afa855fa /src/version.rs | |
| parent | add some logging and stuff (diff) | |
more stuff
Diffstat (limited to 'src/version.rs')
| -rw-r--r-- | src/version.rs | 27 |
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, |
