Skip to content

Improving OsRng access #681

@tarcieri

Description

@tarcieri

We have several crates, some in this repo, that use traits from rand_core. An example is the aead crate:

https://docs.rs/aead/0.4.1/aead/trait.NewAead.html#method.generate_key

However, while some crates document how to use OsRng as the concrete RNG, we typically don't make this easy.

Some suggestions for improving this:

Re-export rand_core

This would make it easier to access both the traits and the built-in RNG.

It could be exported verbatim as rand_core, or perhaps we could consider making the feature name rand and re-exporting it as rand. But that might be a bit less clear than just the rand_core name, even though it's a bit uglier. (edit: so far we're just doing rand_core for clarity that it's a re-export)

Have the std feature activate rand_core/std

This would mean that rand_core is always pulled in whenever std is enabled (at least until weak feature activation ships), but would make it easy for users to access rand_core::OsRng when the std feature is enabled, e.g. as aead::rand_core::OsRng.

Implementation status

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions