summaryrefslogtreecommitdiff
path: root/src/index.rs
diff options
context:
space:
mode:
authorNaz <ndpm13@ch-naseem.com>2025-07-31 15:46:40 +0100
committerNaz <ndpm13@ch-naseem.com>2025-07-31 15:46:40 +0100
commit29c3640e5fea0f423357c28e3c221fcaca004ee8 (patch)
treea7f774b1f58ccb3070fd3b0f7d3dad1e524bc40d /src/index.rs
parentbd230c3d916be2af8f97e587f3f764800077cba4 (diff)
✨feat: use the custom Result type instead of the standard
Diffstat (limited to 'src/index.rs')
-rw-r--r--src/index.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/index.rs b/src/index.rs
index 069068a..dff2f58 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -1,6 +1,6 @@
use tokio::fs;
-use crate::{AppImage, index_dir};
+use crate::{AppImage, Result, index_dir};
#[derive(Debug, Default)]
pub struct Index {}
@@ -9,7 +9,7 @@ impl Index {
pub fn new() -> Self {
Self {}
}
- pub async fn get(&self, appname: &str) -> Result<AppImage, Box<dyn std::error::Error>> {
+ pub async fn get(&self, appname: &str) -> Result<AppImage> {
let index_file_path = index_dir().join(format!("{appname}.json"));
let index_file_content = fs::read_to_string(&index_file_path).await?;
let appimage: AppImage = serde_json::from_str(&index_file_content)?;
@@ -19,11 +19,7 @@ impl Index {
pub fn exists(&self, executable: &str) -> bool {
index_dir().join(format!("{}.json", &executable)).exists()
}
- pub async fn add(
- &self,
- appimage: &AppImage,
- appname: &str,
- ) -> Result<(), Box<dyn std::error::Error>> {
+ pub async fn add(&self, appimage: &AppImage, appname: &str) -> Result<()> {
fs::create_dir_all(&index_dir()).await?;
let index_file = &index_dir().join(format!("{appname}.json"));
@@ -33,7 +29,7 @@ impl Index {
Ok(())
}
- pub async fn remove(&self, appname: &str) -> Result<(), Box<dyn std::error::Error>> {
+ pub async fn remove(&self, appname: &str) -> Result<()> {
let index_file_path = index_dir().join(format!("{appname}.json"));
fs::remove_file(index_file_path).await?;