#user #random #generator #api

random_user

Random user generator using the api from https://randomuser.me

5 unstable releases

0.3.2 Jul 21, 2023
0.3.1 Jul 19, 2023
0.3.0 Jul 19, 2023
0.2.0 Jul 19, 2023
0.1.0 Jul 19, 2023

#360 in #random

28 downloads per month

MIT license

15KB
276 lines

random_user

This library provides a convenient random user generator using the api from https://randomuser.me Built with reqwest and using async.

Examples

Generate one random user:

use random_user::UserGenerator;
#[tokio::main]
async fn main() {
    let generator = UserGenerator::new();
    let user = generator
        .fetch_one()
        .await
        .expect("Error fetching random user");
    println!("{:#?}", user);
}

Generate multiple random users with filters:

let generator = UserGenerator::new();
// Get 5 Australian women with complex passwords
let users = generator
    .get()
    .gender(Gender::Female)
    .nationality(Nationality::Australian)
    .password("upper,lower,special,12-24")
    .fetch(5)
    .await?
for user in users {
    println!("Name: {}, Password: {}", user.name.first, user.login.password);
}

lib.rs:

This library provides a convenient random user generator using the api from https://randomuser.me

Built with reqwest and using async.

Examples

Generate one random user:


let generator = UserGenerator::new();

let user = generator.fetch_one().await?;

println!("{user:#?}");

Generate multiple random users with filters:


let generator = UserGenerator::new();
// Get 5 Austrialian women with complex passwords
let users = generator
    .get()
    .gender(Gender::Female)
    .nationality(Nationality::Australian)
    .password("upper,lower,special,12-24")
    .fetch(5)
    .await?;

for user in users {
    println!("Name: {}, Password: {}", user.name.first, user.login.password);
}

Dependencies

~5–18MB
~239K SLoC