random_user

Crates.iorandom_user
lib.rsrandom_user
version0.3.2
sourcesrc
created_at2023-07-19 16:17:40.26286
updated_at2023-07-21 14:04:45.120757
descriptionRandom user generator using the api from
homepage
repositoryhttps://github.com/jilchab/random_user
max_upload_size
id920516
size47,689
Jil C (jilchab)

documentation

README

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);
}
Commit count: 16

cargo fmt