Rename RandomSource -> Rng, DefaultRandomSource -> SysRng#157539
Rename RandomSource -> Rng, DefaultRandomSource -> SysRng#157539joshtriplett wants to merge 1 commit into
RandomSource -> Rng, DefaultRandomSource -> SysRng#157539Conversation
Per naming bikeshed in libs-api. `Rng` is shorter, and already established in the ecosystem. `Sys` is also shorter, and makes it self-documenting that `SysRng` gets its randomness from the system RNG.
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
|
||
| use crate::sys::random as sys; | ||
|
|
||
| /// The default random source. |
There was a problem hiding this comment.
Is SysRng still going to be "the default random source" (or: default RNG)? Discussion on Zulip raised two (possibly conflicting) reasons why we might want a DefaultRng separate from SysRng:
- On platforms where the raw system source has deficiencies that std can fix (e.g., non-uniform outputs), it may be useful to have the default source be distinct from
SysRngso that the latter can remain a thin wrapper as advertised. - On platforms where the raw system source is secure but slow, it's tempting to add a "faster, possibly not quite as secure, but fine for some uses" userspace PRNG and declare that one the default.
Conversely, if SysRng is still the default, then how do we make sure it's still perceived as the default if and when std::random gains a second or third type that implements Rng?
There was a problem hiding this comment.
My intention was that SysRng is still the default, just named more concisely. I wasn't attempting to position it as something other than "default", hence why I didn't change any of these comments.
(I did see that discussion.)
Part of our rationale for keeping the system RNG as the default is that it's fast enough for most users, much faster on some platforms (e.g. Linux with vDSO), secure by default (on platforms where that's possible at all), and supports useful system properties like vmfork.
|
Looks like a simple change; |
|
I don't really want to bikeshed this all over again, but how about calling this |
|
@joboet |
I'm trying to figure out what the CI issue is. Currently re-running it because it's not clear to me if it's spurious or not. |
Per naming bikeshed in libs-api.
Rngis shorter, and already established in the ecosystem.Sysis also shorter, and makes it self-documenting thatSysRnggets its randomness from the system RNG.This also makes it short and convenient to write
SysRng.fill_bytes, rather thanDefaultRandomSource.fill_bytes.