Trait nettle::random::Random

source ·
pub trait Random {
    // Required methods
    unsafe fn context(&mut self) -> *mut c_void;
    unsafe extern "C" fn random_impl(
        ctx: *mut c_void,
        length: size_t,
        dst: *mut u8
    );

    // Provided method
    fn random(&mut self, buf: &mut [u8]) { ... }
}
Expand description

A cryptographic random number generator.

Required Methods§

source

unsafe fn context(&mut self) -> *mut c_void

Returns a pointer to the opaque CRNG state.

source

unsafe extern "C" fn random_impl( ctx: *mut c_void, length: size_t, dst: *mut u8 )

Fills the buffer dst with length random bytes, advancing the CRNG state ctx.

Provided Methods§

source

fn random(&mut self, buf: &mut [u8])

Fills the buffer random with random bytes.

Examples found in repository?
examples/polymorphic.rs (line 186)
184
185
186
187
188
fn random_bool() -> bool {
    let mut b = [0];
    Yarrow::default().random(&mut b);
    b[0] > 127
}

Object Safety§

This trait is not object safe.

Implementors§