pub struct ScreepsApi {
pub http_client: ScreepsHttpClient,
}Expand description
Screeps Api
Fields§
§http_client: ScreepsHttpClienthttp 客户端
Implementations§
Source§impl ScreepsApi
impl ScreepsApi
pub fn new(config: ScreepsConfig) -> Self
Sourcepub async fn auth(&self) -> ScreepsResult<TokenData>
pub async fn auth(&self) -> ScreepsResult<TokenData>
登录获取 token 数据
Sourcepub async fn request<T: Serialize, U: DeserializeOwned>(
&self,
method: Method,
path: &str,
body: Option<T>,
) -> ScreepsResult<U>
pub async fn request<T: Serialize, U: DeserializeOwned>( &self, method: Method, path: &str, body: Option<T>, ) -> ScreepsResult<U>
请求接口
Sourcepub async fn get_my_info(&self) -> ScreepsResult<MyInfoData>
pub async fn get_my_info(&self) -> ScreepsResult<MyInfoData>
获取自己的信息数据
Sourcepub async fn get_my_name(&self) -> ScreepsResult<MyNameData>
pub async fn get_my_name(&self) -> ScreepsResult<MyNameData>
获取我的名字
Sourcepub async fn get_user_rooms(&self, id: &str) -> ScreepsResult<UserAllRoomsData>
pub async fn get_user_rooms(&self, id: &str) -> ScreepsResult<UserAllRoomsData>
获取玩家的所有房间
Sourcepub async fn get_user_info_by_name(
&self,
username: &str,
) -> ScreepsResult<UserInfoData>
pub async fn get_user_info_by_name( &self, username: &str, ) -> ScreepsResult<UserInfoData>
根据用户名获取玩家信息
Sourcepub async fn get_user_info_by_id(&self, id: &str) -> ScreepsResult<UserInfoData>
pub async fn get_user_info_by_id(&self, id: &str) -> ScreepsResult<UserInfoData>
根据用户ID获取玩家信息
Sourcepub async fn get_room_objects(
&self,
room: &str,
shard: &str,
) -> ScreepsResult<RoomObjectsData>
pub async fn get_room_objects( &self, room: &str, shard: &str, ) -> ScreepsResult<RoomObjectsData>
获取房间对象数据 参数:
- room: 房间名称
- shard: shard 名称
Sourcepub async fn get_room_terrain(
&self,
room: &str,
shard: &str,
) -> ScreepsResult<RoomTerrainData>
pub async fn get_room_terrain( &self, room: &str, shard: &str, ) -> ScreepsResult<RoomTerrainData>
获取房间地形数据
Sourcepub async fn get_room_terrain_encoded(
&self,
room: &str,
shard: &str,
) -> ScreepsResult<EncodedRoomTerrainData>
pub async fn get_room_terrain_encoded( &self, room: &str, shard: &str, ) -> ScreepsResult<EncodedRoomTerrainData>
获取编码后的房间地形数据
Sourcepub async fn get_room_status(
&self,
room: &str,
shard: &str,
) -> ScreepsResult<RoomStatusData>
pub async fn get_room_status( &self, room: &str, shard: &str, ) -> ScreepsResult<RoomStatusData>
获取房间状态数据
Sourcepub async fn get_shards(&self) -> ScreepsResult<AllShardData>
pub async fn get_shards(&self) -> ScreepsResult<AllShardData>
获取所有shard的信息
Sourcepub async fn get_shard_time(&self, shard: &str) -> ScreepsResult<ShardTimeData>
pub async fn get_shard_time(&self, shard: &str) -> ScreepsResult<ShardTimeData>
获取指定 shard 的游戏时间
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ScreepsApi
impl !RefUnwindSafe for ScreepsApi
impl Send for ScreepsApi
impl Sync for ScreepsApi
impl Unpin for ScreepsApi
impl !UnwindSafe for ScreepsApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more