extracts server in its own module
This commit is contained in:
10
src/api.rs
10
src/api.rs
@@ -2,7 +2,7 @@ use actix_web::{web, web::Json, Error, HttpResponse, Result};
|
||||
use futures::Future;
|
||||
|
||||
use lootalot_db::Pool;
|
||||
use lootalot_db::{ActionResult, DbConnection, Item, Player as PlayerData, QueryResult};
|
||||
use lootalot_db::{ActionResult, DbConnection, Item, Player, QueryResult};
|
||||
|
||||
pub struct DbApi<'q>(&'q DbConnection);
|
||||
|
||||
@@ -11,8 +11,8 @@ impl<'q> DbApi<'q> {
|
||||
Self(conn)
|
||||
}
|
||||
|
||||
pub fn fetch_players(self) -> QueryResult<Vec<PlayerData>> {
|
||||
PlayerData::fetch_list(self.0)
|
||||
pub fn fetch_players(self) -> QueryResult<Vec<Player>> {
|
||||
Player::fetch_list(self.0)
|
||||
}
|
||||
|
||||
pub fn as_player(self, id: i32) -> AsPlayer<'q> {
|
||||
@@ -28,10 +28,10 @@ pub struct AsPlayer<'q> {
|
||||
impl<'q> AsPlayer<'q> {
|
||||
/// Fetch the content of a player's chest
|
||||
pub fn loot(self) -> QueryResult<Vec<Item>> {
|
||||
PlayerData::fetch_loot(self.id, self.conn)
|
||||
Player::fetch_loot(self.id, self.conn)
|
||||
}
|
||||
pub fn claim(self, item: i32) -> ActionResult {
|
||||
PlayerData::action_claim_object(self.id, item, self.conn)
|
||||
Player::action_claim_object(self.id, item, self.conn)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user