Struct linux_kcapi::Rng [−][src]
Random Generator.
If the rand_trait
feature is enabled, it implements the rand_core::RngCore
and rand_core::CryptoRng
traits.
Sample usage
use linux_kcapi::{RngType, Rng}; let rng = Rng::new(RngType::DrbgPrHmacSha256, &seed)?; rng.get_bytes(&mut data)?; assert_ne!(zero, data); rng.get_bytes(&mut data2)?; assert_ne!(data, data2);
Implementations
impl Rng
[src]
pub fn new<T>(rng: RngType, seed: &T) -> Result<Self, Error> where
T: AsRef<[u8]> + Clone,
[src]
T: AsRef<[u8]> + Clone,
#[must_use]pub fn name(&self) -> RngType
[src]
Get Rng type
pub fn get_bytes(&self, dest: &mut [u8]) -> Result<(), Error>
[src]
fill destination with random bytes
Errors
Error::Incomplete
if destination was not totally filledError::Sys(Errno)
in case of low level error
Trait Implementations
impl CryptoRng for Rng
[src]
Only available with "rand_trait"
feature
impl RngCore for Rng
[src]
Only available with "rand_trait"
feature
Panic
next_u32
, next_u64
and fill_bytes
will panic in case of error
Auto Trait Implementations
impl RefUnwindSafe for Rng
[src]
impl Send for Rng
[src]
impl Sync for Rng
[src]
impl Unpin for Rng
[src]
impl UnwindSafe for Rng
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,