diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-07 14:15:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-07 14:15:55 +0900 |
| commit | da6f05c12d08ac96b4286664cd8205d3fee042d8 (patch) | |
| tree | 7fb50447d73d04544edb224346604f294b450f95 /crates/shirabe/src/factory.rs | |
| parent | 86961b16b2f5c9c26a776193934d13ff87ab7fea (diff) | |
| download | php-shirabe-da6f05c12d08ac96b4286664cd8205d3fee042d8.tar.gz php-shirabe-da6f05c12d08ac96b4286664cd8205d3fee042d8.tar.zst php-shirabe-da6f05c12d08ac96b4286664cd8205d3fee042d8.zip | |
feat(phase-c): resolve owned-argument phase-b TODOs
Replace value-by-value signature workarounds with proper ownership:
- validate_json_schema: borrow JsonFile via ValidateJsonInput<&JsonFile>,
restoring the dropped local auth file validation call
- Auditor::audit / Solver::new / create_pool: pass cloned Rc handles and
share Pool via Rc<RefCell<Pool>>; create_pool now takes &mut Request
- MarkAlias{Installed,Uninstalled}Operation: hand over AliasPackageHandle
from the alias-confirmed branch
- dispatch_installer_event: clone the base Transaction (Rc-backed
contents) and enable the PRE_OPERATIONS_EXEC dispatch
- SuggestedPackagesReporter: share between command and installer via
Rc<RefCell<>> to mirror PHP reference semantics
PrePoolCreateEvent remains a TODO: it is plugin-only and would require a
speculative Rc migration of Request whose payload is never read today.
Diffstat (limited to 'crates/shirabe/src/factory.rs')
| -rw-r--r-- | crates/shirabe/src/factory.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 95511b0..c099777 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -273,14 +273,9 @@ impl Factory { crate::io::DEBUG, ); } - // TODO(phase-b): validate_json_schema takes ownership of JsonFile; recreate it Self::validate_json_schema( io.clone(), - ValidateJsonInput::File(JsonFile::new( - global_config_path.clone(), - None, - io.clone(), - )?), + ValidateJsonInput::File(&file), JsonFile::LAX_SCHEMA, None, )?; @@ -337,10 +332,9 @@ impl Factory { crate::io::DEBUG, ); } - // TODO(phase-b): validate_json_schema takes ownership; recreate JsonFile Self::validate_json_schema( io.clone(), - ValidateJsonInput::File(JsonFile::new(auth_file_path.clone(), None, io.clone())?), + ValidateJsonInput::File(&auth_file), JsonFile::AUTH_SCHEMA, None, )?; @@ -554,9 +548,12 @@ impl Factory { true, crate::io::DEBUG, ); - // TODO(phase-b): validate_json_schema/ValidateJsonInput::File expects an owned - // JsonFile (PHP class semantics share refs); needs Rc<RefCell<JsonFile>> refactor. - let _ = &local_auth_file; + Self::validate_json_schema( + Some(io.clone()), + ValidateJsonInput::File(&local_auth_file), + JsonFile::AUTH_SCHEMA, + None, + )?; let auth_read = local_auth_file.read()?; let mut wrapped: IndexMap<String, PhpMixed> = IndexMap::new(); wrapped.insert("config".to_string(), auth_read); @@ -1475,7 +1472,7 @@ impl Factory { fn validate_json_schema( io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>, - file_or_data: ValidateJsonInput, + file_or_data: ValidateJsonInput<'_>, schema: i64, source: Option<&str>, ) -> anyhow::Result<()> { @@ -1484,7 +1481,7 @@ impl Factory { } let result = match file_or_data { - ValidateJsonInput::File(mut file) => file.validate_schema(schema, None), + ValidateJsonInput::File(file) => file.validate_schema(schema, None), ValidateJsonInput::Data(data) => { let source = source.ok_or_else(|| { anyhow::anyhow!(InvalidArgumentException { @@ -1522,7 +1519,7 @@ impl Factory { } } -enum ValidateJsonInput { - File(JsonFile), +enum ValidateJsonInput<'a> { + File(&'a JsonFile), Data(PhpMixed), } |
