Crate screeps_api [] [src]

Rust library for using the Screeps HTTP API.

Screeps is a true programming MMO where users uploading JavaScript code to power their online empires. rust-screeps-api can connect to the official server, and any private server instances run by users.

rust-screeps-api uses hyper to run http requests and serde to parse json results.

Usage

Screeps API is built on two levels: an underlying asynchronous Api structure, and an easier-to-use SyncApi built on top of it.

To start using screeps through the blocking synchronous API, simply create a SyncApi object:

extern crate screeps_api;

use screeps_api::SyncApi;

let mut api = SyncApi::new().expect("expected starting screeps http client to suceed");

This API object can then be used to make any number of API calls. Each will return a Result with a typed response or an error. All calls require mutable access to manage tokens and the underlying tokio instance:

api.login("username", "password").unwrap();

let my_info = api.my_info().unwrap();

println!("Logged in with user ID {}!", my_info.user_id);

Reexports

pub use error::Error;
pub use error::ErrorKind;
pub use error::NoToken;
pub use data::RoomName;
pub use endpoints::MapStats;
pub use endpoints::MyInfo;
pub use endpoints::RecentPvp;
pub use endpoints::RoomOverview;
pub use endpoints::RoomStatus;
pub use endpoints::RoomTerrain;
pub use endpoints::ShardInfo;
pub use endpoints::WorldStartRoom;
pub use endpoints::leaderboard::LeaderboardType;
pub use endpoints::room_terrain::TerrainGrid;
pub use endpoints::recent_pvp::PvpArgs as RecentPvpDetails;
pub use endpoints::login::LoggedIn;
pub use endpoints::leaderboard::season_list::LeaderboardSeason;
pub use endpoints::leaderboard::find_rank::FoundUserRank;
pub use endpoints::leaderboard::page::LeaderboardPage;
pub use connecting::FutureResponse;
pub use sync::Config as SyncConfig;
pub use sync::SyncApi;

Modules

connecting

Semi-internal functionality related to networking.

data

Data structures that appear in multiple API endpoint results.

endpoints

Parsing code for each individual API endpoint.

error

Error types for the screeps api.

sync

Small wrapper around the asynchronous Api struct providing synchronous access methods.

websocket

Handling of socket connections to screeps using ws-rs as a backend.

Structs

Api

API Object, stores the current API token and allows access to making requests.

Statics

DEFAULT_OFFICIAL_API_URL

The official server's default api url`

Traits

EndpointType

Sealed trait implemented for each endpoint.

HyperClient

A generic trait over hyper's Client which allows for references, owned clients, and Arc<hyper::Client> to be used.

TokenStorage

A generic trait over some storage for auth tokens, possibly for use with sharing tokens between clients.

Functions

gcl_calc

Calculates GCL, given GCL points.

Type Definitions

ArcTokenStorage

Convenience type representing the regular token storage when sending between threads is required.

RcTokenStorage

Convenience type representing the regular token storage when sending between threads is not required.

Token

An API token that allows for one-time authentication. Each use of an API token with the screeps API will cause the API to return a new token which should be stored in its place.