signstar_configure/result.rs
1//! The result of a Signstar host configuration operation.
2
3use std::process::{ExitCode, Termination};
4
5/// The possible result of a Signstar host configuration.
6///
7/// # Note
8///
9/// The variants of this enum are not considered run-time errors.
10#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
11pub enum ConfigurationResult {
12 /// The synchronization of the host's configuration with its system users and backends
13 /// succeeded.
14 SyncSucceeded,
15
16 /// There is no configuration section for a particular type of HSM backend.
17 MissingConfigurationForBackend,
18
19 /// There are no connections available for a particular type of HSM backend.
20 ///
21 /// # Note
22 ///
23 /// This may indicate a transient network issue, or USB hardware failure.
24 NoAvailableBackendConnection,
25
26 /// There are provisioned backends, but no administrative credentials.
27 ///
28 /// # Note
29 ///
30 /// This likely indicates, that a backup and administrative credentials need to be provided to
31 /// the system to restore from the backup.
32 ProvisionedBackendsButNoAdminCreds,
33
34 /// Not all connections of a particular type of HSM backend are present and there are no
35 /// administrative credentials.
36 ///
37 /// # Note
38 ///
39 /// This may indicate a transient network issue, or USB hardware failure.
40 /// Only with all configured connections available, the system can consider creating (new)
41 /// administrative credentials.
42 NotAllConnectionsAvailableAndNoAdminCreds,
43}
44
45impl Termination for ConfigurationResult {
46 fn report(self) -> ExitCode {
47 match self {
48 Self::SyncSucceeded => ExitCode::SUCCESS,
49 Self::MissingConfigurationForBackend => ExitCode::from(100),
50 Self::NoAvailableBackendConnection => ExitCode::from(101),
51 Self::ProvisionedBackendsButNoAdminCreds => ExitCode::from(102),
52 Self::NotAllConnectionsAvailableAndNoAdminCreds => ExitCode::from(103),
53 }
54 }
55}