epoch_rng 0.1.0

Simple epoch‑based PRNG and configurable LCG PRNG.
Documentation
  • Coverage
  • 0%
    0 out of 21 items documented0 out of 20 items with examples
  • Size
  • Source code size: 6.42 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 41s Average build duration of successful builds.
  • all releases: 41s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ParsaBordbar/epoch_rng
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ParsaBordbar

epoch_rng

Crates.io Documentation

A lightweight psudo random number generator library for Rust featuring:

• Epoch‑seeded RNG
• Configurable Linear Congruential Generator (LCG)
• Simple API
• No external dependencies

This crate is intended for lightweight simulations, games, and experimentation where a fast and simple RNG is useful.

⚠️ Not cryptographically secure.


Installation

cargo add epoch_rng

Usage

use epoch_rng::epoch_rng::EpochRng;

fn main() {
    let mut rng = EpochRng::new();

    println!("u64: {}", rng.next_u64());
    println!("u32: {}", rng.next_u32());
    println!("f64: {}", rng.next_f64());

    println!("range f64: {}", rng.gen_range(1.0, 10.0));
}

Shuffle Example

use epoch_rng::epoch_rng::EpochRng;

fn main() {
    let mut rng = EpochRng::new();

    let mut data = [1,2,3,4,5];
    rng.shuffle(&mut data);

    println!("{:?}", data);
}

LCG RNG

use epoch_rng::lcg_rng::LcgRng;

fn main() {
    let mut rng = LcgRng::new();

    println!("{}", rng.next_u64());
}

Features

Current RNG implementations:

EpochRng – seeded from system epoch time
LcgRng – configurable linear congruential generator

Both support:

  • next_u64
  • next_u32
  • next_f64
  • range generation
  • shuffling

Future Plans

Possible improvements:

  • no_std support
  • additional algorithms (XorShift, PCG, Xoshiro)