diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-28 03:31:41 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-28 03:32:04 +0900 |
| commit | c7f53c5d7d581ebf76803650c63ec615b1558dc8 (patch) | |
| tree | c6d83819e82a83cf93ca737b661094a8ea800cec /crates/shirabe/src/installer/library_installer.rs | |
| parent | cc5d73c05a0abca2eebcc8a6afa0b1543ee49850 (diff) | |
| download | php-shirabe-refactor/composer-handles.tar.gz php-shirabe-refactor/composer-handles.tar.zst php-shirabe-refactor/composer-handles.zip | |
refactor(composer): represent composer via trait-based handlesrefactor/composer-handles
Replace the PartialComposer/Composer structs and the single
Rc<RefCell<PartialOrFullComposer>> enum with PartialComposer and
Composer traits (Composer: PartialComposer), InnerPartialComposer /
InnerFullComposer data structs, and the handle types FullComposerHandle
(impl Composer) and AnyComposerHandle (polymorphic enum, impl
PartialComposer), plus their weak variants.
Factory builds the full and partial graphs via separate Rc::new_cyclic
branches that share a build_composer_base helper. Call sites now use
trait methods that encapsulate borrowing instead of borrow_partial() /
composer_full*().
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer/library_installer.rs')
| -rw-r--r-- | crates/shirabe/src/installer/library_installer.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index c1fedef..b50dbff 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -9,7 +9,7 @@ use shirabe_php_shim::{ realpath, rmdir, rtrim, strpos, }; -use crate::composer::PartialComposerWeakHandle; +use crate::composer::{AnyComposerWeakHandle, Composer, PartialComposer}; use crate::downloader::DownloadManager; use crate::installer::BinaryInstaller; use crate::installer::BinaryPresenceInterface; @@ -24,7 +24,7 @@ use crate::util::Silencer; /// Package installation manager. #[derive(Debug)] pub struct LibraryInstaller { - pub(crate) composer: PartialComposerWeakHandle, + pub(crate) composer: AnyComposerWeakHandle, pub(crate) vendor_dir: String, pub(crate) download_manager: Option<std::rc::Rc<std::cell::RefCell<DownloadManager>>>, pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, @@ -37,7 +37,7 @@ impl LibraryInstaller { /// Initializes library installer. pub fn new( io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, - composer: PartialComposerWeakHandle, + composer: AnyComposerWeakHandle, r#type: Option<String>, filesystem: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, binary_installer: Option<BinaryInstaller>, @@ -48,15 +48,13 @@ impl LibraryInstaller { let download_manager = composer_rc .as_full() - .map(|full| full.borrow().get_download_manager()); - - let composer_ref = composer_rc.borrow_partial(); + .map(|full| full.get_download_manager()); let filesystem = filesystem .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None)))); let vendor_dir = rtrim( // TODO(phase-b): Config::get returns PhpMixed; coerce to String via get_str. - &composer_ref + &composer_rc .get_config() .borrow_mut() .get_str("vendor-dir") @@ -68,7 +66,7 @@ impl LibraryInstaller { // TODO(phase-b): pass io by reference/clone todo!("io reference"), rtrim( - &composer_ref + &composer_rc .get_config() .borrow_mut() .get_str("bin-dir") @@ -76,7 +74,7 @@ impl LibraryInstaller { Some("/"), ), // TODO(phase-b): Config::get returns PhpMixed; coerce to String via get_str. - composer_ref + composer_rc .get_config() .borrow_mut() .get_str("bin-compat") |
