From 4f40c26bac5a162744910691c3e9b1ae58babdff Mon Sep 17 00:00:00 2001 From: Alain Emilia Anna Zscheile Date: Fri, 4 Oct 2024 23:49:54 +0200 Subject: [PATCH] chore(autorouter): let ExecutionStepper::step_catch_err take Autorouter as context --- src/autorouter/execution.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/autorouter/execution.rs b/src/autorouter/execution.rs index 25fa306..628986a 100644 --- a/src/autorouter/execution.rs +++ b/src/autorouter/execution.rs @@ -11,7 +11,7 @@ use super::{ place_via::PlaceViaExecutionStepper, remove_bands::RemoveBandsExecutionStepper, selection::{BandSelection, PinSelection}, - AutorouterOptions, + Autorouter, AutorouterOptions, }; type Type = PinSelection; @@ -37,28 +37,26 @@ pub enum ExecutionStepper { impl ExecutionStepper { fn step_catch_err( &mut self, - invoker: &mut Invoker, + autorouter: &mut Autorouter, ) -> Result { Ok(match self { - ExecutionStepper::Autoroute(autoroute) => { - match autoroute.step(&mut invoker.autorouter)? { - AutorouteStatus::Running => InvokerStatus::Running, - AutorouteStatus::Routed(..) => InvokerStatus::Running, - AutorouteStatus::Finished => { - InvokerStatus::Finished("finished autorouting".to_string()) - } + ExecutionStepper::Autoroute(autoroute) => match autoroute.step(autorouter)? { + AutorouteStatus::Running => InvokerStatus::Running, + AutorouteStatus::Routed(..) => InvokerStatus::Running, + AutorouteStatus::Finished => { + InvokerStatus::Finished("finished autorouting".to_string()) } - } + }, ExecutionStepper::PlaceVia(place_via) => { - place_via.doit(&mut invoker.autorouter)?; + place_via.doit(autorouter)?; InvokerStatus::Finished("finished placing via".to_string()) } ExecutionStepper::RemoveBands(remove_bands) => { - remove_bands.doit(&mut invoker.autorouter)?; + remove_bands.doit(autorouter)?; InvokerStatus::Finished("finished removing bands".to_string()) } ExecutionStepper::CompareDetours(compare_detours) => { - match compare_detours.step(&mut invoker.autorouter)? { + match compare_detours.step(autorouter)? { CompareDetoursStatus::Running => InvokerStatus::Running, CompareDetoursStatus::Finished(total_length1, total_length2) => { InvokerStatus::Finished(format!( @@ -69,7 +67,7 @@ impl ExecutionStepper { } } ExecutionStepper::MeasureLength(measure_length) => { - let length = measure_length.doit(&mut invoker.autorouter)?; + let length = measure_length.doit(autorouter)?; InvokerStatus::Finished(format!("Total length of selected bands: {}", length)) } }) @@ -78,7 +76,7 @@ impl ExecutionStepper { impl Step, InvokerStatus, InvokerError, ()> for ExecutionStepper { fn step(&mut self, invoker: &mut Invoker) -> Result { - match self.step_catch_err(invoker) { + match self.step_catch_err(&mut invoker.autorouter) { Ok(InvokerStatus::Running) => Ok(InvokerStatus::Running), Ok(InvokerStatus::Finished(msg)) => { if let Some(command) = invoker.ongoing_command.take() {