@@ -11,20 +11,23 @@ use rand_core::Error;
11
11
use core:: fmt;
12
12
13
13
/// An error that can occur when [`JitterRng::test_timer`] fails.
14
+ ///
15
+ /// All variants have a value of 0x6e530400 = 1850934272 plus a small
16
+ /// increment (1 through 5).
14
17
///
15
18
/// [`JitterRng::test_timer`]: crate::JitterRng::test_timer
16
19
#[ derive( Debug , Clone , PartialEq , Eq ) ]
17
20
pub enum TimerError {
18
21
/// No timer available.
19
- NoTimer ,
22
+ NoTimer = 0x6e530401 ,
20
23
/// Timer too coarse to use as an entropy source.
21
- CoarseTimer ,
24
+ CoarseTimer = 0x6e530402 ,
22
25
/// Timer is not monotonically increasing.
23
- NotMonotonic ,
26
+ NotMonotonic = 0x6e530403 ,
24
27
/// Variations of deltas of time too small.
25
- TinyVariantions ,
28
+ TinyVariantions = 0x6e530404 ,
26
29
/// Too many stuck results (indicating no added entropy).
27
- TooManyStuck ,
30
+ TooManyStuck = 0x6e530405 ,
28
31
#[ doc( hidden) ]
29
32
__Nonexhaustive,
30
33
}
@@ -60,11 +63,10 @@ impl From<TimerError> for Error {
60
63
// Timer check is already quite permissive of failures so we don't
61
64
// expect false-positive failures, i.e. any error is irrecoverable.
62
65
#[ cfg( feature = "std" ) ] {
63
- Error :: with_cause ( "timer jitter failed basic quality tests" , err)
66
+ Error :: new ( err)
64
67
}
65
68
#[ cfg( not( feature = "std" ) ) ] {
66
- let _ = err;
67
- Error :: new ( "timer jitter failed basic quality tests" )
69
+ Error :: from ( core:: num:: NonZeroU32 :: new ( err as u32 ) . unwrap ( ) )
68
70
}
69
71
}
70
72
}
0 commit comments