pub trait EntropySource: Send + Sync {
// Required method
fn get_entropy(&mut self, dest: &mut [u8]) -> Result<()>;
// Provided methods
fn is_available(&self) -> bool { ... }
fn quality(&self) -> f64 { ... }
fn name(&self) -> &'static str { ... }
fn source_type(&self) -> EntropySourceType { ... }
fn max_entropy_per_call(&self) -> Option<usize> { ... }
fn requires_initialization(&self) -> bool { ... }
fn initialize(&mut self, config: &EntropyConfig) -> Result<()> { ... }
}Expand description
Entropy source trait for providing random data
This trait defines the interface for entropy sources that can provide random data to RNG implementations.
Required Methods§
Provided Methods§
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if the entropy source is available
Returns true if the entropy source is available and can provide
entropy, false otherwise.
Sourcefn quality(&self) -> f64
fn quality(&self) -> f64
Get the entropy source’s quality estimate (0.0 to 1.0)
Returns an estimate of the entropy source’s quality, where 1.0 represents perfect entropy and 0.0 represents no entropy.
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Get the entropy source’s name
Returns a human-readable name for the entropy source.
Sourcefn source_type(&self) -> EntropySourceType
fn source_type(&self) -> EntropySourceType
Get the entropy source’s type
Returns the type of entropy source.
Sourcefn max_entropy_per_call(&self) -> Option<usize>
fn max_entropy_per_call(&self) -> Option<usize>
Get the maximum entropy that can be obtained in one call
Returns the maximum number of bytes that can be obtained in a single
call to get_entropy, or None if there’s no limit.
Sourcefn requires_initialization(&self) -> bool
fn requires_initialization(&self) -> bool
Check if the entropy source requires initialization
Returns true if the entropy source requires initialization before use.
Sourcefn initialize(&mut self, config: &EntropyConfig) -> Result<()>
fn initialize(&mut self, config: &EntropyConfig) -> Result<()>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl EntropySource for DeterministicEntropySource
impl EntropySource for HardwareEntropySource
impl EntropySource for OsEntropySource
impl EntropySource for UserEntropySource
alloc only.impl EntropySource for SaturninDeterministicEntropySource
alloc only.