Skip to content

Add SysRng behind new feature sys_rng#751

Merged
dhardy merged 19 commits into
masterfrom
push-tqlwtzsrywpy
Nov 24, 2025
Merged

Add SysRng behind new feature sys_rng#751
dhardy merged 19 commits into
masterfrom
push-tqlwtzsrywpy

Conversation

@dhardy

@dhardy dhardy commented Nov 10, 2025

Copy link
Copy Markdown
Member

This was mentioned elsewhere: rust-random/rand#1675

Adds rand_core as a dependency, which is one small crate.

This attempts to enable testing of rng in all CI tests.

@dhardy

dhardy commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

@newpavlov your opinion on this please?

There is an alternative: the rand_os crate. I slightly prefer fewer crates but either is acceptable.

@newpavlov

Copy link
Copy Markdown
Member

As I wrote previously, personally, I have a slight preference for a separate crate. But I would be fine with this PR as well, if others prefer it.

P.S.: Note that rand_os recently got an "unmaintained" advisory: rustsec/advisory-db#2462

@josephlr josephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote previously, personally, I have a slight preference for a separate crate. But I would be fine with this PR as well, if others prefer it.

I think I would slightly lean towards having this as part of getrandom. A non-default additive feature seems like a good fit. I think the only complexity is figuring out what (if anything) this crate should re-export from rand_core.

Comment thread .github/workflows/tests.yml Outdated
Comment thread Cargo.toml Outdated
Comment thread src/rng.rs Outdated
Comment thread src/rng.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/rng.rs Outdated
Comment thread src/lib.rs Outdated
@dhardy

dhardy commented Nov 19, 2025

Copy link
Copy Markdown
Member Author

Thanks for moving this forward @josephlr. I think I addressed your concerns (except as commented).

Comment thread src/rng.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread src/rng.rs Outdated
@dhardy

dhardy commented Nov 21, 2025

Copy link
Copy Markdown
Member Author

@newpavlov I addressed your concerns

Comment thread src/rng.rs Outdated
Comment thread tests/rng.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread .github/workflows/tests.yml Outdated
Comment thread src/sys_rng.rs
Comment thread src/sys_rng.rs Outdated
@newpavlov

newpavlov commented Nov 23, 2025

Copy link
Copy Markdown
Member

@josephlr
WDYT? It looks like the only unresolved question is whether we need to introduce UnwrappedSysRng or not.

@dhardy
Please add #![cfg_attr(docsrs, feature(doc_cfg))] as per the comment above and add a changelog entry.

@newpavlov newpavlov changed the title Add OsRng to getrandom Add SysRng to getrandom Nov 23, 2025
@newpavlov newpavlov changed the title Add SysRng to getrandom Add feature-gated SysRng type implementing rand_core traits Nov 23, 2025
@dhardy

dhardy commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

@newpavlov see lib.rs:12.

@dhardy

dhardy commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

A consequence of renaming the feature to sys_rng is:
image
Would it be better just to name the feature rng?

@dhardy

dhardy commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

I added UnwrappedSysRng (with a slight doc tweak)

@newpavlov

Copy link
Copy Markdown
Member

What about changelog?

It could worth to add test_unwrapped_sys_rng.

Would it be better just to name the feature rng?

Personally, I don't see a problem with the provided rendering.

@dhardy

dhardy commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

Added CHANGELOG entry and test case.

Comment thread tests/sys_rng.rs Outdated
@newpavlov newpavlov changed the title Add feature-gated SysRng type implementing rand_core traits Add SysRng and UnwrappedSysRng behind new feature sys_rng Nov 24, 2025
@newpavlov newpavlov changed the title Add SysRng and UnwrappedSysRng behind new feature sys_rng Add SysRng behind new feature sys_rng Nov 24, 2025
@dhardy dhardy merged commit 6cbbcb4 into master Nov 24, 2025
75 checks passed
@dhardy dhardy deleted the push-tqlwtzsrywpy branch November 24, 2025 11:23

@josephlr josephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (sorry for the delay on review), will respond about UnwrappedSysRng in #754

takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants