[][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::error::Error;
pub use crate::error::ErrorKind;
pub use crate::error::NoToken;

Modules

docs

Protocol documentation

error

Error types for the screeps api.

find_rank

Interpreting the result of finding the rank of a specific user.

page

Interpreting user leaderboard page results.

season_list

Interpreting leaderboard season list results.

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.

ApiError

JSON API error result from the server.

Badge

Description of a user badge, contains information on how that badge should be drawn/colored.

FoundUserRank

Result from a lookup for a user's rank on the leaderboard.

HardSign

Represents a "hard sign" on a room, where the server has overwritten any player-placed signs for a specific period.

LeaderboardPage

Single leaderboard page of users.

LeaderboardSeason

Single leaderboard season description, part of the result to a call to get all leaderboard seasons.

LoggedIn

The result of a call to log in.

LoginArgs

Login details

MapStats

Statistics on a number of rooms.

MapStatsArgs

Arguments to a map stats call, holds a single value which can be iterated to get rooms.

MyInfo

Result of a call to get the information for the logged in user.

RecentPvp

Result storing recent pvp matches for the entire world.

RegistrationArgs

Registration details

RegistrationSuccess

Registration success response.

RoomInfo

Information on a room.

RoomName

A structure representing a room name.

RoomNameAbsoluteCoordinates

A mirror of RoomName which implements serde::Serialize and serde::Deserialize into two numbers rather than a string.

RoomNameParseError

An error representing when a string can't be parsed into a RoomName.

RoomOverview

Various statistics about a single room, returned as a result from room_overview calls.

RoomOwner

Description of the owner of an owned room.

RoomSign

Represents a room sign.

RoomStatus

Struct describing the status of a room

RoomTerrain

Structure describing the terrain of a room

SetMemorySegmentArgs

SetMemorySegment details

ShardInfo

Structure describing information about a single game shard.

ShardRecentPvp

Result storing recent pvp matches for a particular shard.

StatPoint

A single statistics point, representing a quantity for data over an interval of time.

TokenStorage

Storage for the token inside the client, so that async requests can update the client's token if an updated token is returned.

TotalStats

Total stats over a specific time period.

UserCpuShardAllocation

Information on a user's per-shard CPU allocations.

UserDetails

Details on any user in a given leaderboard page result.

UserInfo

Information on a user.

WorldStartRoom

Structure describing the shard and room the client should start at.

Enums

BadgeColor

Badge color - what color a specific part of a badge should be.

BadgeType

Badge type - what shape a badge should be.

LeaderboardType

Type of leaderboards that are available for each season.

MapStatName

Stat name argument to the map stats call. Only one possible argument implemented, more to come!

RecentPvpArgs

Call parameters for requesting recent pvp

RoomState

A room state, returned by room status.

TerrainType

Type of terrain

Statics

DEFAULT_OFFICIAL_API_URL

The official server's default api url`

Traits

IntoRoomName

Something that can be turned into a room name.

Functions

gcl_calc

Calculates GCL, given GCL points.

Type Definitions

RankedUser

Alias since the format is the same for the inner user ranks and found user ranks.

TerrainGrid

A type alias for a 50x50 terrain grid. terrain[y_pos][x_pos] can be used to access any terrain from x 0-49, y 0-49.

TerrainRow

A type alias for a single row in the terrain grid.

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.