Skip to content

Commit fe5ef09

Browse files
committed
feat(hal/digest): add Display implementation for digest ErrorKind
- Implement core::fmt::Display for digest::ErrorKind enum - Provide user-friendly error messages for digest operation errors - Follow Rust conventions for error type Display formatting - Enable better digest error reporting and library integration Digest error messages are lowercase, human-readable descriptions suitable for user-facing digest operation error reporting while maintaining technical accuracy for cryptographic operations.
1 parent 5ee18ed commit fe5ef09

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

hal/blocking/src/digest.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,24 @@ pub enum ErrorKind {
444444
NotInitialized,
445445
}
446446

447+
impl core::fmt::Display for ErrorKind {
448+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
449+
match self {
450+
Self::InvalidInputLength => write!(f, "invalid input data length"),
451+
Self::UnsupportedAlgorithm => write!(f, "unsupported hash algorithm"),
452+
Self::MemoryAllocationFailure => write!(f, "memory allocation failed"),
453+
Self::InitializationError => write!(f, "failed to initialize hash computation"),
454+
Self::UpdateError => write!(f, "error updating hash computation"),
455+
Self::FinalizationError => write!(f, "error finalizing hash computation"),
456+
Self::Busy => write!(f, "hardware accelerator is busy"),
457+
Self::HardwareFailure => write!(f, "hardware failure during hash computation"),
458+
Self::InvalidOutputSize => write!(f, "invalid output size for hash function"),
459+
Self::PermissionDenied => write!(f, "insufficient permissions to access hardware"),
460+
Self::NotInitialized => write!(f, "hash computation context not initialized"),
461+
}
462+
}
463+
}
464+
447465
/// Trait for digest operation errors.
448466
///
449467
/// This trait provides a common interface for all error types that can occur

0 commit comments

Comments
 (0)