Module toornament::iter [] [src]

This module introduces iterator-like interface to the toornament. The content of this module is not really an iterator, it just may look so. It was made to provide an easy and rust-idiomatic way to interact with the service. Note that everything here is "lazy". Think of it as you use an iterator over remote data.

Usage

Delete a participant:

use toornament::*;

let toornament = Toornament::with_application("API_TOKEN",
                                              "CLIENT_ID",
                                              "CLIENT_SECRET").unwrap();
toornament.tournaments_iter()
          .with_id(TournamentId("1".to_owned()))
          .participants()
          .with_id(ParticipantId("2".to_owned()))
          .delete();

Iterate over tournaments and some other actions:

use toornament::*;

let toornament = Toornament::with_application("API_TOKEN",
                                              "CLIENT_ID",
                                              "CLIENT_SECRET").unwrap();

let all = toornament.tournaments_iter().all().collect::<Tournaments>().unwrap();
let my = toornament.tournaments_iter().my().collect::<Tournaments>().unwrap();
let tournament_with_id_1 = toornament.tournaments_iter()
                                     .with_id(TournamentId("1".to_owned()))
                                     .collect::<Tournament>().unwrap();
// Edit tournament with id = 1
let edit_result = toornament.tournaments_iter()
                            .with_id(TournamentId("1".to_owned()))
                            .edit(|t| t.name("New name"))
                            .update();
// Delete tournament with id = 1
let delete_result = toornament.tournaments_iter()
                              .with_id(TournamentId("1".to_owned()))
                              .delete();
// Get tournament's permissions
let permissions = toornament.tournaments_iter()
                            .with_id(TournamentId("1".to_owned()))
                            .permissions()
                            .collect::<Permissions>();
// Get tournament's participants
let participants = toornament.tournaments_iter()
                             .with_id(TournamentId("1".to_owned()))
                             .participants()
                             .collect::<Participants>();
// Edit tournament's match
let edited_match = toornament.tournaments_iter()
                             .with_id(TournamentId("1".to_owned()))
                             .matches()
                             .with_id(MatchId("2".to_owned()))
                             .edit(|m| m.number(2))
                             .update();
// Get match result
let match_result = toornament.tournaments_iter()
                             .with_id(TournamentId("1".to_owned()))
                             .matches()
                             .with_id(MatchId("2".to_owned()))
                             .result()
                             .collect::<MatchResult>();
// Get match game result
let game_result = toornament.tournaments_iter()
                            .with_id(TournamentId("1".to_owned()))
                            .matches()
                            .with_id(MatchId("2".to_owned()))
                            .games()
                            .with_number(GameNumber(3i64))
                            .result()
                            .collect::<MatchResult>();

Note that iter-like interface is lazy - no action is done before you actually do something. So, the finish states are usually a modifier of an iterator (like matches() of TournamentIter) or a collect() methods.

Structs

DisciplineIter

Discipline iterator

DisciplineMatchesIter

A discipline matches iterator

DisciplinesIter

Disciplines iterator

GameEditor

A lazy game result editor

GameIter

A match game iterator

GameResultEditor

A lazy game result editor

GameResultIter

A match game result iterator

GamesIter

A match games iterator

ParticipantCreator

A lazy participant creator

ParticipantEditor

A lazy participant editor

ParticipantIter

A remote participant iterator

ParticipantsEditor

A lazy participants editor

ParticipantsIter

A remote participants iterator

PermissionAttributesEditor

A lazy permission attributes editor

PermissionAttributesIter

A permission attributes iterator

PermissionCreator

A lazy permission creator

PermissionIter

Tournament permission iterator

PermissionsIter

Tournament permissions iterator

StagesIter

Tournament stages iterator

TournamentCreator

A lazy tournament creator

TournamentEditor

A lazy tournament editor

TournamentIter

A remote tournament iterator

TournamentMatchEditor

A lazy tournament match editor

TournamentMatchIter

A tournament match iterator

TournamentMatchResultEditor

A lazy match result editor

TournamentMatchResultIter

A tournament match result iterator

TournamentMatchesIter

A tournament matches iterator

TournamentsIter

A remote iterator over tournaments

VideosIter

Tournament videos iterator