mop_common/
solver.rs

1use alloc::boxed::Box;
2use core::{future::Future, pin::Pin};
3
4#[cfg(not(feature = "with-futures"))]
5pub type SolverFuture<'a, E> = Pin<Box<dyn Future<Output = Result<(), E>> + 'a>>;
6
7#[cfg(feature = "with-futures")]
8pub type SolverFuture<'a, E> = Pin<Box<dyn Future<Output = Result<(), E>> + Send + Sync + 'a>>;
9
10pub trait Solver<P> {
11  type Error;
12
13  /// Do solving work after stoping criteria verification.
14  fn after_iter<'a>(&'a mut self, p: &'a mut P) -> SolverFuture<'a, Self::Error>;
15
16  /// Do solving work before stoping criteria verification.
17  fn before_iter<'a>(&'a mut self, p: &'a mut P) -> SolverFuture<'a, Self::Error>;
18
19  fn finished(&mut self, _: &mut P) {}
20
21  fn init(&mut self, _: &mut P) {}
22}