Trait kernel::hil::rng::Rng

source ·
pub trait Rng<'a> {
    // Required methods
    fn get(&self) -> Result<(), ErrorCode>;
    fn cancel(&self) -> Result<(), ErrorCode>;
    fn set_client(&'a self, _: &'a dyn Client);
}
Expand description

Generic interface for a 32-bit random number generator.

Implementors should assume the client implements the Client trait.

Required Methods§

source

fn get(&self) -> Result<(), ErrorCode>

Initiate the aquisition of new random number generation.

There are three valid return values:

  • Ok(()): a randomness_available callback will be called in the future when randomness is available.
  • FAIL: a randomness_available callback will not be called in the future, because random numbers cannot be generated. This is a general failure condition.
  • OFF: a randomness_available callback will not be called in the future, because the random number generator is off/not powered.
source

fn cancel(&self) -> Result<(), ErrorCode>

Cancel acquisition of random numbers.

There are two valid return values:

  • Ok(()): an outstanding request from get has been cancelled, or there was no oustanding request. No randomness_available callback will be issued.
  • FAIL: There will be a randomness_available callback, which may or may not return an error code.
source

fn set_client(&'a self, _: &'a dyn Client)

Implementors§