Skip to main content

PRStream

Trait PRStream 

Source
pub trait PRStream:
    Sized
    + Clone
    + ReprC {
    // Required method
    unsafe fn fill_raw(&mut self, dst_ptr: *mut u8, dst_len: usize);

    // Provided methods
    fn fill_block(&mut self, block: &mut [u8]) { ... }
    fn next_block<const N: usize>(&mut self) -> [u8; N] { ... }
}
Expand description

Represents a pseudo random stream. These are easily convertible into PRNGs through the StreamPRNG wrapper.

Required Methods§

Source

unsafe fn fill_raw(&mut self, dst_ptr: *mut u8, dst_len: usize)

Fills the given raw buffer with randomness.

§Safety

This function assumes that both dst_ptr and dst_len correspond to valid chunk of memory. Otherwise the behaviour is undefined.

Provided Methods§

Source

fn fill_block(&mut self, block: &mut [u8])

Fills the given block with randomness.

Source

fn next_block<const N: usize>(&mut self) -> [u8; N]

Generates the next block of given length.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const ROUNDS: u32> PRStream for ChaChaStream<ROUNDS>