trellis_runner/state/
status.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
//! Module for abstractions about the state of a solver, and reasons why a solver may have
//! terminated.

use serde::{Deserialize, Serialize};

/// The status of the solver
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub enum Status {
    /// A solver can either be [`NotTerminated`]
    NotTerminated,
    /// Or the solver can be terminated for [`Cause`]
    Terminated(Cause),
}

impl Default for Status {
    fn default() -> Self {
        Self::NotTerminated
    }
}

/// Causes for termination of a solver
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum Cause {
    /// The caller has manually terminated the process with ctrl-C
    ControlC,
    /// A parent thread had terminated the process using a [`tokio::CancellationToken`]
    Parent,
    /// The solver has converged to the requested tolerance
    Converged,
    /// The solver has exceeded the maximum allowable iterations
    ExceededMaxIterations,
}