Skip to main content

Entropy

Trait Entropy 

Source
pub trait Entropy {
    // Required method
    fn fill(&mut self, buf: &mut [u8]) -> Result<(), EntropyError>;
}
Expand description

A source of cryptographically secure random bytes.

Blanket-implemented for closures so hosts pass a function, not a global: natively |b| getrandom::getrandom(b).map_err(...), in Workers the JS crypto equivalent, in tests a counter. Upholds the sans-I/O law (design doc 03 §1).

Required Methods§

Source

fn fill(&mut self, buf: &mut [u8]) -> Result<(), EntropyError>

Fill buf entirely with random bytes, or fail.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> Entropy for F
where F: FnMut(&mut [u8]) -> Result<(), EntropyError>,