batch_mode_batch_triple/
batch_file_state.rs

1// ---------------- [ File: src/batch_file_state.rs ]
2crate::ix!();
3
4/// Represents the state of batch files based on the presence of input, output, and error files.
5#[derive(Debug, PartialEq, Eq)]
6pub enum BatchFileState {
7    InputOnly,           // Only input file is present.
8    InputOutput,         // Input and output files are present.
9    InputError,          // Input and error files are present.
10    InputOutputError,    // All three files are present.
11}
12
13impl From<&BatchFileTriple> for BatchFileState {
14
15    /// Determines the state of the batch files.
16    fn from(triple: &BatchFileTriple) -> BatchFileState {
17
18        let has_input  = triple.input().is_some();
19        let has_error  = triple.error().is_some();
20        let has_output = triple.output().is_some();
21
22        match (has_input, has_output, has_error) {
23            (true, true, true)   => BatchFileState::InputOutputError,
24            (true, true, false)  => BatchFileState::InputOutput,
25            (true, false, true)  => BatchFileState::InputError,
26            (true, false, false) => BatchFileState::InputOnly,
27            _ => unreachable!("Input file must be present at this point"),
28        }
29    }
30}