#random

cap-rand

Capability-based random number generators

84 releases (31 stable)

4.0.2 Feb 15, 2026
4.0.0 Dec 11, 2025
3.4.5 Oct 24, 2025
3.4.4 Apr 21, 2025
0.6.0 Nov 10, 2020

#1471 in Algorithms

Download history 134925/week @ 2026-01-22 121520/week @ 2026-01-29 117416/week @ 2026-02-05 140053/week @ 2026-02-12 164428/week @ 2026-02-19 170601/week @ 2026-02-26 208507/week @ 2026-03-05 183630/week @ 2026-03-12 175357/week @ 2026-03-19 199191/week @ 2026-03-26 180101/week @ 2026-04-02 205845/week @ 2026-04-09 203992/week @ 2026-04-16 223895/week @ 2026-04-23 216354/week @ 2026-04-30 251152/week @ 2026-05-07

927,405 downloads per month
Used in 607 crates (5 directly)

Apache-2.0…

11KB
96 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

~1.5MB
~26K SLoC