use super::Entropy;
use std::io;
#[derive(Debug, Clone, Copy, Default)]
pub struct WindowsEntropy;
impl WindowsEntropy {
pub const fn new() -> Self {
Self
}
}
impl crate::sealed::Sealed for WindowsEntropy {}
impl Entropy for WindowsEntropy {
fn fill(&self, buf: &mut [u8]) -> io::Result<()> {
getrandom::fill(buf).map_err(|e| match e.raw_os_error() {
Some(code) => io::Error::from_raw_os_error(code),
None => io::Error::other(format!("the OS CSPRNG refused: {e}")),
})
}
}