pub trait EntropySource: Send {
// Required methods
fn timestamp(&mut self) -> Option<u64>;
fn random(&mut self, range: RangeInclusive<u128>) -> Option<u128>;
}Expand description
Trait for entropy sources.
For a type to be used as an entropy source, implement the EntropySource trait and
create an EntropySourceHandle out of it and set the handle using the set_entropy_source function.
§Example
struct MySource;
impl MySource {
fn new() -> Self {
todo!()
}
}
impl mr_ulid::EntropySource for MySource {
fn timestamp(&mut self) -> Option<u64> {
todo!()
}
fn random(&mut self, range: std::ops::RangeInclusive<u128>) -> Option<u128> {
todo!()
}
}
let my_source = MySource::new();
let handle = mr_ulid::EntropySourceHandle::new(my_source);
mr_ulid::set_entropy_source(handle);