norris-jokes

Crates.ionorris-jokes
lib.rsnorris-jokes
version0.2.0
sourcesrc
created_at2024-06-18 22:25:41.111207
updated_at2024-06-19 21:14:19.381467
descriptionChuck Norris jokes API sync & async fetcher library for Rust applications
homepagehttps://github.com/skewnart/norris-jokes-api
repositoryhttps://github.com/skewnart/norris-jokes-api
max_upload_size
id1276260
size12,901
Corentin Z. (Skewnart)

documentation

README

Norris Jokes API

Chuck Norris jokes API sync & async fetcher library for Rust applications

Usage

Usage for synchronous calls

use norris_jokes::jokecategory::JokeCategory;

fn main() {
    let mut result = norris_jokes::get_random();
    println!("{:?}", result);
    
    result = norris_jokes::get_random_with_category(JokeCategory::Sport);
    println!("{:?}", result);
    
    let result_list = norris_jokes::get_with_query("sport");
    println!("{:?}", result_list);
}

Usage for asynchronous calls

use norris_jokes::jokecategory::JokeCategory;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut joke = norris_jokes::get_random_async().await;
    println!("{:?}", joke);
    
    joke = norris_jokes::get_random_with_category_async(JokeCategory::Sport).await;
    println!("{:?}", joke);
    
    let result_list = norris_jokes::get_with_query_async("sport").await;
    println!("{:?}", result_list);

    Ok(())
}
Commit count: 31

cargo fmt