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 functions which haven’t been implemented yet
Example
use lib_mal::MALClient; let client = MALClient::init("[YOUR_SECRET_HERE]", false, None).await; //--do authorization stuff before accessing the functions--// //Gets the details with all fields for Mobile Suit Gundam let anime = client.get_anime_details(80, None).await?; //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: boolImplementations
Creates the client and fetches the MAL tokens from the cache if available. If caching is
false 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
Creates a client using provided token. Caching is disable by default.
A client created this way can’t authenticate the user if needed because it lacks a
client_secret
Sets the directory the client will use for the token cache
Sets wether the client will cache or not
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 mut client = MALClient::init("[YOUR_SECRET_HERE]", false, None).await;
let (url, challenge, state) = client.get_auth_parts();
println!("Go here to log in: {}", url);
client.auth(&redirect_uri, &challenge, &state).await?;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 mut client = MALClient::init("[YOUR_SECRET_HERE]", false, None).await;
let (url, challenge, state) = client.get_auth_parts();
println!("Go here to log in: {}", url);
client.auth(&redirect_uri, &challenge, &state).await?;
Returns the current access token. Intended mostly for debugging.
Gets a list of anime based on the query string provided
limit defaults to 100 if None
pub async fn get_anime_details<T: Into<Option<AnimeFields>>>(
&self,
id: u32,
fields: T
) -> Result<AnimeDetails, MALError>
pub async fn get_anime_details<T: Into<Option<AnimeFields>>>(
&self,
id: u32,
fields: T
) -> Result<AnimeDetails, MALError>
Gets the details for an anime by the show’s ID.
Only returns the fields specified in the fields parameter
Returns all fields when supplied None
Example
use lib_mal::model::fields::AnimeFields; //returns an AnimeDetails struct with just the Rank, Mean, and Studio data for Mobile Suit Gundam let res = client.get_anime_details(80, AnimeFields::Rank | AnimeFields::Mean | AnimeFields::Studios).await?;
pub async fn get_anime_ranking(
&self,
ranking_type: RankingType,
limit: Option<u8>
) -> Result<AnimeList, MALError>
pub async fn get_anime_ranking(
&self,
ranking_type: RankingType,
limit: Option<u8>
) -> Result<AnimeList, MALError>
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.
pub async fn update_user_anime_status<T: Params>(
&self,
id: u32,
update: T
) -> Result<ListStatus, MALError>
pub async fn update_user_anime_status<T: Params>(
&self,
id: u32,
update: T
) -> Result<ListStatus, MALError>
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.
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
pub async fn get_forum_topic_detail(
&self,
topic_id: u32,
limit: Option<u8>
) -> Result<TopicDetails, MALError>
pub async fn get_forum_topic_detail(
&self,
topic_id: u32,
limit: Option<u8>
) -> Result<TopicDetails, MALError>
Returns details of the specified topic
Returns all topics for a given query
Gets the details for the current user