failure.rs (2720B)
1 //! Bounded command failure diagnostics separate from compact resource errors. 2 use crate::{Code, Detail, Error, OperationContext, RetryClass}; 3 use core::fmt; 4 use radroots_signing::issuance::RejectedArtifact; 5 6 /// Allocation-free command failure. The primitive Error retains its 64-byte 7 /// contract; this separate Copy value can also retain fixed rejection metadata. 8 /// It owns no untrusted raw signer payload, dynamic message or backend cause. 9 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 10 pub struct ExecutionFailure { 11 error: Error, 12 rejection: Option<RejectedArtifact>, 13 } 14 const _: () = assert!(core::mem::size_of::<ExecutionFailure>() <= 128); 15 impl From<Error> for ExecutionFailure { 16 fn from(error: Error) -> Self { 17 Self { 18 error, 19 rejection: None, 20 } 21 } 22 } 23 impl ExecutionFailure { 24 /// Primitive compact diagnostic; it supplies no business/nonissuance proof. 25 pub const fn error(self) -> Error { 26 self.error 27 } 28 /// Original fixed diagnostic code, including actual storage failures. 29 pub const fn code(self) -> Code { 30 self.error.code() 31 } 32 /// Original reported operation identity and admission observation. 33 pub const fn context(self) -> OperationContext { 34 self.error.context() 35 } 36 /// Conservative original-operation continuation requirement. 37 pub const fn retry(self) -> RetryClass { 38 self.error.retry() 39 } 40 /// Optional fixed redacted diagnostic categories. 41 pub const fn detail(self) -> Option<Detail> { 42 self.error.detail() 43 } 44 /// Actual fixed signer rejection and optional exact fingerprint coverage. 45 /// This is caller diagnostic data, never authenticated business evidence. 46 pub const fn signer_rejection(self) -> Option<RejectedArtifact> { 47 self.rejection 48 } 49 #[cfg(feature = "workspace_session")] 50 pub(crate) const fn rejected( 51 operation: radroots_domain::OperationId, 52 rejection: RejectedArtifact, 53 ) -> Self { 54 Self { 55 error: Error::signer_tampering(operation), 56 rejection: Some(rejection), 57 } 58 } 59 #[cfg(feature = "workspace_session")] 60 pub(crate) fn host_after_rejection( 61 error: radroots_storage::command::OperationError, 62 operation: radroots_domain::OperationId, 63 rejection: RejectedArtifact, 64 ) -> Self { 65 Self { 66 error: Error::capture_pending(error, OperationContext::retained(operation)), 67 rejection: Some(rejection), 68 } 69 } 70 } 71 impl fmt::Display for ExecutionFailure { 72 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 73 self.error.fmt(f) 74 } 75 } 76 impl core::error::Error for ExecutionFailure {}