lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

capability.rs (2262B)


      1 use core::fmt;
      2 
      3 /// Path-free failures from actual owner backup operations. These are distinct
      4 /// from the optimistic metadata-transition errors of reliability records.
      5 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
      6 #[non_exhaustive]
      7 pub enum BackupCapabilityError {
      8     /// This backend provides no actual snapshot capability.
      9     Unsupported,
     10     /// The owner is closed or its storage is unavailable.
     11     Unavailable,
     12     /// An explicit valid host-owned backup location is required.
     13     InvalidConfiguration,
     14     /// The requested backup format is not supported by the owner.
     15     UnsupportedVersion,
     16     /// Existing staged or finalized state requires reconciliation.
     17     Conflict,
     18     /// The supplied plan, inventory or member bytes could not be verified.
     19     VerificationFailed,
     20     /// Capture or durable filesystem publication did not complete successfully.
     21     Failed,
     22 }
     23 
     24 impl fmt::Display for BackupCapabilityError {
     25     fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
     26         formatter.write_str(match self {
     27             Self::Unsupported => "storage backup capability is unsupported",
     28             Self::Unavailable => "storage backup owner is unavailable",
     29             Self::InvalidConfiguration => "storage backup configuration is invalid",
     30             Self::UnsupportedVersion => "storage backup format is unsupported",
     31             Self::Conflict => "storage backup state requires reconciliation",
     32             Self::VerificationFailed => "storage backup verification failed",
     33             Self::Failed => "storage backup did not complete",
     34         })
     35     }
     36 }
     37 
     38 impl std::error::Error for BackupCapabilityError {}
     39 
     40 #[cfg(test)]
     41 mod tests {
     42     use super::BackupCapabilityError as E;
     43 
     44     #[test]
     45     fn errors_are_bounded_public_reports_without_paths_or_backend_sources() {
     46         for error in [
     47             E::Unsupported,
     48             E::Unavailable,
     49             E::InvalidConfiguration,
     50             E::UnsupportedVersion,
     51             E::Conflict,
     52             E::VerificationFailed,
     53             E::Failed,
     54         ] {
     55             let report = error.to_string();
     56             assert!(report.len() < 80);
     57             assert!(!report.contains('/'));
     58             assert!(std::error::Error::source(&error).is_none());
     59         }
     60     }
     61 }