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

pub struct Data { /* fields omitted */ }

Data fetching functions for async client.

Implementations

impl Data[src]

pub async fn roast(&self) -> HttpResult<Roast, String>[src]

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

pub async fn joke(&self) -> HttpResult<Joke, String>[src]

get a random joke

pub async fn flag(&self) -> HttpResult<Flag, String>[src]

get a random flag!

pub async fn wtp(&self) -> HttpResult<WTP, String>[src]

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

pub async fn headline(&self) -> HttpResult<Headline, String>[src]

get a random headline. Can be fake or real

Get a random logo

Get an Easy Logo

pub async fn pickup_line(&self) -> HttpResult<PickupLine, String>[src]

Pickup Line

pub async fn fact(&self) -> HttpResult<Fact, String>[src]

Random Fact

pub async fn yomama(&self) -> HttpResult<YomamaJoke, String>[src]

Yomama Joke

Auto Trait Implementations

impl !RefUnwindSafe for Data

impl Send for Data

impl Sync for Data

impl Unpin for Data

impl !UnwindSafe for Data

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithSubscriber for T[src]