fakedata_generator
A rust crate to generate fake datasets
IMPORTANT NOTE
The gen_corpora_switch generator will not work when compiling the library into a binary or including it in your project. The generator is not able to find the JSON files it needs to read and I haven't figured out how to include the files yet.
The data comes from the Corpora Project.
About
This crate provides functions to generate datasets, e.g. 10 dog breed names or 10 domain names, etc.
It is a very early version and not meant to be used in any production services or third-party tooling.
Usage
Load the library with use fakedata_generator::* and then call one of the generator functions.
use *;
A list of all available generators can be found below.
Generators
Generators without arguments
Return a random e-Mail address which is a combination of the username and domain generator.
Rust function signature
gen_email
Example
let word: String = gen_email();
// word = shaneIxD@we.net
username
Return a random username.
Note: predefined list as of v0.1.
Function signature
gen_username
Example
let word: String = gen_username;
// word = ahmadajmi
domain
Return a random domain name.
Note: Does not yet support all TDLs and true random host names - it's created by a predefined list.
gen_domain
Example
let word: String = gen_domain;
// word = "names.us"
gen_http_method
Return a random HTTP method from a defined list.
Possible values: "DELETE", "GET", "HEAD", "OPTION", "PATCH", "POST", "PUT"
gen_http_method
Example
let word: String = gen_http_method;
// word = "GET"
gen_ipv4
Returns a random IP address. Generates four numbers in the range of 0 - 255.
gen_ipv4
Exmaple
let ip: String = gen_ipv4;
// ip = "168.11.40.75"
Generators with arguments
enum
Return random string from set of specified strings. Specify a comma seperated list as argument.
Function signature
gen_enum
Example
let word: String = gen_enum;
// word = "hola"
int
Return random integer in range. Must specify 1 or 2 numbers separated by comma.
Function signature
gen_int
Example
let num: String = gen_enum;
// num = "42"
Corpora generator
gen_corpora_switch is a special generator that reads JSON files from the Corpora Project and returns a random value. As noted above this will not work as of now.
Possible values:
catdoghorsedinosaur
Each of these will return a random breed of the specified animal.
Function signature
gen_corpora_switch
Example
let cat: String = gen_corpora_switch;
// cat = "European Shorthair"