Struct dagpirs::data::Data[][src]

pub struct Data { /* fields omitted */ }
Expand description

Data fetching functions for async client.

Implementations

get a hot fiery roast Basic Data endpoint might return a custom struct

Example

use dagpirs::{Client, models::Roast};
use tokio;
#[tokio::main]
async fn main() {
    let token = std::env::var("DAGPI_TOKEN").unwrap();
    let c = Client::new(&token).unwrap();
    if let Ok(i) = c.data.roast().await {
        match i {
            Ok(r) => {
                println!("{}", r.roast);
        },
            Err(e) => panic!("{}", e)    
        }
    }
}

get a random joke

get a random flag!

get a random WTP object A more complex Struct with lots of field is like the WTP

Example

use dagpirs::{Client, models::WTP};
use tokio;
#[tokio::main]
async fn main() {
    let token = std::env::var("DAGPI_TOKEN").unwrap();
    let c = Client::new(&token).unwrap();
    if let Ok(i) = c.data.wtp().await {
        match i {
            Ok(r) => {
                println!("question: {}\nanswer: {}\nname: {}\nid: {}", r.question, r.answer, r.Data.name, r.Data.id);
        },
            Err(e) => panic!("{}", e)    
        }
    }
}

get a random headline. Can be fake or real

Get a random logo

Get an Easy Logo

Pickup Line

Random Fact

Yomama Joke

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.