From 85fb9fcc50d16f8b8147c117521b836ab750cd98 Mon Sep 17 00:00:00 2001 From: Naz Date: Sun, 27 Jul 2025 14:37:16 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20add=20AppImage=20index=20persistence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/types.rs b/src/types.rs index bd903df..5636fe9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,8 @@ use serde::Serialize; use std::path::PathBuf; +use tokio::fs; + +use crate::{index_dir}; #[derive(Debug, Serialize)] pub struct AppImage { @@ -18,3 +21,14 @@ pub struct Source { pub struct SourceMetadata { pub url: String, } + +impl AppImage { + pub async fn save_to_index(&self, appname: &str) -> Result<(), Box> { + let index_file = &index_dir().join(format!("{appname}.json")); + + let json = serde_json::to_string_pretty(self)?; + fs::write(index_file, json).await?; + + Ok(()) + } +} -- cgit v1.2.3