Skip to content

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

License

Notifications You must be signed in to change notification settings

Skewnart/norris-jokes-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages