summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-04-19 17:54:52 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-04-19 17:58:33 +0200
commit7cc25e9cf2dda28f1f8dea43caac7bd6291ed1f1 (patch)
tree9fa1b948ac6ff7179fb311b54e60f1e41a97087c /src/config.rs
Initial import
In the beginning there was darkness. So I spoke "git init". And there was a git repository.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..7d47004
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,60 @@
+use std::ops::Deref;
+
+use url::Url;
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Configuration {
+ #[serde(with = "url_serde")]
+ #[serde(rename = "repology_url")]
+ repology_url: Url,
+
+ #[serde(rename = "whitelist")]
+ whitelist: Vec<String>,
+
+ #[serde(rename = "blacklist")]
+ blacklist: Vec<String>,
+
+ #[serde(rename = "local_packages")]
+ local_packages: Option<Vec<Package>>,
+}
+
+impl Configuration {
+ pub fn repology_url(&self) -> &Url {
+ &self.repology_url
+ }
+
+ pub fn whitelist(&self) -> &Vec<String> {
+ &self.whitelist
+ }
+
+ pub fn blacklist(&self) -> &Vec<String> {
+ &self.blacklist
+ }
+
+ // unused
+ //pub fn local_packages(&self) -> Option<&Vec<Package>> {
+ // self.local_packages.as_ref()
+ //}
+
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Package {
+ #[serde(rename = "name")]
+ name: String,
+
+ #[serde(rename = "local_version")]
+ local_version: Version,
+}
+
+/// Not reusing the librepology type here because it might change
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Version(String);
+
+impl Deref for Version {
+ type Target = String;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}