From 24c7f66b0494438b92e441f8a978a83b43b2f47e 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 | 47 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/autorouter/execution.rs b/src/autorouter/execution.rs index 6dd5d12..1e533a8 100644 --- a/src/autorouter/execution.rs +++ b/src/autorouter/execution.rs @@ -16,7 +16,7 @@ use super::{ place_via::PlaceViaExecutionStepper, remove_bands::RemoveBandsExecutionStepper, selection::{BandSelection, PinSelection}, - AutorouterOptions, + Autorouter, AutorouterOptions, }; type Type = PinSelection; @@ -42,26 +42,24 @@ pub enum ExecutionStepper { impl ExecutionStepper { fn step_catch_err( &mut self, - invoker: &mut Invoker, + autorouter: &mut Autorouter, ) -> Poll> { match self { - ExecutionStepper::Autoroute(autoroute) => { - match autoroute.step(&mut invoker.autorouter)? { - AutorouteStatus::Running => Poll::Pending, - AutorouteStatus::Routed(..) => Poll::Pending, - AutorouteStatus::Finished => Poll::Ready("finished autorouting".to_string()), - } - } + ExecutionStepper::Autoroute(autoroute) => match autoroute.step(autorouter)? { + AutorouteStatus::Running => Poll::Pending, + AutorouteStatus::Routed(..) => Poll::Pending, + AutorouteStatus::Finished => Poll::Ready("finished autorouting".to_string()), + }, ExecutionStepper::PlaceVia(place_via) => { - place_via.doit(&mut invoker.autorouter)?; + place_via.doit(autorouter)?; Poll::Ready("finished placing via".to_string()) } ExecutionStepper::RemoveBands(remove_bands) => { - remove_bands.doit(&mut invoker.autorouter)?; + remove_bands.doit(autorouter)?; Poll::Ready("finished removing bands".to_string()) } ExecutionStepper::CompareDetours(compare_detours) => { - match compare_detours.step(&mut invoker.autorouter)? { + match compare_detours.step(autorouter)? { CompareDetoursStatus::Running => Poll::Pending, CompareDetoursStatus::Finished(total_length1, total_length2) => { Poll::Ready(format!( @@ -72,7 +70,7 @@ impl ExecutionStepper { } } ExecutionStepper::MeasureLength(measure_length) => { - let length = measure_length.doit(&mut invoker.autorouter)?; + let length = measure_length.doit(autorouter)?; Poll::Ready(format!("Total length of selected bands: {}", length)) } } @@ -86,17 +84,18 @@ impl StepError for ExecutionStepper { impl PollStep, String> for ExecutionStepper { fn poll_step(&mut self, invoker: &mut Invoker) -> Poll> { - self.step_catch_err(invoker).map(|x| match x { - Ok(msg) => { - if let Some(command) = invoker.ongoing_command.take() { - invoker.history.do_(command); + self.step_catch_err(&mut invoker.autorouter) + .map(|x| match x { + Ok(msg) => { + if let Some(command) = invoker.ongoing_command.take() { + invoker.history.do_(command); + } + Ok(msg) } - Ok(msg) - } - Err(err) => { - invoker.ongoing_command = None; - Err(err) - } - }) + Err(err) => { + invoker.ongoing_command = None; + Err(err) + } + }) } }