Struct mal_api::anime::api::AnimeApiClient
source · pub struct AnimeApiClient<State = None> { /* private fields */ }
Expand description
The AnimeApiClient provides functions for interacting with the various
anime
and user animelist
MAL API endpoints. The accessible endpoints
vary depending on if the AnimeApiClient was constructed from a
MalClientId or an OauthClient.
Keep in mind that constructing an AnimeApiClient from an OauthClient provides more access to the MAL API than from a MalClientId. Check the MAL API documentation to view which endpoints require an OauthClient versus a MalClientId to see which one is most appropriate for your use case.
§Example
use dotenvy;
use mal_api::oauth::MalClientId;
use mal_api::prelude::*;
#[tokio::main]
async fn main() {
dotenvy::dotenv().ok();
let client_id = MalClientId::from_env().unwrap();
let api_client = AnimeApiClient::from(&client_id);
let common_fields = mal_api::anime::all_common_fields();
let detail_fields = mal_api::anime::all_detail_fields();
// Using the builder pattern for building the query
let query = GetAnimeList::builder("One Piece")
.fields(&common_fields)
.build()
.unwrap();
let response = api_client.get_anime_list(&query).await;
if let Ok(response) = response {
println!("Received response: {}\n", response);
for entry in response.data.iter() {
println!("Id: {}", entry.node.id);
}
}
let query = GetAnimeDetails::builder(9969)
.fields(&detail_fields)
.build()
.unwrap();
let response = api_client.get_anime_details(&query).await;
if let Ok(response) = response {
println!("Received response: {}\n", response);
}
}
Implementations§
source§impl AnimeApiClient<Client>
impl AnimeApiClient<Client>
sourcepub async fn get_user_anime_list(
&self,
query: &GetUserAnimeList
) -> Result<AnimeList, AnimeApiError>
pub async fn get_user_anime_list( &self, query: &GetUserAnimeList ) -> Result<AnimeList, AnimeApiError>
Get a users anime list
You cannot get the anime list of @me
with a ClientId AnimeApiClient
Corresponds to the Get user anime list endpoint
source§impl AnimeApiClient<Oauth>
impl AnimeApiClient<Oauth>
sourcepub async fn get_suggested_anime(
&self,
query: &GetSuggestedAnime
) -> Result<SuggestedAnime, AnimeApiError>
pub async fn get_suggested_anime( &self, query: &GetSuggestedAnime ) -> Result<SuggestedAnime, AnimeApiError>
Get a list of suggested anime
Corresponds to the Get suggested anime endpoint
sourcepub async fn get_user_anime_list(
&self,
query: &GetUserAnimeList
) -> Result<AnimeList, AnimeApiError>
pub async fn get_user_anime_list( &self, query: &GetUserAnimeList ) -> Result<AnimeList, AnimeApiError>
Get a users Anime list
You can get the anime list of @me
with an OauthClient AnimeApiClient
Corresponds to the Get user anime list endpoint
sourcepub async fn update_anime_list_status(
&self,
query: &UpdateMyAnimeListStatus
) -> Result<AnimeListStatus, AnimeApiError>
pub async fn update_anime_list_status( &self, query: &UpdateMyAnimeListStatus ) -> Result<AnimeListStatus, AnimeApiError>
Update the status of an anime for the OAuth user’s anime list
Corresponds to the Update my anime list status endpoint
sourcepub async fn delete_anime_list_item(
&self,
query: &DeleteMyAnimeListItem
) -> Result<(), AnimeApiError>
pub async fn delete_anime_list_item( &self, query: &DeleteMyAnimeListItem ) -> Result<(), AnimeApiError>
Delete an anime entry from the OAuth user’s anime list
Corresponds to the Delete my anime list item endpoint
Trait Implementations§
source§impl<State: Clone> Clone for AnimeApiClient<State>
impl<State: Clone> Clone for AnimeApiClient<State>
source§fn clone(&self) -> AnimeApiClient<State>
fn clone(&self) -> AnimeApiClient<State>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more