Struct secp256kfun::nonce::GlobalRng[][src]

pub struct GlobalRng<R> { /* fields omitted */ }
Expand description

A zero sized type that wraps an RNG that implementes Default e.g. ThreadRng. GlobalRng implements NonceRng and care has been taken to ensure it is Sync.

Examples

use rand::rngs::ThreadRng;
use secp256kfun::nonce::{GlobalRng, NonceRng};
let nonce_rng = GlobalRng::<ThreadRng>::default();
let mut bytes = [0u8; 32];
nonce_rng.fill_bytes(&mut bytes);
assert_ne!(bytes, [0u8; 32]);

fn is_sync<S: Sync>(x: S) -> bool {
    true
}
assert!(is_sync(nonce_rng));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

We implement NonceRng only for rngs we can conjure out of thin air with Default.

Fill bytes with random data.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Returns a new instance of the invocant that will be marked with M. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.