1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::process::Termination;
4
5#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
6pub struct ExitCode(i32);
7
8impl ExitCode {
9 pub const SUCCESS: Self = Self(0);
10 pub const FAILURE: Self = Self(1);
11
12 pub fn value(&self) -> i32 {
13 self.0
14 }
15}
16
17impl From<i32> for ExitCode {
18 fn from(value: i32) -> Self {
19 Self(value)
20 }
21}
22
23impl From<ExitCode> for i32 {
24 fn from(value: ExitCode) -> Self {
25 value.0
26 }
27}
28
29impl Termination for ExitCode {
30 fn report(self) -> std::process::ExitCode {
31 std::process::ExitCode::from(self.0 as u8)
32 }
33}
34