pub struct Faker { /* private fields */ }Expand description
The seedable random-value source every template’s random defaults draw from.
A SplitMix64 generator (Steele, Lea & Flood’s public-domain algorithm),
implemented here rather than depended upon — see the crate docs for the
fake-vs-rand-vs-in-crate evaluation. The output sequence for a given
seed is pinned by test in this crate: two Faker::seeded instances
with the same seed produce identical values, on every platform, forever —
that is the determinism switch’s whole contract.
Not cryptographic, and not meant to be: this generates test data.
Implementations§
Source§impl Faker
impl Faker
Sourcepub fn seeded(seed: u64) -> Self
pub fn seeded(seed: u64) -> Self
A faker whose entire output is determined by seed — the
reproducibility switch. Same seed, same values, always.
Sourcepub fn from_entropy() -> Self
pub fn from_entropy() -> Self
A faker seeded from wall-clock entropy plus a process-global counter —
what create/create_many use when the caller does not care about
reproducing the run.
Sourcepub fn below(&mut self, n: u64) -> u64
pub fn below(&mut self, n: u64) -> u64
A value in 0..n. The multiply-shift reduction carries a negligible
modulo bias — acceptable for test data, and deterministic, which is
what matters here.
§Panics
If n is zero — an empty range has no value to produce.