pub enum Error {
EntropySourceUnavailable {
source: &'static str,
context: Option<&'static str>,
},
InsufficientEntropy {
required: usize,
available: usize,
quality: f64,
},
EntropyValidationFailed {
reason: &'static str,
quality: f64,
details: Option<&'static str>,
},
HardwareRngFailed {
device: &'static str,
status: Option<u32>,
details: Option<&'static str>,
},
PlatformRngFailed {
platform: &'static str,
code: Option<i32>,
details: Option<&'static str>,
},
InvalidConfiguration {
parameter: &'static str,
expected: String,
actual: String,
},
MemoryAllocationFailed {
size: usize,
context: Option<&'static str>,
},
ThreadSafetyViolation {
violation: &'static str,
context: Option<&'static str>,
},
CryptographicFailure {
operation: &'static str,
code: Option<u32>,
details: Option<&'static str>,
},
TestVectorValidationFailed {
vector_id: &'static str,
expected: String,
actual: String,
},
FeatureNotAvailable {
feature: &'static str,
required_features: &'static [&'static str],
},
InternalError {
component: &'static str,
message: &'static str,
},
}Expand description
Comprehensive error types for RNG operations
This enum provides detailed error information for various failure modes in random number generation, enabling proper error handling and recovery.
Variants§
Entropy source is not available or failed
InsufficientEntropy
Insufficient entropy for cryptographic operations
Fields
EntropyValidationFailed
Entropy validation failed
Fields
HardwareRngFailed
Hardware RNG failure
Fields
PlatformRngFailed
Platform-specific RNG failure
Fields
InvalidConfiguration
Invalid configuration or parameters
Fields
MemoryAllocationFailed
Memory allocation failure
ThreadSafetyViolation
Thread safety violation
Fields
CryptographicFailure
Cryptographic operation failed
Fields
TestVectorValidationFailed
Test vector validation failed
Fields
FeatureNotAvailable
Feature not available
Fields
InternalError
Internal implementation error
Implementations§
Source§impl Error
impl Error
Create a new entropy source unavailable error
Create a new entropy source unavailable error with context
Sourcepub fn insufficient_entropy(
required: usize,
available: usize,
quality: f64,
) -> Self
pub fn insufficient_entropy( required: usize, available: usize, quality: f64, ) -> Self
Create a new insufficient entropy error
Sourcepub fn entropy_validation_failed(reason: &'static str, quality: f64) -> Self
pub fn entropy_validation_failed(reason: &'static str, quality: f64) -> Self
Create a new entropy validation failed error
Sourcepub fn entropy_validation_failed_with_details(
reason: &'static str,
quality: f64,
details: &'static str,
) -> Self
pub fn entropy_validation_failed_with_details( reason: &'static str, quality: f64, details: &'static str, ) -> Self
Create a new entropy validation failed error with details
Sourcepub fn hardware_rng_failed(device: &'static str) -> Self
pub fn hardware_rng_failed(device: &'static str) -> Self
Create a new hardware RNG failed error
Sourcepub fn hardware_rng_failed_with_status(
device: &'static str,
status: u32,
details: &'static str,
) -> Self
pub fn hardware_rng_failed_with_status( device: &'static str, status: u32, details: &'static str, ) -> Self
Create a new hardware RNG failed error with status
Sourcepub fn platform_rng_failed(platform: &'static str) -> Self
pub fn platform_rng_failed(platform: &'static str) -> Self
Create a new platform RNG failed error
Sourcepub fn platform_rng_failed_with_code(
platform: &'static str,
code: i32,
details: &'static str,
) -> Self
pub fn platform_rng_failed_with_code( platform: &'static str, code: i32, details: &'static str, ) -> Self
Create a new platform RNG failed error with code
Sourcepub fn invalid_configuration(
parameter: &'static str,
expected: &'static str,
actual: &'static str,
) -> Self
pub fn invalid_configuration( parameter: &'static str, expected: &'static str, actual: &'static str, ) -> Self
Create a new invalid configuration error
Sourcepub fn memory_allocation_failed(size: usize) -> Self
pub fn memory_allocation_failed(size: usize) -> Self
Create a new memory allocation failed error
Sourcepub fn memory_allocation_failed_with_context(
size: usize,
context: &'static str,
) -> Self
pub fn memory_allocation_failed_with_context( size: usize, context: &'static str, ) -> Self
Create a new memory allocation failed error with context
Sourcepub fn thread_safety_violation(violation: &'static str) -> Self
pub fn thread_safety_violation(violation: &'static str) -> Self
Create a new thread safety violation error
Sourcepub fn thread_safety_violation_with_context(
violation: &'static str,
context: &'static str,
) -> Self
pub fn thread_safety_violation_with_context( violation: &'static str, context: &'static str, ) -> Self
Create a new thread safety violation error with context
Sourcepub fn cryptographic_failure(operation: &'static str) -> Self
pub fn cryptographic_failure(operation: &'static str) -> Self
Create a new cryptographic failure error
Sourcepub fn cryptographic_failure_with_code(
operation: &'static str,
code: u32,
details: &'static str,
) -> Self
pub fn cryptographic_failure_with_code( operation: &'static str, code: u32, details: &'static str, ) -> Self
Create a new cryptographic failure error with code
Sourcepub fn test_vector_validation_failed(
vector_id: &'static str,
expected: &'static str,
actual: &'static str,
) -> Self
pub fn test_vector_validation_failed( vector_id: &'static str, expected: &'static str, actual: &'static str, ) -> Self
Create a new test vector validation failed error
Sourcepub fn feature_not_available(
feature: &'static str,
required_features: &'static [&'static str],
) -> Self
pub fn feature_not_available( feature: &'static str, required_features: &'static [&'static str], ) -> Self
Create a new feature not available error
Sourcepub fn internal_error(component: &'static str, message: &'static str) -> Self
pub fn internal_error(component: &'static str, message: &'static str) -> Self
Create a new internal error
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable
Check if this error indicates insufficient entropy
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Get a human-readable error description
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()