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]
self,
term: String,
pagination_opts: PaginationOpts
) -> Result<PaginatedData<PaginatedJoke>, Box<dyn Error>>
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
impl !RefUnwindSafe for DadJokeSDK
impl Send for DadJokeSDK
impl Sync for DadJokeSDK
impl Unpin for DadJokeSDK
impl !UnwindSafe for DadJokeSDK
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,