Struct lib_mal::MALClient[][src]

pub struct MALClient {
    pub need_auth: bool,
    // some fields omitted
}
Expand description

Exposes all of the API functions for the MyAnimeList API

With the exception of all the manga-related funcitons which haven’t been implemented yet

Example

 use lib_mal::MALClient;
 let client = MALClient::new([YOUR_SECRET_HERE]).await;
 //--do authorization stuff before accessing the funcitons--//

 //Gets the details with all fields for Mobile Suit Gundam
 let anime = client.get_anime_details(80, None).await.expect("Couldn't get anime details");
 //You should actually handle the potential error
 println!("Title: {} | Started airing: {} | Finished airing: {}",
     anime.show.title,
     anime.start_date.unwrap(),
     anime.end_date.unwrap());

Fields

need_auth: bool

Implementations

Creates the client and fetches the MAL tokens from the cache if available. If caching is fasle or cache_dir is None the user will have to log in at the start of every session.

When created client will attempt to refresh the access_token if it has expired

Returns the auth URL and code challenge which will be needed to authorize the user.

Example

     use lib_mal::MALClient;

     let redirect_uri = "http://localhost:2525";//<-- example uri
     let client = MALClient::new([YOUR_SECRET_HERE]).await;
     let (url, challenge, state) = client.get_auth_parts();
     println!("Go here to log in: {}", url);
     client.auth(&redirect_uri, &challenge, &state).await.expect("Unable to log in");

Listens for the OAuth2 callback from MAL on callback_url, which is the redirect_uri registered when obtaining the API token from MAL. Only HTTP URIs are supported right now.

For now only applications with a single registered URI are supported, having more than one seems to cause issues with the MAL api itself

Example

     use lib_mal::MALClient;

     let redirect_uri = "localhost:2525";//<-- example uri,
     //appears as "http://localhost:2525" in the API settings
     let client = MALClient::new([YOUR_SECRET_HERE]).await;
     let (url, challenge, state) = client.get_auth_parts(&redirect_uri);
     println!("Go here to log in: {}", url);
     client.auth(&redirect_uri, &challenge, &state).await.expect("Unable to log in");

Gets a list of anime based on the query string provided limit defaults to 100 if None

Gets the deatils for an anime by the show’s ID. Only returns the fields specified in the fields parameter

Returns all fields when supplied None

Gets a list of anime ranked by RankingType

limit defaults to the max of 100 when None

Gets the anime for a given season in a given year

limit defaults to the max of 100 when None

Returns the suggested anime for the current user. Can return an empty list if the user has no suggestions.

Adds an anime to the list, or updates the element if it already exists

Returns the user’s full anime list as an AnimeList struct. If the request fails for any reason, an Err object with a string describing the error is returned instead

Deletes the anime with id from the user’s anime list

Returns 404 if the id isn’t in the list.

Returns a vector of HashMaps that represent all the forum boards on MAL

Gets the details for the current user

fields defaults to anime_statistics if None

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.