Trait Generator

Source
pub trait Generator {
    // Required method
    fn generate() -> Result<Self, BwError>
       where Self: Sized;
}
Expand description

The Generator trait defines a common interface for types that require a generation phase, typically resulting in the instantiation of a unique or random state.

§Example

let generated_key = EdDsaKey::generate().expect("Key generation failed");

Implementing Generator trait for your own types enables the structured creation of instances, particularly in cryptographic or secure contexts where randomness or uniqueness is crucial.

Required Methods§

Source

fn generate() -> Result<Self, BwError>
where Self: Sized,

Generates and returns an instance of the implementing type.

§Errors

Returns crate::BwError in cases where generation fails, e.g., due to insufficient system entropy, internal failures, etc.

Implementors§