use crate::{ElicitCommunicator, ElicitResult, Elicitation, Prompt, default_style};
use rand::SeedableRng;
use rand::rngs::StdRng;
use rand_chacha::ChaCha8Rng;
default_style!(StdRng => StdRngStyle);
default_style!(ChaCha8Rng => ChaCha8RngStyle);
impl Prompt for StdRng {
fn prompt() -> Option<&'static str> {
Some("Enter seed for standard RNG (u64):")
}
}
impl Elicitation for StdRng {
type Style = StdRngStyle;
async fn elicit<C: ElicitCommunicator>(communicator: &C) -> ElicitResult<Self> {
let seed: u64 = u64::elicit(communicator).await?;
Ok(StdRng::seed_from_u64(seed))
}
}
impl Prompt for ChaCha8Rng {
fn prompt() -> Option<&'static str> {
Some("Enter seed for cryptographic RNG (u64):")
}
}
impl Elicitation for ChaCha8Rng {
type Style = ChaCha8RngStyle;
async fn elicit<C: ElicitCommunicator>(communicator: &C) -> ElicitResult<Self> {
let seed: u64 = u64::elicit(communicator).await?;
Ok(ChaCha8Rng::seed_from_u64(seed))
}
}