[][src]Struct urbandictionary::Client

pub struct Client(_);

Methods

impl Client[src]

pub fn new(http_client: impl Into<Arc<HttpClient>>) -> Self[src]

Create a new UrbanDictionary client.

Examples

use reqwest::Client as HttpClient;
use urbandictionary::Client;

let http_client = HttpClient::new();
let urban_client = Client::new(http_client);

pub async fn define<'_, '_>(
    &'_ self,
    word: &'_ str
) -> Result<Option<Definition>>
[src]

Attempt to retrieve the first definition for a word.

Examples

Retrieve the definition of the word "cat":

use reqwest::Client as HttpClient;
use urbandictionary::Client;

let http_client = HttpClient::new();
let client = Client::new(http_client);
let response = client.define("cat").await?;

if let Some(definition) = response {
    println!("The definition of cat is: {}", definition.definition);
} else {
    println!("No definition found");
}

pub async fn definitions<'_, '_>(&'_ self, word: &'_ str) -> Result<Response>[src]

Attempt to retrieve the definitions for a word.

Examples

Retrieve the definitions for the word "cat":

use reqwest::Client as HttpClient;
use urbandictionary::Client;

let http_client = HttpClient::new();
let client = Client::new(http_client);

let response = client.definitions("cat").await?;

if let Some(definition) = response.definitions.first() {
    println!(
        "The first definition of cat is: {}",
        definition.definition,
    );
} else {
    println!("No definitions found");
}

Auto Trait Implementations

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

impl !RefUnwindSafe for Client

Blanket Implementations

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

impl<T> From<T> for 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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