fakeit
Port of the famous Go fakeit library for Rust with more than 130 functions.
Warning
v1.2.0 breaks the backward compatibility with the previous versions. The chrono
package have been completely removed, so the following functions returns simplified structs:
datetime::date_range("RFC3339", "RFC3339");
datetime::date();
There is the workaround to get the same behaviour as before:
extern crate fakeit;
extern crate chrono;
use fakeit::datetime;
use chrono::{DateTime, NaiveDateTime, Utc};
fn main() {
let data = datetime::date_range("RFC3339", "RFC3339");
let data = datetime::date();
let datetime = NaiveDateTime::from_timestamp_opt(data.secs, data.nsecs)
.expect("invalid or out-of-range datetime");
let dt = DateTime::<Utc>::from_utc(datetime, Utc);
println!("{}", dt.to_rfc3339());
}
Usage
Functions
address (16 functions)
extern crate fakeit;
use fakeit::address;
fn main() {
let data = address::info(); let data = address::street(); let data = address::street_number(); let data = address::street_prefix(); let data = address::street_name(); let data = address::street_suffix(); let data = address::city(); let data = address::state(); let data = address::state_abr(); let data = address::zip(); let data = address::country(); let data = address::country_abr(); let data = address::latitude(); let data = address::latitude_in_range(-30 as f64, 30 as f64); let data = address::longitude(); let data = address::longitude_in_range(-30 as f64, 30 as f64); }
animal (6 functions)
extern crate fakeit;
use fakeit::animal;
fn main() {
let data = animal::pet_name(); let data = animal::animal(); let data = animal::type_of(); let data = animal::farm(); let data = animal::cat(); let data = animal::dog(); }
beer (8 functions)
extern crate fakeit;
use fakeit::beer;
fn main() {
let data = beer::name(); let data = beer::style(); let data = beer::hop(); let data = beer::yeast(); let data = beer::malt(); let data = beer::ibu(); let data = beer::alcohol(); let data = beer::blg(); }
bool (1 functions)
extern crate fakeit;
use fakeit::bool;
fn main() {
let data = bool::bool(); }
color (4 functions)
extern crate fakeit;
use fakeit::color;
fn main() {
let data = color::full(); let data = color::hex(); let data = color::safe(); let data = color::rgb(); }
company (4 functions)
extern crate fakeit;
use fakeit::company;
fn main() {
let data = company::company(); let data = company::company_suffix(); let data = company::buzzword(); let data = company::bs(); }
contact (4 functions)
extern crate fakeit;
use fakeit::contact;
fn main() {
let data = contact::info(); let data = contact::phone(); let data = contact::phone_formatted(); let data = contact::email(); }
currency (4 functions)
extern crate fakeit;
use fakeit::currency;
fn main() {
let data = currency::compact(); let data = currency::short(); let data = currency::long(); let data = currency::price(1 as f64, 123 as f64); }
datetime (14 functions)
extern crate fakeit;
use fakeit::datetime;
fn main() {
let data = datetime::month(); let data = datetime::day(); let data = datetime::week_day(); let data = datetime::year(); let data = datetime::hour(); let data = datetime::minute(); let data = datetime::second(); let data = datetime::nanosecond(); let data = datetime::timezone(); let data = datetime::timezone_full(); let data = datetime::timezone_abv(); let data = datetime::timezone_offset(); let data = datetime::date_range("RFC3339", "RFC3339"); let data = datetime::date(); }
file (2 functions)
extern crate fakeit;
use fakeit::file;
fn main() {
let data = file::mime_type(); let data = file::extension(); }
generator (1 function)
extern crate fakeit;
use fakeit::generator;
fn main() {
let data = generator::generate("{person.first} {person.last} {contact.email} #?#?#?".to_string()); }
hacker (6 functions)
extern crate fakeit;
use fakeit::hacker;
fn main() {
let data = hacker::phrase(); let data = hacker::abbreviation(); let data = hacker::adjective(); let data = hacker::noun(); let data = hacker::verb(); let data = hacker::ingverb(); }
hipster (3 functions)
extern crate fakeit;
use fakeit::hipster;
fn main() {
let data = hipster::word(); let data = hipster::sentence(12); let data = hipster::paragraph(3, 4, 40, " ".to_string()); }
image (1 function)
extern crate fakeit;
use fakeit::image;
fn main() {
let data = image::url(500, 500); }
internet (7 functions)
extern crate fakeit;
use fakeit::internet;
fn main() {
let data = internet::domain_name(); let data = internet::http_method(); let data = internet::domain_suffix(); let data = internet::ipv4_address(); let data = internet::ipv6_address(); let data = internet::mac_address(); let data = internet::username(); }
job (4 functions)
extern crate fakeit;
use fakeit::job;
fn main() {
let data = job::info(); let data = job::title(); let data = job::descriptor(); let data = job::level(); }
language (3 functions)
extern crate fakeit;
use fakeit::language;
fn main() {
let data = language::random(); let data = language::abbreviation(); let data = language::programming(); }
log-level (3 functions)
extern crate fakeit;
use fakeit::log_level;
fn main() {
let data = log_level::general(); let data = log_level::syslog(); let data = log_level::apache(); }
name (5 functions)
extern crate fakeit;
use fakeit::name;
fn main() {
let data = name::full(); let data = name::first(); let data = name::last(); let data = name::prefix(); let data = name::suffix(); }
password (1 function)
extern crate fakeit;
use fakeit::password;
fn main() {
let data = password::generate(upper, numeric, special, num); }
payment (6 functions)
extern crate fakeit;
use fakeit::payment;
fn main() {
let data = payment::credit_card(); let data = payment::credit_card_type(); let data = payment::credit_card_number(); let data = payment::credit_card_luhn_number(); let data = payment::credit_card_exp(); let data = payment::credit_card_cvv(); }
person (3 functions)
extern crate fakeit;
use fakeit::person;
fn main() {
let data = person::info(); let data = person::ssn(); let data = person::gender(); }
status code (2 functions)
extern crate fakeit;
use fakeit::status_code;
fn main() {
let data = status_code::simple(); let data = status_code::general(); }
unique (2 functions)
extern crate fakeit;
use fakeit::unique;
fn main() {
let data = unique::uuid_v1(); let data = unique::uuid_v4(); }
user agent (8 functions)
extern crate fakeit;
use fakeit::user_agent;
fn main() {
let data = user_agent::chrome(); let data = user_agent::firefox(); let data = user_agent::safari(); let data = user_agent::opera(); let data = user_agent::linux_platform_token(); let data = user_agent::mac_platform_token(); let data = user_agent::windows_platform_token(); let data = user_agent::random_platform(); }
vehicle (6 functions)
extern crate fakeit;
use fakeit::vehicle;
fn main() {
let data = vehicle::info(); let data = vehicle::vehicle_type(); let data = vehicle::fuel(); let data = vehicle::transmission_gear(); let data = vehicle::car_maker(); let data = vehicle::car_model(); }
words (6 functions)
extern crate fakeit;
use fakeit::words;
fn main() {
let data = words::word(); let data = words::sentence(word_count); let data = words::paragraph(count, sentence_count, word_count, separator); let data = words::question(); let data = words::quote();
let opts = words::ParagraphOpts {
count: 5,
sentence_count: 4,
word_count: 11,
separator: "\n".to_string(),
};
let data = words::paragraph_generator(opts, &words::sentence); }