Crates.io | randomorg |
lib.rs | randomorg |
version | 1.0.4 |
source | src |
created_at | 2017-06-27 10:55:31.524875 |
updated_at | 2021-02-10 18:46:34.604665 |
description | A random.org client library. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs. |
homepage | |
repository | https://github.com/vityafx/randomorg |
max_upload_size | |
id | 20914 |
size | 96,235 |
A https://random.org client library. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
Everything is implemented. Note, that the random.org
service
API is at beta stage of development, however the library will try to be up-to-date.
The documentation which may help you using this library.
Sync
and
Send
).reqwest
crate is used for performing requests.chrono
for dates.serde
for serialization and deserialization.rand
feature which provides the
rand_core::RngCore
trait implementation for the Random
struct and adds new FallibleRandom<T: rand_core::RngCore>
structure
for better random generation UX.Start by creating Random
instance and perform needed operations after.
extern crate randomorg;
fn main() {
use randomorg::Random;
let r = Random::new("API KEY HERE");
// A method-call way:
println!("Result: {:?}", r.generate_integers(-100, 100, 15, true));
// A lazy request builder way:
let random_data = r.request_integers().min(0).max(100).limit(5).collect::<Vec<i32>>();
println!("Random integers: {:?}", random_data);
}
With the rand
feature you can also use it that way:
extern crate randomorg;
fn main() {
use rand_core::RngCore;
use randomorg::Random;
let mut random = Random::new("API KEY HERE");
let mut key = [0u8; 16];
random.fill_bytes(&mut key);
let random_u64 = random.next_u64();
}
This project is licensed under the MIT license.