use crate::{Linux, c_uint};
#[doc = crate::_tags!(rand linux)]
#[doc = crate::_doc_meta!{location("sys/os/linux")}]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LinuxRandomMode {
Secure,
#[default]
SecureNonblock,
Insecure,
}
impl LinuxRandomMode {
#[inline(always)]
pub const fn flags(self) -> c_uint {
match self {
Self::Secure => 0,
Self::SecureNonblock => Linux::GRND_NONBLOCK,
Self::Insecure => Linux::GRND_INSECURE,
}
}
#[inline(always)]
pub const fn is_cryptographic(self) -> bool {
matches!(self, Self::Secure | Self::SecureNonblock)
}
#[inline(always)]
pub const fn is_weak(self) -> bool {
matches!(self, Self::Insecure)
}
#[inline(always)]
pub const fn may_block(self) -> bool {
matches!(self, Self::Secure)
}
}