Skip to content

Commit

Permalink
- Fixing some stuff so that earlier versions of Rust will still compile
Browse files Browse the repository at this point in the history
- added #[must_use] so that callers get warned about using the api without doing anything with the functions
- Added rust 1.27.0+ to the build and test matrices on travis
  • Loading branch information
Sunspar committed Nov 11, 2018
1 parent a6a3283 commit da43f63
Show file tree
Hide file tree
Showing 47 changed files with 304 additions and 287 deletions.
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
language: rust

cache: cargo

os:
- linux
- osx

- windows
rust:
- stable
- beta
- nightly


- 1.29.2
- 1.29.1
- 1.29.0
- 1.28.0
- 1.27.2
- 1.27.1
- 1.27.0
script:
- cargo test --verbose --all

matrix:
fast_finish: true
allow_failures:
- rust: nightly
- rust: nightly
- os: osx
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description = "A Rust library for the Guild Wars 2 API."
keywords = ["guildwars2", "gw2", "api"]
name = "gw2rs"
version = "0.1.0"
edition = "2015"
license = "Apache-2.0/MIT"
repository = "https://github.com/sunspar/gw2rs"
maintenance = { status = "actively-developed" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GW2 RS
[![Build Status](https://travis-ci.org/Sunspar/gw2rs.svg?branch=master)](https://travis-ci.org/Sunspar/gw2rs)[![Build status](https://ci.appveyor.com/api/projects/status/hou7p7nlae6a7rmk/branch/master?svg=true)](https://ci.appveyor.com/project/Sunspar/gw2rs/branch/master)
[![Build Status](https://travis-ci.org/Sunspar/gw2rs.svg?branch=master)](https://travis-ci.org/Sunspar/gw2rs)

GW2RS is an api wrapper around the ArenaNet Guild Wars 2 API, for Rust.

Expand Down
7 changes: 6 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ Endpoints as presented from https://api.guildwars2.com/v2
- [x] /v2/wvw/objectives [l]
- [x] /v2/wvw/ranks [l]
- [-] /v2/wvw/rewardtracks [l,d]
- [x] /v2/wvw/upgrades [l]
- [x] /v2/wvw/upgrades [l]

- 1.30:
- replace all global paths to simplify them:
- e.g ::std::fmt::Result -> std::fmt::Result
- use `crate` instead of things like ::module as the start of paths
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/anet/achievement/achievement.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(AchievementId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/achievement/category.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
gw2rs_id_u64!(AchievementCategoryId);

use crate::anet::achievement::achievement::AchievementId;
use ::anet::achievement::achievement::AchievementId;

/// `AchievementCategory`s represent broad categories of achievements in Guild Wars 2.
#[derive(Debug, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/anet/achievement/daily.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

/// `DailyAchievements` are the response of the daily achievement endpoints and map to the various
/// categories of daily achievements found in the Game.
Expand Down
2 changes: 1 addition & 1 deletion src/anet/achievement/group.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::anet::achievement::category::AchievementCategoryId;
use ::anet::achievement::category::AchievementCategoryId;

gw2rs_id_string!(AchievementGroupId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/achievement/reward.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::anet::achievement::region::Region;
use ::anet::achievement::region::Region;

/// `AchievementReward`s represent the various types of rewards you can receive for completing
/// achievements within the game.
Expand Down
2 changes: 1 addition & 1 deletion src/anet/backstory/answer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_string!(BackstoryAnswerId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/backstory/question.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(BackstoryQuestionId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/color.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(ColorId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/commerce/deliveries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

/// `TradingPostDeliveries` represents a user's items and gold waiting for pickup from the Trading
/// Post.
Expand Down
2 changes: 1 addition & 1 deletion src/anet/commerce/listing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(ListingId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/commerce/prices.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(PricesId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/glider.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(GliderId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/legend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_string!(LegendId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/specializations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(SpecializationId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/stories/season.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_string!(StorySeasonId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/stories/story.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(StoryId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/titles.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_u64!(TitleId);

Expand Down
2 changes: 1 addition & 1 deletion src/anet/wvw/objective.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::prelude::*;
use ::prelude::*;

gw2rs_id_string!(ObjectiveId);

Expand Down
4 changes: 2 additions & 2 deletions src/anet/wvw/wvw_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ macro_rules! gw2rs_wvw_server_data {
};
}

use crate::prelude::*;
use ::prelude::*;

gw2rs_id_string!(WVWMatchId);
gw2rs_wvw_server_data!(WVWMatchScores, u64);
Expand All @@ -29,7 +29,7 @@ gw2rs_wvw_server_data!(WVWMatchMapScores, u64);
gw2rs_wvw_server_data!(WVWMapKills, u64);
gw2rs_wvw_server_data!(WVWMapDeaths, u64);

use crate::anet::wvw::map::WVWMap;
use ::anet::wvw::map::WVWMap;

/// The `WVWMatch` struct represents all associated data related to a World versus World matchup.
#[derive(Debug, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/internal/api_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal::error_response::ErrorResponse;
use ::internal::error_response::ErrorResponse;

/// Enumerates error conditions expected throughout the library.
#[derive(Debug, Serialize)]
Expand Down
12 changes: 6 additions & 6 deletions src/internal/gold_value.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::convert::From as StdFrom;
use std::fmt::Display as StdDisplay;
use std::fmt::Formatter as StdFormatter;
use std::fmt::Result as StdFmtResult;
use std::ops::Add as StdAdd;
use std::ops::Sub as StdSub;
use ::std::convert::From as StdFrom;
use ::std::fmt::Display as StdDisplay;
use ::std::fmt::Formatter as StdFormatter;
use ::std::fmt::Result as StdFmtResult;
use ::std::ops::Add as StdAdd;
use ::std::ops::Sub as StdSub;

/// `GoldValue`s are a convenience around monetary values provided by the ArenaNet API.
/// In particular, endpoints that return monetary values natively return the number of copper coins
Expand Down
37 changes: 22 additions & 15 deletions src/internal/gw2/achievement.rs
Original file line number Diff line number Diff line change
@@ -1,64 +1,71 @@
use futures::Future;

use crate::prelude::*;
use ::prelude::*;

impl GW2 {
/// Retrieves today's daily achievements.
#[must_use]
pub fn daily_achievements(&self) -> impl Future<Item = DailyAchievements, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::AchievementsDaily;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<DailyAchievements>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<DailyAchievements>(&res))
}

/// Retrieves tomorrows daily achievements.
#[must_use]
pub fn daily_achievements_tomorrow(&self) -> impl Future<Item = DailyAchievements, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::AchievementsDailyTomorrow;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<DailyAchievements>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<DailyAchievements>(&res))
}

/// Fetches achievements using a slice of u64 identifiers.
#[must_use]
pub fn achievements_by_ids<'a>(&self, ids: &'a [u64]) -> impl Future<Item = Vec<Achievement>, Error = APIError> + 'a {
let client = self.get_http_client();
let locale = self.locale();
let endpoint = Endpoint::Achievements;
crate::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<Achievement>>(&res))
::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<Achievement>>(&res))
}

/// Retrieves the identifiers for valid achievement categories.
#[must_use]
pub fn achievement_categories(&self) -> impl Future<Item = Vec<u64>, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::AchievementsCategories;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<u64>>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<u64>>(&res))
}

/// Retrieves achievement categories with the given identifiers.
#[must_use]
pub fn achievement_categories_by_ids<'a>(&self, ids: &'a [u64]) -> impl Future<Item = Vec<AchievementCategory>, Error = APIError> + 'a {
let client = self.get_http_client();
let locale = self.locale();
let endpoint = Endpoint::AchievementsCategories;
crate::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<AchievementCategory>>(&res))
::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<AchievementCategory>>(&res))
}

/// Retrieves valid achievement group identifiers.
#[must_use]
pub fn achievement_groups(&self) -> impl Future<Item = Vec<AchievementGroupId>, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::AchievementsGroups;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<AchievementGroupId>>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<AchievementGroupId>>(&res))
}

/// Retrieves achievement groups with the given identifiers.
#[must_use]
pub fn achievement_groups_by_ids<'a>(&self, ids: &'a [&str]) -> impl Future<Item = Vec<AchievementGroup>, Error = APIError> + 'a {
let client = self.get_http_client();
let locale = self.locale();
let endpoint = Endpoint::AchievementsGroups;
crate::internal::http::request_with_string_ids(client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<AchievementGroup>>(&res))
::internal::http::request_with_string_ids(client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<AchievementGroup>>(&res))
}
}
22 changes: 13 additions & 9 deletions src/internal/gw2/backstory.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
use futures::Future;

use crate::prelude::*;
use ::prelude::*;

impl GW2 {
/// Retrieves backstory answer identifiers.
#[must_use]
pub fn backstory_answers(&self) -> impl Future<Item = Vec<BackstoryAnswerId>, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::BackstoryAnswers;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<BackstoryAnswerId>>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<BackstoryAnswerId>>(&res))
}

/// Retrieves backstory answers using the given list of identifiers.
#[must_use]
pub fn backstory_answers_by_ids<'a>(&self, ids: &'a [&str]) -> impl Future<Item = Vec<BackstoryAnswer>, Error = APIError> + 'a {
let client = self.get_http_client();
let locale = self.locale();
let endpoint = Endpoint::BackstoryAnswers;
crate::internal::http::request_with_string_ids(client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<BackstoryAnswer>>(&res))
::internal::http::request_with_string_ids(client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<BackstoryAnswer>>(&res))
}

/// Retrieves backstory question identifiers.
#[must_use]
pub fn backstory_questions(&self) -> impl Future<Item = Vec<BackstoryQuestionId>, Error = APIError> {
let client = self.get_http_client();
let endpoint = Endpoint::BackstoryQuestions;
crate::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<BackstoryQuestionId>>(&res))
::internal::http::request_without_ids(client, endpoint, None, None, None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<BackstoryQuestionId>>(&res))
}

/// Retrieves backstory questions using the given list of identifiers.
#[must_use]
pub fn backstory_questions_by_ids<'a>(&self, ids: &'a [u64]) -> impl Future<Item = Vec<BackstoryQuestion>, Error = APIError> + 'a {
let client = self.get_http_client();
let locale = self.locale();
let endpoint = Endpoint::BackstoryQuestions;
crate::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| crate::internal::http::convert_to_struct::<Vec<BackstoryQuestion>>(&res))
::internal::http::request_with_numeric_ids( client, endpoint, Some(ids), None, Some(locale), None)
.and_then(|res| ::internal::http::convert_to_struct::<Vec<BackstoryQuestion>>(&res))
}
}
Loading

0 comments on commit da43f63

Please sign in to comment.