From cc5d73c05a0abca2eebcc8a6afa0b1543ee49850 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 27 May 2026 00:49:33 +0900 Subject: refactor(package): pass package handles by value throughout Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/shirabe/src/installer/project_installer.rs | 30 ++++++++++------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'crates/shirabe/src/installer/project_installer.rs') diff --git a/crates/shirabe/src/installer/project_installer.rs b/crates/shirabe/src/installer/project_installer.rs index 129810b..6c8a279 100644 --- a/crates/shirabe/src/installer/project_installer.rs +++ b/crates/shirabe/src/installer/project_installer.rs @@ -2,7 +2,6 @@ use crate::downloader::DownloadManager; use crate::installer::InstallerInterface; -use crate::package::PackageInterface; use crate::package::PackageInterfaceHandle; use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; @@ -39,15 +38,15 @@ impl InstallerInterface for ProjectInstaller { fn is_installed( &self, _repo: &dyn InstalledRepositoryInterface, - _package: &dyn PackageInterface, + _package: PackageInterfaceHandle, ) -> bool { false } async fn download( &self, - package: &dyn PackageInterface, - prev_package: Option<&dyn PackageInterface>, + package: PackageInterfaceHandle, + prev_package: Option, ) -> anyhow::Result> { let install_path = &self.install_path; if std::path::Path::new(install_path).exists() @@ -72,8 +71,8 @@ impl InstallerInterface for ProjectInstaller { async fn prepare( &self, r#type: &str, - package: &dyn PackageInterface, - prev_package: Option<&dyn PackageInterface>, + package: PackageInterfaceHandle, + prev_package: Option, ) -> anyhow::Result> { self.download_manager .borrow() @@ -84,8 +83,8 @@ impl InstallerInterface for ProjectInstaller { async fn cleanup( &self, r#type: &str, - package: &dyn PackageInterface, - prev_package: Option<&dyn PackageInterface>, + package: PackageInterfaceHandle, + prev_package: Option, ) -> anyhow::Result> { self.download_manager .borrow() @@ -96,22 +95,19 @@ impl InstallerInterface for ProjectInstaller { async fn install( &mut self, _repo: &mut dyn InstalledRepositoryInterface, - package: &PackageInterfaceHandle, + package: PackageInterfaceHandle, ) -> anyhow::Result> { self.download_manager .borrow() - .install( - package.as_rc().borrow().as_package_interface(), - &self.install_path, - ) + .install(package, &self.install_path) .await } async fn update( &mut self, _repo: &mut dyn InstalledRepositoryInterface, - _initial: &PackageInterfaceHandle, - _target: &PackageInterfaceHandle, + _initial: PackageInterfaceHandle, + _target: PackageInterfaceHandle, ) -> anyhow::Result> { Err(InvalidArgumentException { message: "not supported".to_string(), @@ -123,7 +119,7 @@ impl InstallerInterface for ProjectInstaller { async fn uninstall( &mut self, _repo: &mut dyn InstalledRepositoryInterface, - _package: &PackageInterfaceHandle, + _package: PackageInterfaceHandle, ) -> anyhow::Result> { Err(InvalidArgumentException { message: "not supported".to_string(), @@ -132,7 +128,7 @@ impl InstallerInterface for ProjectInstaller { .into()) } - fn get_install_path(&self, _package: &dyn PackageInterface) -> Option { + fn get_install_path(&self, _package: PackageInterfaceHandle) -> Option { Some(self.install_path.clone()) } } -- cgit v1.3.1