Rng

Trait Rng 

Source
pub trait Rng {
    // Required methods
    fn next_u32(&mut self) -> u32;
    fn next_u64(&mut self) -> u64;
    fn fill_bytes(&mut self, dest: &mut [u8]);

    // Provided method
    fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<()> { ... }
}
Expand description

Core trait for random number generators

This trait provides the basic interface for generating random values. It’s compatible with the rand crate’s RngCore trait for interoperability.

Required Methods§

Source

fn next_u32(&mut self) -> u32

Generate the next u32 random value

Source

fn next_u64(&mut self) -> u64

Generate the next u64 random value

Source

fn fill_bytes(&mut self, dest: &mut [u8])

Fill a byte buffer with random data

Provided Methods§

Source

fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<()>

Try to fill a byte buffer with random data (may fail)

Implementors§