getrandom: rand_core and error types
If we are to make this crate independent of rand_core, then we need to include an error type here.
We could simply copy the one rand_core uses; I think something simpler and equivalent on no_std may be preferable however. A quick look at the code shows that where we do include a cause, we are mostly just using an integer error code. Whether it is even worth forwarding the cause is another question.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (15 by maintainers)
I don’t think that such extra-complexity is warranted (plus it will be even less idiomatic that
NonZeroU32). On panics users by default already will get an error message specifying that it originated ingetrandom. After that they’ll have to look into platform specific details either way.As was written in the rust-random/rand#715 I think in addition to
msgwe could addis_retryablemethod andRETRYABLEerror constant. Also I am not sure if automatically retrying onInterruptederror is a correct behavior. For example on Linux interrupt handler could useSA_RESTARTflag to continue interruptible operations withoutEINTR, so hard-coding retry loop may be a wrong approach.There is an option we could use here if we wanted: something akin to the UNIX
errno, but using anAtomicPtrto store a&'static str, behind an API likeThis would be fully
no_stdcompatible with minimal run-time overhead (on successful usage). There are two drawbacks:std; also we would essentially be piggy-backing this crate to define anErrortype possibly used elsewhere in Rand