diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-07-27 14:37:16 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-07-27 14:37:16 +0100 |
| commit | 85fb9fcc50d16f8b8147c117521b836ab750cd98 (patch) | |
| tree | a8222278ed4583c34075e0d956e1f33b3fe579bd /src | |
| parent | 44451e5e920d939ed63ee8942757e90d7188d8ff (diff) | |
✨feat: add AppImage index persistence
Diffstat (limited to 'src')
| -rw-r--r-- | src/types.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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<dyn std::error::Error>> { + let index_file = &index_dir().join(format!("{appname}.json")); + + let json = serde_json::to_string_pretty(self)?; + fs::write(index_file, json).await?; + + Ok(()) + } +} |
