fastmash 0.6.0

Fast command-line statistics on text data, compatible with GNU datamash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Checked Linux entropy for native storage.
use rustix::{
    io::Errno,
    rand::{GetRandomFlags, getrandom},
};
use std::io;
pub(crate) fn random(bytes: &mut [u8]) -> io::Result<()> {
    let mut at = 0;
    while at < bytes.len() {
        match getrandom(&mut bytes[at..], GetRandomFlags::empty()) {
            Ok(0) => return Err(io::Error::other("empty random read")),
            Ok(n) => at += n,
            Err(Errno::INTR) => {}
            Err(e) => return Err(e.into()),
        }
    }
    Ok(())
}