aboutsummaryrefslogtreecommitdiff
path: root/src/models.rs
diff options
context:
space:
mode:
authorMax Audron <me@audron.dev>2026-01-30 18:19:42 +0100
committerMax Audron <me@audron.dev>2026-01-30 18:19:42 +0100
commit84e778c6f693027c4f9215eeeda203e36cc19f9a (patch)
tree0598fc34cac17c60d6530e0af7f86c8aa48276a6 /src/models.rs
init
Diffstat (limited to 'src/models.rs')
-rw-r--r--src/models.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs
new file mode 100644
index 0000000..66389ae
--- /dev/null
+++ b/src/models.rs
@@ -0,0 +1,50 @@
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ContentItem {
+ pub name: String,
+ pub author: String,
+ pub information_url: String,
+ pub version: String,
+ pub active: bool,
+ pub clean_installation: bool,
+ #[serde(skip_serializing)]
+ pub download_url: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct Storage {
+ #[serde(default)]
+ pub car: HashMap<String, ContentItem>,
+ #[serde(default)]
+ pub track: HashMap<String, ContentItem>,
+ #[serde(default)]
+ pub luaapp: HashMap<String, ContentItem>,
+ #[serde(default)]
+ pub app: HashMap<String, ContentItem>,
+ #[serde(default)]
+ pub filter: HashMap<String, ContentItem>,
+}
+
+#[derive(Debug, Serialize)]
+pub struct ListResponse {
+ pub car: HashMap<String, String>,
+ pub track: HashMap<String, String>,
+ pub luaapp: HashMap<String, String>,
+ pub app: HashMap<String, String>,
+ pub filter: HashMap<String, String>,
+}
+
+impl From<&Storage> for ListResponse {
+ fn from(storage: &Storage) -> Self {
+ Self {
+ car: storage.car.iter().map(|(k, v)| (k.clone(), v.version.clone())).collect(),
+ track: storage.track.iter().map(|(k, v)| (k.clone(), v.version.clone())).collect(),
+ luaapp: storage.luaapp.iter().map(|(k, v)| (k.clone(), v.version.clone())).collect(),
+ app: storage.app.iter().map(|(k, v)| (k.clone(), v.version.clone())).collect(),
+ filter: storage.filter.iter().map(|(k, v)| (k.clone(), v.version.clone())).collect(),
+ }
+ }
+}