81 releases (28 stable)

new 3.4.4 Apr 21, 2025
3.4.2 Dec 4, 2024
3.4.1 Nov 5, 2024
3.2.0 Jul 8, 2024
0.6.0 Nov 10, 2020

#496 in Algorithms

Download history 29193/week @ 2024-12-30 54024/week @ 2025-01-06 54634/week @ 2025-01-13 49807/week @ 2025-01-20 55880/week @ 2025-01-27 67672/week @ 2025-02-03 56915/week @ 2025-02-10 58475/week @ 2025-02-17 55193/week @ 2025-02-24 64593/week @ 2025-03-03 65186/week @ 2025-03-10 77298/week @ 2025-03-17 55678/week @ 2025-03-24 66462/week @ 2025-03-31 71715/week @ 2025-04-07 58273/week @ 2025-04-14

256,366 downloads per month
Used in 227 crates (3 directly)

Apache-2.0…

10KB
103 lines

Capability-based random number generators

This corresponds to rand.

Capability-based APIs represent access to external resources as values which can be passed around between different parts of a program.

Two notable features are the OsRng and CapRng types, which wrap up access to the operating system entropy source in capability values.

This crate uses the existing rand::SeedableRng trait rather than having its own version, however while rand::SeedableRng is mostly just a pure interface, it provides a from_entropy function which directly reads from the operating system entropy source. To preserve the capability-based interface, avoid using rand::SeedableRng's from_entropy function on any of the types that implement that trait; use std_rng_from_entropy instead.


cap-rand

Capability-based random number generators

Github Actions CI Status crates.io page docs.rs docs

The cap-rand crate provides a capability-based interface to random number generators via the rand crate.

Dependencies

~350KB