Struct mal::list::List [] [src]

pub struct List<'a, E: ListEntry> {
    pub mal: &'a MAL<'a>,
    // some fields omitted
}

This struct allows you to add, update, delete, and read entries to / from a user's list, as well as search for an anime / manga series.

The E type parameter dictates what type of list is will be modified when performing operations.

Examples

use mal::MAL;
use mal::list::{List, Status};
use mal::list::anime::{AnimeEntry, AnimeValues};

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Create a new List that will operate on a user's anime list.
// (note that you can also just call mal.anime_list() here, which does the same thing)
let anime_list = List::<AnimeEntry>::new(&mal);

// Create new anime entry values
let mut values = AnimeValues::new();

// Set the watched episode count to 25, and status to completed
values.set_watched_episodes(25)
      .set_status(Status::Completed);

// Add the anime with ID 4224 (Toradora) to a user's anime list with the values set above
anime_list.add_id(4224, &mut values).unwrap();

Fields

A reference to the MAL instance used to perform operations on a user's list.

Methods

impl<'a, E: ListEntry> List<'a, E>
[src]

[src]

Creates a new List instance for performing operations on a user's list.

[src]

Searches MyAnimeList for the type of series defined by the List instance and returns all found results.

Examples

use mal::MAL;

let mal = MAL::new("username", "password");

// Search for the anime series "Cowboy Bebop"
let found_anime = mal.anime_list().search_for("Cowboy Bebop").unwrap();

// Search for the manga series "Bleach"
let found_manga = mal.manga_list().search_for("Bleach").unwrap();

[src]

Requests and parses all entries on a user's list.

Examples

use mal::MAL;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Read the user's anime list
let list = mal.anime_list().read().unwrap();

println!("{:?}", list.user_info);
println!("{:?}", list.entries);

[src]

Adds an entry to a user's list.

If the entry is already on a user's list, nothing will happen.

Examples

use mal::MAL;
use mal::list::Status;
use mal::list::anime::AnimeEntry;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Search for "Toradora" on MyAnimeList
let mut search_results = mal.anime_list().search_for("Toradora").unwrap();

// Use the first result's info
let toradora_info = search_results.swap_remove(0);

// Create a new anime list entry with Toradora's info
let mut entry = AnimeEntry::new(toradora_info);

// Set the entry's watched episodes to 5 and status to watching
entry.values
     .set_watched_episodes(5)
     .set_status(Status::WatchingOrReading);

// Add the entry to the user's anime list
mal.anime_list().add(&mut entry).unwrap();

[src]

Adds an entry to a user's list by id.

If the entry is already on a user's list, nothing will happen.

Examples

use mal::MAL;
use mal::list::Status;
use mal::list::anime::AnimeValues;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Create new entry values
let mut values = AnimeValues::new();

// Set the number of watched episodes to 5 and the status to watching
values.set_watched_episodes(5)
      .set_status(Status::WatchingOrReading);

// Add an entry with an id of 4224 (Toradora) to the user's anime list
mal.anime_list().add_id(4224, &mut values).unwrap();

[src]

Updates an entry on a user's list.

If the entry is already on a user's list, nothing will happen.

Examples

use mal::MAL;
use mal::list::Status;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Get a handle to the user's anime list
let anime_list = mal.anime_list();

// Read the user's anime list
let list = anime_list.read().unwrap();

// Find Toradora in the list entries
let mut toradora = list
    .entries
    .into_iter()
    .find(|e| e.series_info.id == 4224).unwrap();

// Set new values for the list entry
// In this case, the episode count will be updated to 25, the score will be set to 10, and the status will be set to completed
toradora.values
        .set_watched_episodes(25)
        .set_score(10)
        .set_status(Status::Completed);

// Update the anime on the user's list
anime_list.update(&mut toradora).unwrap();

[src]

Updates an entry on a user's list by id.

If the entry is already on the user's list, nothing will happen.

Examples

use mal::MAL;
use mal::list::Status;
use mal::list::anime::AnimeValues;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Create new entry values
let mut values = AnimeValues::new();

// Set the number of watched episodes to 25, score to 10, and status to completed
values.set_watched_episodes(25)
      .set_score(10)
      .set_status(Status::Completed);

// Update the entry with an id of 4224 (Toradora) on the user's anime list
mal.anime_list().update_id(4224, &mut values).unwrap();

[src]

Removes an entry from a user's list.

If the entry isn't already on a user's list, nothing will happen.

Examples

use mal::MAL;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Search for "Toradora" on MyAnimeList
let mut search_results = mal.anime_list().search_for("Toradora").unwrap();

// Use the first result's info
let toradora_info = search_results.swap_remove(0);

// Get a handle to the user's anime list
let anime_list = mal.anime_list();

// Read the user's anime list
let list = anime_list.read().unwrap();

// Find Toradora in the list entries
let toradora = list
    .entries
    .into_iter()
    .find(|e| e.series_info.id == 4224).unwrap();

// Delete Toradora from the user's anime list
anime_list.delete(&toradora).unwrap();

[src]

Removes an entry from a user's list by its id.

If the entry isn't already on a user's list, nothing will happen.

Examples

use mal::MAL;

// Create a new MAL instance
let mal = MAL::new("username", "password");

// Delete the anime with the id of 4224 (Toradora) from the user's anime list
mal.anime_list().delete_id(4224).unwrap();

Trait Implementations

impl<'a, E: Debug + ListEntry> Debug for List<'a, E>
[src]

[src]

Formats the value using the given formatter. Read more

impl<'a, E: Clone + ListEntry> Clone for List<'a, E>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, E: Copy + ListEntry> Copy for List<'a, E>
[src]

Auto Trait Implementations

impl<'a, E> Send for List<'a, E> where
    E: Send

impl<'a, E> Sync for List<'a, E> where
    E: Sync