Skip to main content

CPRNGEntropy

Struct CPRNGEntropy 

Source
pub struct CPRNGEntropy<TPrng>
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,
{ /* private fields */ }
Expand description

Represents a generic entropy generator, which generates randomness from a cryptographically secure PRNG, but is seed from the actual OS entropy.

Implementations§

Source§

impl<TPrng> CPRNGEntropy<TPrng>
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source

pub fn new() -> Result<Self, <StdEntropyGenerator as EntropyGenerator>::Error>

Creates a new instance of CPRNGEntropy

§Errors

These get propagated from [StdEntropyGenerator] when generating a new seed fails.

Source

pub fn generate<T: EntropyConcreteGenerator<CPRNGEntropy<TPrng>>>( &mut self, ) -> T

Generates a new random item.

Trait Implementations§

Source§

impl<TPrng> Clone for CPRNGEntropy<TPrng>
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128> + Clone,

Source§

fn clone(&self) -> CPRNGEntropy<TPrng>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for [u8; N]
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for i128
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for i16
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for i32
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for i64
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for isize
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for u128
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for u16
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for u32
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for u64
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyConcreteGenerator<CPRNGEntropy<TPrng>> for usize
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

fn generate( generator: &mut CPRNGEntropy<TPrng>, ) -> Result<Self, <CPRNGEntropy<TPrng> as EntropyGenerator>::Error>

Generates a new random instance of itself. Read more
Source§

impl<TPrng> EntropyGenerator for CPRNGEntropy<TPrng>
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

type Error = Infallible

CPRNGEntropy cannot fail at randomness generation.

Source§

unsafe fn fill_raw( &mut self, buffer_ptr: *mut u8, buffer_len: usize, ) -> Result<(), Infallible>

Fills raw ptr with randomness based on surrounding entropy. Read more
§

fn fill(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>

Fills slice with randomness based on surrounding entropy. Read more
§

fn generate<T>(&mut self) -> Result<T, Self::Error>
where T: EntropyConcreteGenerator<Self>,

Generates random instance of given type. Read more
Source§

impl<TPrng> ReprC for CPRNGEntropy<TPrng>
where TPrng: PRNGenerator + CryptographicallySecure + Seedable<u128>,

Source§

const CHECK: ()

This field is used for const checks only.

Auto Trait Implementations§

§

impl<TPrng> Freeze for CPRNGEntropy<TPrng>
where TPrng: Freeze,

§

impl<TPrng> RefUnwindSafe for CPRNGEntropy<TPrng>
where TPrng: RefUnwindSafe,

§

impl<TPrng> Send for CPRNGEntropy<TPrng>
where TPrng: Send,

§

impl<TPrng> Sync for CPRNGEntropy<TPrng>
where TPrng: Sync,

§

impl<TPrng> Unpin for CPRNGEntropy<TPrng>
where TPrng: Unpin,

§

impl<TPrng> UnsafeUnpin for CPRNGEntropy<TPrng>
where TPrng: UnsafeUnpin,

§

impl<TPrng> UnwindSafe for CPRNGEntropy<TPrng>
where TPrng: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.