Skip to main content

EntropySource

Trait EntropySource 

Source
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§

Source

fn get_entropy(&mut self, dest: &mut [u8]) -> Result<()>

Get entropy from the source

§Arguments
  • dest - Buffer to fill with entropy data
§Errors

Returns an error if entropy cannot be obtained from the source.

Provided Methods§

Source

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.

Source

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.

Source

fn name(&self) -> &'static str

Get the entropy source’s name

Returns a human-readable name for the entropy source.

Source

fn source_type(&self) -> EntropySourceType

Get the entropy source’s type

Returns the type of entropy source.

Source

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.

Source

fn requires_initialization(&self) -> bool

Check if the entropy source requires initialization

Returns true if the entropy source requires initialization before use.

Source

fn initialize(&mut self, config: &EntropyConfig) -> Result<()>

Initialize the entropy source

§Arguments
  • config - Configuration parameters for initialization
§Errors

Returns an error if initialization fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§