summaryrefslogtreecommitdiff
path: root/src/index.rs
diff options
context:
space:
mode:
authorNaz <ndpm13@ch-naseem.com>2025-07-29 13:46:43 +0100
committerNaz <ndpm13@ch-naseem.com>2025-07-29 13:46:43 +0100
commitbd8adb9f0193f1482ca866b06cf133ff68fd9a8e (patch)
tree8d29230c9821e0512c207e2415e682a997090d2e /src/index.rs
parentf419a08d2861d76dce3d2a8206d6f1eb24bf1f2e (diff)
🔧refactor: remove types.rs
Diffstat (limited to 'src/index.rs')
-rw-r--r--src/index.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/index.rs b/src/index.rs
new file mode 100644
index 0000000..e543b1d
--- /dev/null
+++ b/src/index.rs
@@ -0,0 +1,26 @@
+use tokio::fs;
+
+use crate::{AppImage, index_dir};
+
+#[derive(Debug, Default)]
+pub struct Index {}
+
+impl Index {
+ pub fn new() -> Self {
+ Self {}
+ }
+ pub async fn add(
+ &self,
+ appimage: &AppImage,
+ appname: &str,
+ ) -> Result<(), Box<dyn std::error::Error>> {
+ fs::create_dir_all(&index_dir()).await?;
+
+ let index_file = &index_dir().join(format!("{appname}.json"));
+
+ let json = serde_json::to_string_pretty(appimage)?;
+ fs::write(index_file, json).await?;
+
+ Ok(())
+ }
+}