Struct lib_mal::MALClient [−][src]
pub struct MALClient {
pub need_auth: bool,
// some fields omitted
}Fields
need_auth: boolImplementations
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
use lib_mal::MALClient; use tokio #[tokio::main] async fn main() { let redirect_uri = [YOUR_REDIRECT_URI_HERE]; 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"); //Auth will open an http server on port 2561 to listen for the OAuth2 callback }
Listens for the OAuth2 callback from MAL on callback_url, which is the callback url
registered when obtaining the API token from MAL. Only applications with a single registered
URL are supported at the moment.
#[tokio::main] async fn main() { let redirect_uri = [YOUR_REDIRECT_URI_HERE]; 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"); //Auth will open an http server on port 2561 to listen for the OAuth2 callback }
Gets a list of anime based on the query string provided
limit defaults to 100 if None
pub async fn get_anime_details(
&self,
id: &u32,
fields: Option<Vec<AnimeField>>
) -> Result<AnimeDetails, String>
pub async fn get_anime_details(
&self,
id: &u32,
fields: Option<Vec<AnimeField>>
) -> Result<AnimeDetails, String>
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
pub async fn get_anime_ranking(
&self,
ranking_type: RankingType,
limit: Option<u8>
) -> Result<AnimeList, String>
pub async fn get_anime_ranking(
&self,
ranking_type: RankingType,
limit: Option<u8>
) -> Result<AnimeList, String>
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, String>
pub async fn update_user_anime_status<T: Params>(
&self,
id: u32,
update: T
) -> Result<ListStatus, String>
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