pub enum EntropyError {
Unavailable {
reason: &'static str,
},
Failed {
reason: &'static str,
code: Option<i32>,
},
}Expand description
Why an EntropySource could not produce randomness.
Both variants are fatal for the operation that needed the bytes. Callers must fail that operation rather than fall back to a weaker source: minip2p uses entropy for key generation, Noise handshakes, and nonces, where a predictable substitute is a security bug.
Variants§
The platform has no entropy source at all.
Permanent — retrying will not help. Typically an embedded target built without a hardware RNG or a configured seed.
Failed
The entropy source exists but failed to produce bytes.
May be transient, for example a hardware RNG reporting a health-check failure or an exhausted file descriptor table.
Implementations§
Source§impl EntropyError
impl EntropyError
Creates an Unavailable error.
Sourcepub const fn failed(reason: &'static str) -> Self
pub const fn failed(reason: &'static str) -> Self
Creates a Failed error without a platform code.
Sourcepub const fn failed_with_code(reason: &'static str, code: i32) -> Self
pub const fn failed_with_code(reason: &'static str, code: i32) -> Self
Creates a Failed error carrying a platform code.
Trait Implementations§
Source§impl Clone for EntropyError
impl Clone for EntropyError
Source§fn clone(&self) -> EntropyError
fn clone(&self) -> EntropyError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EntropyError
Source§impl Debug for EntropyError
impl Debug for EntropyError
Source§impl Display for EntropyError
impl Display for EntropyError
impl Eq for EntropyError
Source§impl Error for EntropyError
impl Error for EntropyError
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()