From bd8adb9f0193f1482ca866b06cf133ff68fd9a8e Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 29 Jul 2025 13:46:43 +0100 Subject: =?UTF-8?q?=F0=9F=94=A7refactor:=20remove=20types.rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/index.rs (limited to 'src/index.rs') 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> { + 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(()) + } +} -- cgit v1.2.3