conjure_core/solver/
states.rs

1//! States of a [`Solver`].
2use std::fmt::Display;
3
4use crate::stats::SolverStats;
5
6use super::private::Internal;
7use super::private::Sealed;
8use super::SearchStatus;
9use super::Solver;
10use super::SolverError;
11
12pub trait SolverState: Sealed {}
13
14impl Sealed for Init {}
15impl Sealed for ModelLoaded {}
16impl Sealed for ExecutionSuccess {}
17impl Sealed for ExecutionFailure {}
18
19impl SolverState for Init {}
20impl SolverState for ModelLoaded {}
21impl SolverState for ExecutionSuccess {}
22impl SolverState for ExecutionFailure {}
23
24pub struct Init;
25pub struct ModelLoaded;
26
27/// The state returned by [`Solver`] if solving has been successful.
28pub struct ExecutionSuccess {
29    /// Execution statistics.
30    pub stats: SolverStats,
31
32    /// The status of the search
33    pub status: SearchStatus,
34
35    /// Cannot construct this from outside this module.
36    pub _sealed: Internal,
37}
38
39/// The state returned by [`Solver`] if solving has not been successful.
40pub struct ExecutionFailure {
41    pub why: SolverError,
42
43    /// Cannot construct this from outside this module.
44    pub _sealed: Internal,
45}