From 06e8e14520a4a38fed500581d2b75a42418b22c4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 4 Jun 2026 21:09:02 +0900 Subject: feat(package): implement PackageInterface accessor layer for Package/CompletePackage/RootPackage Fill the trait-impl todo!() across the package accessor layer so loaded packages are actually usable (the ArrayLoader::load path depends on it): - Package: implement BasePackage/PackageInterface from struct fields and existing inherent methods; Display via get_unique_name. - CompletePackage: delegate PackageInterface to inner Package. - RootPackage: delegate CompletePackageInterface/PackageInterface to inner CompletePackage; RootPackageInterface link setters delegate to Package. Correct three unfaithful trait signatures found during implementation: - get_target_dir returns Option (PHP computes a normalized value; a borrow cannot represent it, and AliasPackage could not implement &str across its aliasOf handle). - RootPackageInterface link setters take IndexMap, matching Package and the real ArrayLoader caller (PHP RootPackage inherits Package::setRequires; the Link[] docblock was imprecise). - get_full_pretty_version takes a DisplayMode enum instead of a raw i64; the match is now exhaustive, so it returns String without an error path. Move mirror conversion to the boundaries: PackageInterface mirror methods use Vec (the typed form, matching the inherent methods), with array<->Mirror conversion done by the producer (ComposerRepository) and consumer (ArrayDumper). Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/installer.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/installer.rs') diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index ec374ac..efc41c1 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -736,7 +736,10 @@ impl Installer { install_names.push(format!( "{}:{}", io.get_package().get_pretty_name(), - io.get_package().get_full_pretty_version(true, 0) + io.get_package().get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev + ) )); } else if let Some(uo) = operation.as_update_operation() { // when mirrors/metadata from a package gets updated we do not want to list it as an @@ -753,7 +756,10 @@ impl Installer { update_names.push(format!( "{}:{}", uo.get_target_package().get_pretty_name(), - uo.get_target_package().get_full_pretty_version(true, 0) + uo.get_target_package().get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev + ) )); } else if let Some(uo) = operation.as_uninstall_operation() { uninstalls.push(operation.clone_box()); @@ -1137,13 +1143,15 @@ impl Installer { installs.push(format!( "{}:{}", io.get_package().get_pretty_name(), - io.get_package().get_full_pretty_version(true, 0) + io.get_package() + .get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) )); } else if let Some(uo) = operation.as_update_operation() { updates.push(format!( "{}:{}", uo.get_target_package().get_pretty_name(), - uo.get_target_package().get_full_pretty_version(true, 0) + uo.get_target_package() + .get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) )); } else if let Some(uo) = operation.as_uninstall_operation() { uninstalls.push(uo.get_package().get_pretty_name().to_string()); @@ -1336,8 +1344,8 @@ impl Installer { } self.fixed_root_package = RootPackageInterfaceHandle::dup(&self.package); - self.fixed_root_package.set_requires(vec![]); - self.fixed_root_package.set_dev_requires(vec![]); + self.fixed_root_package.set_requires(IndexMap::new()); + self.fixed_root_package.set_dev_requires(IndexMap::new()); stability_flags.insert( self.package.get_name(), -- cgit v1.3.1