// SPDX-FileCopyrightText: 2024 Topola contributors // // SPDX-License-Identifier: MIT use core::ops::ControlFlow; use thiserror::Error; use crate::{ autorouter::invoker::{GetDebugOverlayData, Invoker}, board::AccessMesadata, stepper::{Abort, OnEvent, Step}, }; use super::{ activity::{ActivityContext, InteractiveEvent}, route_plan::RoutePlan, }; #[derive(Error, Debug, Clone)] pub enum InteractionError { #[error("nothing to interact with")] NothingToInteract, } pub enum InteractionStepper { // Examples of interactions: // - interactively routing a track // - interactively moving a footprint. RoutePlan(RoutePlan), } impl Step, String> for InteractionStepper { type Error = InteractionError; fn step( &mut self, context: &mut ActivityContext, ) -> Result, InteractionError> { match self { Self::RoutePlan(rp) => rp.step(context), } } } impl Abort> for InteractionStepper { fn abort(&mut self, context: &mut Invoker) { match self { Self::RoutePlan(rp) => rp.abort(context), } } } impl OnEvent, InteractiveEvent> for InteractionStepper { type Output = Result<(), InteractionError>; fn on_event( &mut self, context: &mut ActivityContext, event: InteractiveEvent, ) -> Result<(), InteractionError> { match self { Self::RoutePlan(rp) => rp.on_event(context, event), } } } impl GetDebugOverlayData for InteractionStepper {}