Crate randomorg

Source
Expand description

A random.org api bindings.

The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs. To use the library you must have an api key which you may get from here.

§Usage

extern crate randomorg;

fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE");
    println!("Result: {:?}", r.generate_integers(-100, 100, 15, true));
    let random_data = r.request_integers().min(0).max(100).limit(5).collect::<Vec<i32>>();
    println!("Random integers: {:?}", random_data);
}

§Warning

However the library provides a thread-safe object, the random.org service does not allow to use their API from multithreaded-apps. The service processes incoming calls according the request_id parameter, it must be different for concurrent calls, while this library always provides request_id equal to 1. So when you use the library from multiple threads the library will send multiple requests simultaneously with the same request_id field and the random.org service will refuse to process them.

Modules§

version
This module gives the build and version information about the library.

Structs§

AllowedCharacters
Allowed characters
ApiKey
A random.org api key
ErrorCode
Random.org error code.
GetUsageResult
A random.org response of getUsage method.
Random
A random.org api client.
RandomData
A random.org’s produced random data (from generateIntegers method)
RandomResult
A random.org response with random data.
Request
A random.org request holder
RequestBlobs
A lazy blobs request (builder)
RequestDecimalFractions
A lazy decimal fractions request (builder)
RequestGaussians
A lazy gaussians request (builder)
RequestId
An unique random.org request id
RequestIntegers
A lazy integers request (builder)
RequestStrings
A lazy strings request (builder)
RequestUUIDs
A lazy UUIDs request (builder)
Response
A random.org response holder
ResponseError
Random.org response error definition.

Enums§

ApiKeyStatus
A random.org api key status
Error
Random.org API crate error type.

Type Aliases§

GenerateBlobsResult
A random.org response of GenerateBlobs method.
GenerateDecimalFractionsResult
A random.org response of GenerateDecimalFractions method.
GenerateGaussiansResult
A random.org response of GenerateGaussians method.
GenerateIntegersResult
A random.org response of generateIntegers method.
GenerateStringsResult
A random.org response of GenerateStrings method.
GenerateUUIDsResult
A random.org response of GenerateUUIDs method.
Result
Random.org API Result alias type.