This repository is no longer being maintained. Since Rust has continued to evolve since this repo has last been updated, it is doubtless quite non-functional and it would take some work to make it compile again.
A Rust wrapper for the planets.nu API. While it is by no means complete or polished, it is usable.
- Cargo: This project uses Cargo as its build system, and so it is intended to be used by projects which are also built using Cargo;
- Rust master: This project is maintained such that it will build using the master branch of the Rust compiler. If your project is built using an older version of Rust, there are no guarantees that this library will be compatible.
To start using this library in a Cargo-enabled project:
-
Install Rust and Cargo by following the Rust Guide's installation instructions;
-
Add the following to your project's
Cargo.toml
file:[dependencies.planets_nu] git = "https://github.com/pshendry/rust-planets-nu.git"
No idea, sorry! Hopefully the Rust Guide has instructions for using Cargo libraries in your build environment.
This library comes in two main parts: a request
module and a parse
module. The request
module contains functions for making direct queries to
the planets.nu server, whereas the parse
module contains functions for directly interpreting the content of the responses (usually JSON). As such,
typically the request
module should be used, but if for some reason you need to make requests manually or you need to parse stored responses,
the parse
module is available for that.
For all examples that follow, it is necessary to import the crate and appropriate module(s):
extern crate planets_nu;
use self::planets_nu::request;
use self::planets_nu::parse;
- Login:
-
Example:
let result = request::login("username".to_string(), "password".to_string()); //let result = parse::login("[json string]"); print!(result);
-
- List Games:
-
Example:
// List games using all default parameters let result = request::list_games( request::STATUS_DEFAULT, request::GAME_TYPE_DEFAULT, request::DefaultScope, &Vec::new(), None, None); //let result = parse::list_games("[json string]"); print!(result);
-
- Load Turn:
-
Note: Support is incomplete. The following parts of the Load Turn results are currently not supported: maps, ionstorms, nebulas, stars, starbases, stock, relations, messages, mymessages, notes, vcrs, races, hulls, racehulls, beams, engines, torpedos, advantages.
-
Example:
// Load turn 5 from game 815 as player 1 let result = request::load_turn(815i64, Some(5i64), None, Some(1i64), false); //let result = parse::load_turn("[json string]"); print!(result);
-
- Reference documentation for rust-planets-nu is available at http://www.rust-ci.org/pshendry/rust-planets-nu/doc/planets_nu/.
- Official documentation for the planets.nu API is available on the planets.nu website, and unofficial documentation is available on the VGA Planets Wiki.