solverforge_solver/scope/solver/
progress.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum SolverProgressKind {
3 Progress,
4 BestSolution,
5}
6
7#[derive(Debug, Clone, Copy)]
8pub struct SolverProgressRef<'a, S: PlanningSolution> {
9 pub kind: SolverProgressKind,
10 pub status: SolverLifecycleState,
11 pub solution: Option<&'a S>,
12 pub current_score: Option<&'a S::Score>,
13 pub best_score: Option<&'a S::Score>,
14 pub telemetry: crate::stats::SolverTelemetry,
15}
16
17pub trait ProgressCallback<S: PlanningSolution>: Send + Sync {
18 fn invoke(&self, progress: SolverProgressRef<'_, S>);
19}
20
21impl<S: PlanningSolution> ProgressCallback<S> for () {
22 fn invoke(&self, _progress: SolverProgressRef<'_, S>) {}
23}
24
25impl<S, F> ProgressCallback<S> for F
26where
27 S: PlanningSolution,
28 F: for<'a> Fn(SolverProgressRef<'a, S>) + Send + Sync,
29{
30 fn invoke(&self, progress: SolverProgressRef<'_, S>) {
31 self(progress);
32 }
33}
34