conjure_core/solver/
states.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! States of a [`Solver`].
use std::fmt::Display;

use crate::stats::SolverStats;

use super::private::Internal;
use super::private::Sealed;
use super::SearchStatus;
use super::Solver;
use super::SolverError;

pub trait SolverState: Sealed {}

impl Sealed for Init {}
impl Sealed for ModelLoaded {}
impl Sealed for ExecutionSuccess {}
impl Sealed for ExecutionFailure {}

impl SolverState for Init {}
impl SolverState for ModelLoaded {}
impl SolverState for ExecutionSuccess {}
impl SolverState for ExecutionFailure {}

pub struct Init;
pub struct ModelLoaded;

/// The state returned by [`Solver`] if solving has been successful.
pub struct ExecutionSuccess {
    /// Execution statistics.
    pub stats: SolverStats,

    /// The status of the search
    pub status: SearchStatus,

    /// Cannot construct this from outside this module.
    pub _sealed: Internal,
}

/// The state returned by [`Solver`] if solving has not been successful.
pub struct ExecutionFailure {
    pub why: SolverError,

    /// Cannot construct this from outside this module.
    pub _sealed: Internal,
}