Struct randomorg::Random [] [src]

pub struct Random { /* fields omitted */ }

A random.org api client.

Methods

impl Random
[src]

Creates new random.org client.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
}

This method generates true random integers within a user-defined range.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_integers(-100, 100, 15, true));
}

Constraints

  • min must be within [-1e9; 1e9] range
  • max must be within [-1e9; 1e9] range
  • limit must be within [1; 1e4] range

This method generates true random decimal fractions from a uniform distribution across the [0,1] interval with a user-defined number of decimal places.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_decimal_fractions(10, 8));
}

Constraints

  • limit must be within [1; 1e4] range
  • decimal_places must be within [1; 20] range

This method generates true random numbers from a Gaussian distribution (also known as a normal distribution). The form uses a Box-Muller Transform to generate the Gaussian distribution from uniformly distributed numbers.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_gaussians(2000, 1100, 100, 4));
}

Constraints

  • limit must be within [1; 1e4] range
  • mean must be within [-1e6; 1e6] range
  • standard_deviation must be within [-1e6; 1e6] range
  • significant_digits must be within [2; 20] range

This method generates true random strings.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::{ Random, AllowedCharacters };
    use std::collections::BTreeSet;
    let chars = "abcde".chars().collect::<BTreeSet<char>>();
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_strings(5, 10, AllowedCharacters(chars)));
}

Constraints

  • limit must be within [1; 1e4] range
  • length must be within [1; 20] range
  • characters must contain maximum 80 characters.

This method generates version 4 true random Universally Unique IDentifiers (UUIDs) in accordance with section 4.4 of RFC 4122.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_uuids(5));
}

Constraints

  • limit must be within [1; 1e3] range

This method generates Binary Large OBjects (BLOBs) containing true random data.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.generate_blobs(5, 16));
}

Constraints

  • limit must be within [1; 100] range
  • size must be within [1, 1048576] range

Returns information related to the usage of a given API key.

Usage

extern crate randomorg;
 
fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE").unwrap();
    println!("Result: {:?}", r.get_usage());
}