EntropyError enumv0.1.0
Why unpredictable bytes could not be obtained.
pub enum EntropyError {
Unsupported,
Interrupted,
Failed,
TooLarge
}
Every case is a failure: nothing was written that a caller may rely on. A filled buffer is the success channel of
the ! EntropyError the fill returns.
Cases
| Name | Description |
|---|---|
Unsupported | This system has no entropy source this package can reach. A kernel too old for its own generator reports this. It does not change while a program runs, so retrying is pointless. |
Interrupted | The source kept being interrupted, and the call gave up rather than looping forever. Ordinary on a process taking signals steadily. Worth one more attempt; not worth an unbounded number. |
Failed | The source refused for a reason the system did not make actionable. |
TooLarge | The request was larger than the source accepts in one call. Windows takes a 32-bit count, so a request above four gigabytes has no honest answer. Split it. |
Methods
IsTransient
pub func IsTransient(self: *EntropyError) -> bool
Whether trying again might work.
self is borrowed. True for Interrupted, which says a signal arrived rather than that anything is wrong.
False for everything else: a system with no source will not grow one, and a refusal repeated is still a
refusal.
Cannot fail. Runs in constant time and allocates nothing.
Returns: whether asking again could succeed