Trait kitsu::bridge::reqwest::KitsuRequester [] [src]

pub trait KitsuRequester {
    fn get_anime(&self, id: u64) -> Result<Response<Anime>>;
fn get_character(&self, id: u64) -> Result<Response<Character>>;
fn get_manga(&self, id: u64) -> Result<Response<Manga>>;
fn get_producer(&self, id: u64) -> Result<Response<Producer>>;
fn get_user(&self, id: u64) -> Result<Response<User>>;
fn search_anime<F: FnOnce(Search) -> Search>(
        &self,
        f: F
    ) -> Result<Response<Vec<Anime>>>;
fn search_characters<F: FnOnce(Search) -> Search>(
        &self,
        f: F
    ) -> Result<Response<Vec<Character>>>;
fn search_manga<F: FnOnce(Search) -> Search>(
        &self,
        f: F
    ) -> Result<Response<Vec<Manga>>>;
fn search_users<F: FnOnce(Search) -> Search>(
        &self,
        f: F
    ) -> Result<Response<Vec<User>>>; }

Trait which defines the methods necessary to interact with the service.

Examples

To bring in the implemenation for the reqwest Client, simply use the trait:

use kitsu::KitsuReqwestRequester;

At this point, the methods will be on your Reqwest Client.

Required Methods

Gets an anime using its id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let anime_id = 1;

    // Get the anime.
    let anime = client.get_anime(anime_id)
        .expect("Error getting anime");

    // Do something with anime
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Gets a character using its id.

Gets a manga using its id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let manga_id = 1;

    // Get the manga.
    let manga = client.get_anime(manga_id)
        .expect("Error getting manga");

    // Do something with manga
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Gets a producer using its id

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let producer_id = 1;

    // Get the anime.
    let anime = client.get_producer(producer_id)
        .expect("Error getting producer");

    // Do something with producer
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Gets a user using their id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let user_id = 1;

    // Get the user.
    let user = client.get_anime(user_id)
        .expect("Error getting user");

    // Do something with user
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Gets an anime using its id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let anime_name = "Your Lie in April";

    // Search for the anime.
    let anime = client.search_anime(|f| f.filter("text", anime_name))
        .expect("Error searching for anime");

    // Do something with anime
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Searches for a character.

Gets an anime using its id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let manga_name = "Say I Love You";

    // Search for the manga.
    let manga = client.search_manga(|f| f.filter("text", manga_name))
        .expect("Error getting manga");

    // Do something with manga
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Gets an anime using its id.

Examples

extern crate kitsu;
extern crate reqwest;

use kitsu::KitsuReqwestRequester;
use reqwest::Client;

fn main() {
    // Create the reqwest Client.
    let client = Client::new();

    let user_name = "Billy";

    // Search for the user.
    let user = client.search_users(|f| f.filter("name", user_name))
        .expect("Error searching for user");

    // Do something with users
}

Errors

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

Returns Error::ReqwestBad if the request was otherwise bad for some reason, containing the response.

Returns Error::ReqwestInvalid if the response was a non-OK (status code 200) response, containing the response.

Returns Error::ReqwestParse if there was an error parsing the image parameters into a valid URL.

Returns Error::ReqwestUnauthorized if the authorization token was invalid.

Implementations on Foreign Types

impl KitsuRequester for ReqwestClient
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors