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/alias_package.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'crates/shirabe/src/package/alias_package.rs') diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index b4ddc70..f4b9b55 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -8,6 +8,7 @@ use shirabe_semver::constraint::SimpleConstraint; use crate::package::BasePackage; use crate::package::Link; +use crate::package::Mirror; use crate::package::PackageHandle; use crate::package::PackageInterface; use crate::package::version::VersionParser; @@ -305,8 +306,8 @@ impl PackageInterface for AliasPackage { todo!("AliasPackage::get_type cannot return &str across the aliasOf handle") } - fn get_target_dir(&self) -> Option<&str> { - todo!("AliasPackage::get_target_dir cannot return &str across the aliasOf handle") + fn get_target_dir(&self) -> Option { + self.alias_of.get_target_dir() } fn get_extra(&self) -> IndexMap { @@ -341,11 +342,11 @@ impl PackageInterface for AliasPackage { self.alias_of.set_source_reference(reference); } - fn set_source_mirrors(&mut self, mirrors: Option>>) { + fn set_source_mirrors(&mut self, mirrors: Option>) { self.alias_of.set_source_mirrors(mirrors); } - fn get_source_mirrors(&self) -> Option>> { + fn get_source_mirrors(&self) -> Option> { self.alias_of.get_source_mirrors() } @@ -381,11 +382,11 @@ impl PackageInterface for AliasPackage { self.alias_of.get_transport_options() } - fn set_dist_mirrors(&mut self, mirrors: Option>>) { + fn set_dist_mirrors(&mut self, mirrors: Option>) { self.alias_of.set_dist_mirrors(mirrors); } - fn get_dist_mirrors(&self) -> Option>> { + fn get_dist_mirrors(&self) -> Option> { self.alias_of.get_dist_mirrors() } @@ -441,7 +442,11 @@ impl PackageInterface for AliasPackage { self.alias_of.set_source_dist_references(reference); } - fn get_full_pretty_version(&self, truncate: bool, display_mode: i64) -> String { + fn get_full_pretty_version( + &self, + truncate: bool, + display_mode: crate::package::DisplayMode, + ) -> String { self.alias_of .get_full_pretty_version(truncate, display_mode) } -- cgit v1.3.1