#random #rng

cap-rand

Capability-based random number generators

61 releases (8 stable)

new 1.0.7 Mar 18, 2023
1.0.5 Feb 3, 2023
1.0.3 Dec 24, 2022
1.0.1 Nov 10, 2022
0.6.0 Nov 10, 2020

#56 in Algorithms

Download history 9606/week @ 2022-11-27 8075/week @ 2022-12-04 9402/week @ 2022-12-11 10001/week @ 2022-12-18 3816/week @ 2022-12-25 7398/week @ 2023-01-01 10294/week @ 2023-01-08 9896/week @ 2023-01-15 10586/week @ 2023-01-22 9710/week @ 2023-01-29 8621/week @ 2023-02-05 9549/week @ 2023-02-12 9826/week @ 2023-02-19 10827/week @ 2023-02-26 10679/week @ 2023-03-05 10459/week @ 2023-03-12

42,723 downloads per month
Used in 80 crates (2 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