Trait urbandictionary::bridge::reqwest::UrbanDictionaryRequester[][src]

pub trait UrbanDictionaryRequester {
    fn define(&self, word: &str) -> Result<Option<Definition>>;
fn definitions(&self, word: &str) -> Result<Response>; }

Trait implemented on Reqwest's client for interaction with the UrbanDictionary API.

Required Methods

Attempt to retrieve the first Definition for a word.

Examples

Retrieve the definition of the word "cat":

extern crate reqwest;
extern crate urbandictionary;

use reqwest::Client;
use urbandictionary::ReqwestUrbanDictionaryRequester;

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

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

Errors

Returns Error::Json if there was an error deserializing the response body.

Returns Error::Reqwest if there was an error sending the request.

Attempt to retrieve the definitions for a word.

Examples

Retrieve the definitions for the word "cat":

extern crate reqwest;
extern crate urbandictionary;

use reqwest::Client;
use urbandictionary::ReqwestUrbanDictionaryRequester;

let client = Client::new();
let response = client.definitions("cat")?;

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

Errors

Returns Error::Json if there was an error deserializing the response body.

Returns Error::Reqwest if there was an error sending the request.

Implementations on Foreign Types

impl UrbanDictionaryRequester for Client
[src]

Attempt to retrieve the first Definition for a word.

Attempt to retrieve the definitions for a word.

Implementors