Expand description
Uniform random selection and stealth-safe token primitives.
This crate owns the empty-domain and alphabet contracts for random choices
used by stealth consumers. The APIs avoid modulo-biased sampling and return
None for invalid caller-supplied alphabets instead of panicking.
Structs§
- StdRng
- The standard RNG. The PRNG algorithm in
StdRngis chosen to be efficient on the current platform, to be statistically strong and unpredictable (meaning a cryptographically secure PRNG).
Constants§
- LOWER_
ALPHANUMERIC - Lowercase ASCII letters plus digits.
Functions§
- chance
- Return
truewith the requested probability using thread-local entropy. - chance_
with_ rng - Return
truewith the requested probability using the caller’s RNG. - random_
ascii_ string - Generate an ASCII string from a caller-supplied alphabet using thread-local entropy.
- random_
ascii_ string_ with_ rng - Generate an ASCII string from a caller-supplied alphabet using the caller’s RNG.
- random_
index - Sample a uniformly random index in
0..len. - random_
index_ with_ rng - Sample a uniformly random index in
0..lenusing the caller’s RNG. - random_
item - Sample a uniformly random item from a slice.
- random_
item_ with_ rng - Sample a uniformly random item from a slice using the caller’s RNG.
- random_
lower_ alphanumeric - Generate a lowercase alphanumeric string using thread-local entropy.
- random_
lower_ alphanumeric_ with_ rng - Generate a lowercase alphanumeric string using the caller’s RNG.
- seed_
from_ u64 - Convert a small integer seed into a full byte seed deterministically.
- seeded_
rng - Build a seeded
StdRngfrom a byte seed. - seeded_
rng_ from_ u64 - Build a seeded
StdRngfrom a small integer seed. - weighted_
index - Sample an index from a non-negative finite weight slice.
- weighted_
index_ by_ with_ rng - Sample an item index using weights projected from each item.
- weighted_
index_ with_ rng - Sample an index from a non-negative finite weight slice using the caller’s RNG.
Type Aliases§
- Seed
- A deterministic 32-byte seed for fleet-wide RNGs.