73 releases (20 stable)

new 3.1.0 May 16, 2024
3.0.0 Jan 11, 2024
2.0.1 Jan 2, 2024
2.0.0 Jun 30, 2023
0.6.0 Nov 10, 2020

#282 in Algorithms

Download history 31046/week @ 2024-01-26 33230/week @ 2024-02-02 27734/week @ 2024-02-09 31377/week @ 2024-02-16 31990/week @ 2024-02-23 32345/week @ 2024-03-01 29096/week @ 2024-03-08 30342/week @ 2024-03-15 28775/week @ 2024-03-22 30093/week @ 2024-03-29 28928/week @ 2024-04-05 31110/week @ 2024-04-12 37977/week @ 2024-04-19 34241/week @ 2024-04-26 37681/week @ 2024-05-03 34074/week @ 2024-05-10

148,922 downloads per month
Used in 171 crates (3 directly)

Apache-2.0…

9KB
103 lines

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.


lib.rs:

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.

Dependencies

~325KB