Struct icanhazdadjoke_sdk::DadJokeSDK[][src]

pub struct DadJokeSDK { /* fields omitted */ }

The structure used for manipulating the ianhazdadjoke API.

Internally, this manages the Hyper Client (for requests) and the User-Agent.

Examples

use icanhazdadjoke_sdk::DadJokeSDK;
let dad_joke_sdk = DadJokeSDK::default(); // uses default user agent

Implementations

impl DadJokeSDK[src]

pub fn new(user_agent: String) -> Self[src]

Initializes the dad joke sdk with the given User-Agent that is sent with requests.

pub async fn get_joke(self, id: String) -> Result<Joke, Box<dyn Error>>[src]

Gets a single joke by its given String id from the API.

Examples

use icanhazdadjoke_sdk::DadJokeSDK;
let dad_joke_sdk = DadJokeSDK::default();
dad_joke_sdk.get_joke("0189hNRf2g".into()).await;

pub async fn get_random_joke(self) -> Result<Joke, Box<dyn Error>>[src]

Gets a random joke from the API.

Examples

use icanhazdadjoke_sdk::DadJokeSDK;
let dad_joke_sdk = DadJokeSDK::default();
dad_joke_sdk.get_random_joke().await;

pub async fn query_jokes(
    self,
    term: String,
    pagination_opts: PaginationOpts
) -> Result<PaginatedData<PaginatedJoke>, Box<dyn Error>>
[src]

Searches for jokes that match the given String term and customizes the result pages based upon the PaginationOpts pagination options.

Trait Implementations

impl Debug for DadJokeSDK[src]

impl Default for DadJokeSDK[src]

Auto Trait Implementations

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, 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.