Crate norris_jokes

Crate norris_jokes 

Source
Expand description

§Norris Jokes API

latest version build status dependency status downloads docs license

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(())
}

Modules§

joke
jokecategory
norriserror

Functions§

get_random
get_random_async
get_random_with_category
get_random_with_category_async
get_with_query
get_with_query_async