From 3a388b98a9aa6a14b1c7f7dc909c109cf9837800 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 00:59:54 +0900 Subject: refactor: narrow pub(crate) items to private Porting mapped every PHP `protected` member onto `pub(crate)`, which is wider than nearly all of them need. Each item demoted here is reached only from the module that defines it, so the crate-wide visibility conveyed nothing. Every `pub(crate)` that survives has at least one reader in another module of the same crate. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/installer/binary_installer.rs | 20 ++++++++++---------- crates/shirabe/src/installer/library_installer.rs | 23 +++++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'crates/shirabe/src/installer') diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index 8cd4fe5a..32e4c071 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -47,10 +47,10 @@ impl BinaryInstallerInterface for BinaryInstaller { /// Utility to handle installation of package "bin"/binaries #[derive(Debug)] pub struct BinaryInstaller { - pub(crate) bin_dir: String, - pub(crate) bin_compat: String, - pub(crate) io: std::rc::Rc>, - pub(crate) filesystem: std::rc::Rc>, + bin_dir: String, + bin_compat: String, + io: std::rc::Rc>, + filesystem: std::rc::Rc>, vendor_dir: Option, } @@ -219,11 +219,11 @@ impl BinaryInstaller { "php".to_string() } - pub(crate) fn get_binaries(&self, package: PackageInterfaceHandle) -> Vec { + fn get_binaries(&self, package: PackageInterfaceHandle) -> Vec { package.get_binaries() } - pub(crate) fn install_full_binaries( + fn install_full_binaries( &mut self, bin_path: &str, link: &str, @@ -258,7 +258,7 @@ impl BinaryInstaller { } } - pub(crate) fn install_unixy_proxy_binaries(&self, bin_path: &str, link: &str) { + fn install_unixy_proxy_binaries(&self, bin_path: &str, link: &str) { let code = self.generate_unixy_proxy_code(bin_path, link); file_put_contents(link, code.as_bytes()); let link_owned = link.to_string(); @@ -268,14 +268,14 @@ impl BinaryInstaller { }); } - pub(crate) fn initialize_bin_dir(&mut self) { + fn initialize_bin_dir(&mut self) { self.filesystem .borrow_mut() .ensure_directory_exists(&self.bin_dir); self.bin_dir = realpath(&self.bin_dir).unwrap_or_default(); } - pub(crate) fn generate_windows_proxy_code(&self, bin: &str, link: &str) -> String { + fn generate_windows_proxy_code(&self, bin: &str, link: &str) -> String { let bin_path = self .filesystem .borrow_mut() @@ -311,7 +311,7 @@ impl BinaryInstaller { ) } - pub(crate) fn generate_unixy_proxy_code(&self, bin: &str, link: &str) -> String { + fn generate_unixy_proxy_code(&self, bin: &str, link: &str) -> String { let bin_path = self .filesystem .borrow_mut() diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index cab1e206..5f3b2054 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -24,13 +24,12 @@ pub struct LibraryInstaller { pub(crate) composer: PartialComposerWeakHandle, /// Behind a RefCell so initialize_vendor_dir can canonicalize it through `&self` (the /// installer instance is shared between concurrent package operations). - pub(crate) vendor_dir: std::cell::RefCell, - pub(crate) download_manager: - Option>>, + vendor_dir: std::cell::RefCell, + download_manager: Option>>, pub(crate) io: std::rc::Rc>, - pub(crate) r#type: Option, - pub(crate) filesystem: std::rc::Rc>, - pub(crate) binary_installer: std::rc::Rc>, + r#type: Option, + filesystem: std::rc::Rc>, + binary_installer: std::rc::Rc>, } impl LibraryInstaller { @@ -121,7 +120,7 @@ impl LibraryInstaller { /// /// It is used for BC as getInstallPath tends to be overridden by /// installer plugins but not getPackageBasePath - pub(crate) fn get_package_base_path(&self, package: PackageInterfaceHandle) -> String { + fn get_package_base_path(&self, package: PackageInterfaceHandle) -> String { let install_path = self.get_install_path(package.clone()).unwrap(); let target_dir = package.get_target_dir(); @@ -142,7 +141,7 @@ impl LibraryInstaller { install_path } - pub(crate) async fn install_code( + async fn install_code( &self, package: PackageInterfaceHandle, ) -> anyhow::Result> { @@ -154,7 +153,7 @@ impl LibraryInstaller { .await } - pub(crate) async fn update_code( + async fn update_code( &self, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, @@ -183,7 +182,7 @@ impl LibraryInstaller { .await } - pub(crate) async fn remove_code( + async fn remove_code( &self, package: PackageInterfaceHandle, ) -> anyhow::Result> { @@ -195,7 +194,7 @@ impl LibraryInstaller { .await } - pub(crate) fn initialize_vendor_dir(&self) { + fn initialize_vendor_dir(&self) { self.filesystem .borrow_mut() .ensure_directory_exists(&self.vendor_dir.borrow()); @@ -203,7 +202,7 @@ impl LibraryInstaller { *self.vendor_dir.borrow_mut() = realpath; } - pub(crate) fn get_download_manager( + fn get_download_manager( &self, ) -> &std::rc::Rc> { // PHP: assert($this->downloadManager instanceof DownloadManager, new \LogicException(...)) -- cgit v1.3.1-4-g156e