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/package/root_alias_package.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/package/root_alias_package.rs') diff --git a/crates/shirabe/src/package/root_alias_package.rs b/crates/shirabe/src/package/root_alias_package.rs index 67e123b..de4733a 100644 --- a/crates/shirabe/src/package/root_alias_package.rs +++ b/crates/shirabe/src/package/root_alias_package.rs @@ -82,11 +82,11 @@ impl RootPackageInterface for RootAliasPackage { todo!("RootAliasPackage::get_config cannot return a borrow across the aliasOf handle") } - fn set_requires(&mut self, requires: Vec) { - let replaced = self - .inner - .inner - .replace_self_version_dependencies(requires.clone(), Link::TYPE_REQUIRE); + fn set_requires(&mut self, requires: IndexMap) { + let replaced = self.inner.inner.replace_self_version_dependencies( + requires.values().cloned().collect(), + Link::TYPE_REQUIRE, + ); self.inner.inner.requires = replaced .into_iter() .map(|l| (l.get_target().to_string(), l)) @@ -94,19 +94,19 @@ impl RootPackageInterface for RootAliasPackage { self.alias_of.set_requires(requires); } - fn set_dev_requires(&mut self, dev_requires: Vec) { + fn set_dev_requires(&mut self, dev_requires: IndexMap) { self.alias_of.set_dev_requires(dev_requires); } - fn set_conflicts(&mut self, conflicts: Vec) { + fn set_conflicts(&mut self, conflicts: IndexMap) { self.alias_of.set_conflicts(conflicts); } - fn set_provides(&mut self, provides: Vec) { + fn set_provides(&mut self, provides: IndexMap) { self.alias_of.set_provides(provides); } - fn set_replaces(&mut self, replaces: Vec) { + fn set_replaces(&mut self, replaces: IndexMap) { self.alias_of.set_replaces(replaces); } -- cgit v1.3.1