[−][src]Crate screeps_api
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.set_token("auth token"); let my_info = api.my_info().unwrap(); println!("Logged in with user ID {}!", my_info.user_id);
Re-exports
pub use crate::sync::SyncApi; |
pub use crate::data::RoomName; |
pub use crate::endpoints::leaderboard::find_rank::FoundUserRank; |
pub use crate::endpoints::leaderboard::page::LeaderboardPage; |
pub use crate::endpoints::leaderboard::season_list::LeaderboardSeason; |
pub use crate::endpoints::leaderboard::LeaderboardType; |
pub use crate::endpoints::login::LoggedIn; |
pub use crate::endpoints::recent_pvp::PvpArgs as RecentPvpDetails; |
pub use crate::endpoints::register::Details as RegistrationDetails; |
pub use crate::endpoints::register::RegistrationSuccess; |
pub use crate::endpoints::room_terrain::TerrainGrid; |
pub use crate::endpoints::MapStats; |
pub use crate::endpoints::MyInfo; |
pub use crate::endpoints::RecentPvp; |
pub use crate::endpoints::RoomOverview; |
pub use crate::endpoints::RoomStatus; |
pub use crate::endpoints::RoomTerrain; |
pub use crate::endpoints::ShardInfo; |
pub use crate::endpoints::WorldStartRoom; |
pub use crate::error::Error; |
pub use crate::error::ErrorKind; |
pub use crate::error::NoToken; |
Modules
connecting | Semi-internal functionality related to networking. |
data | Data structures that appear in multiple API endpoint results. |
docs | Protocol documentation |
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. |
TokenStorage | Storage for the token inside the client, so that async requests can update the client's token if an updated token is returned. |
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
|
Functions
gcl_calc | Calculates GCL, given GCL points. |
Type Definitions
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. |