[−][src]Struct exrng::ExternalRng
ExternalRng has all features But use external random source
Fields
rng_bytes: [u8; 32]
bytes to receive external rng when init
len: usize
lenght of RNG
Methods
impl ExternalRng
[src]
pub fn copy_into_array<A, T>(slice: &[T]) -> A where
A: Default + AsMut<[T]>,
T: Copy,
[src]
A: Default + AsMut<[T]>,
T: Copy,
for no std env if want to convert slice to array
Inputs
- 'slice' is a slice from raw part
returns
- array from slice
Examples
use rand_core::{CryptoRng,RngCore}; use exrng::ExternalRng; fn main(){ use core::slice; let rng_bytes:[u8;32] = [1u8;32]; let random_ptr: *const u8 = rng_bytes.as_ptr(); let r:&[u8] = unsafe {slice::from_raw_parts(random_ptr, 32)}; let mut rng = ExternalRng {rng_bytes:ExternalRng::copy_into_array(r),len:32}; let mut zero = [0u8; 32]; rng.fill_bytes(&mut zero); assert_eq!([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], &zero[..]); }
Trait Implementations
impl Debug for ExternalRng
[src]
impl Clone for ExternalRng
[src]
fn clone(&self) -> ExternalRng
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl RngCore for ExternalRng
[src]
implement Trait RngCore for EnternalRng foucus on fill_bytes
fn next_u32(&mut self) -> u32
[src]
fn next_u64(&mut self) -> u64
[src]
fn fill_bytes(&mut self, dest: &mut [u8])
[src]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]
impl CryptoRng for ExternalRng
[src]
implement Trait CryptoRng for EnternalRng empty implement
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,