diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-07-31 15:46:40 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-07-31 15:46:40 +0100 |
| commit | 29c3640e5fea0f423357c28e3c221fcaca004ee8 (patch) | |
| tree | a7f774b1f58ccb3070fd3b0f7d3dad1e524bc40d /src/manager.rs | |
| parent | bd230c3d916be2af8f97e587f3f764800077cba4 (diff) | |
✨feat: use the custom Result type instead of the standard
Diffstat (limited to 'src/manager.rs')
| -rw-r--r-- | src/manager.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/manager.rs b/src/manager.rs index 66ed6f6..6616e1a 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -1,6 +1,6 @@ use tokio::fs; -use crate::{AppImage, Downloader, Index, SymlinkManager, index_dir}; +use crate::{AppImage, Downloader, Index, Result, SymlinkManager, index_dir}; #[derive(Debug, Default)] pub struct PackageManager { @@ -17,13 +17,10 @@ impl PackageManager { symlink_manager: SymlinkManager::new(), } } - pub async fn install( - &self, - appimage: &mut AppImage, - appname: &str, - ) -> Result<(), Box<dyn std::error::Error>> { + pub async fn install(&self, appimage: &mut AppImage, appname: &str) -> Result<()> { if self.index.exists(&appimage.executable) { - return Err(format!("{} is already installed.", &appimage.executable).into()); + println!("{} is already installed.", appimage.executable); + return Ok(()); } appimage.file_path = self @@ -37,7 +34,7 @@ impl PackageManager { self.symlink_manager.create(appimage).await?; Ok(()) } - pub async fn remove(&self, appname: &str) -> Result<(), Box<dyn std::error::Error>> { + pub async fn remove(&self, appname: &str) -> Result<()> { let appimage = self.index.get(appname).await?; fs::remove_file(&appimage.file_path).await?; @@ -46,7 +43,7 @@ impl PackageManager { Ok(()) } - pub async fn list(&self) -> Result<(), Box<dyn std::error::Error>> { + pub async fn list(&self) -> Result<()> { let mut appimages = fs::read_dir(index_dir()).await?; while let Some(appimage) = appimages.next_entry().await? { |
