remove warnings

This commit is contained in:
ntr 2020-01-03 15:44:17 +10:00
parent 6232755d47
commit 9f97319c2d
11 changed files with 30 additions and 61 deletions

View File

@ -11,7 +11,6 @@ use chrono::prelude::*;
use chrono::Duration;
use player::{Player, Score};
use mob::{bot_player, instance_mobs};
use game::{Game};
use item::{Item};
use vbox;
@ -504,6 +503,7 @@ impl Instance {
#[cfg(test)]
mod tests {
use super::*;
use mob::{bot_player, instance_mobs};
#[test]
fn instance_pve_test() {

View File

@ -9,8 +9,6 @@ use rand::distributions::{WeightedIndex};
use failure::Error;
use failure::err_msg;
use construct::{Colours};
use item::*;
pub type VboxIndices = Option<HashMap<ItemType, Vec<String>>>;
@ -217,6 +215,7 @@ impl Vbox {
#[cfg(test)]
mod tests {
use super::*;
use construct::{Colours};
#[test]
fn combine_test() {

View File

@ -42,7 +42,7 @@ impl Account {
false => None,
};
Ok(Player::new(self.id, Some(self.img), &self.name, constructs))
Ok(Player::new(self.id, img, &self.name, constructs))
}
pub fn anonymous() -> Account {
@ -103,7 +103,7 @@ pub fn chat_wheel(_db: &Db, _id: Uuid) -> Result<Vec<String>, Error> {
])
}
pub fn select_name(db: &Db, name: &String) -> Result<Account, Error> {
pub fn _select_name(db: &Db, name: &String) -> Result<Account, Error> {
let query = "
SELECT id, name, balance, subscribed, img
FROM accounts

View File

@ -6,7 +6,7 @@ use std::time;
use uuid::Uuid;
use failure::Error;
use failure::{err_msg, format_err};
use failure::{format_err};
use crossbeam_channel::{Sender, Receiver};
@ -15,7 +15,6 @@ use names;
use rpc::RpcMessage;
use warden::{GameEvent};
use mail::Mail;
pub type EventsTx = Sender<Event>;
type Id = Uuid;
@ -35,7 +34,6 @@ pub struct Events {
pub tx: Sender<Event>,
rx: Receiver<Event>,
mail: Sender<Mail>,
warden: Sender<GameEvent>,
clients: HashMap<Id, WsClient>,
}
@ -72,12 +70,11 @@ struct WsClient {
}
impl Events {
pub fn new(tx: Sender<Event>, rx: Receiver<Event>, warden: Sender<GameEvent>, mail: Sender<Mail>) -> Events {
pub fn new(tx: Sender<Event>, rx: Receiver<Event>, warden: Sender<GameEvent>) -> Events {
Events {
tx,
rx,
warden,
mail,
clients: HashMap::new(),
}
}
@ -101,17 +98,6 @@ impl Events {
}
}
fn get_client(&mut self, id: Id) -> Result<&mut WsClient, Error> {
match self.clients.get_mut(&id) {
Some(c) => Ok(c),
None => Err(format_err!("connection not found id={:?}", id)),
}
}
fn remove_client(&mut self, id: Id) {
self.clients.remove(&id);
}
fn event(&mut self, msg: Event) -> Result<(), Error> {
match msg {
Event::Connect(id, account, tx) => {
@ -157,7 +143,7 @@ impl Events {
trace!("unsubscribe id={:?} object={:?}", id, obj);
match self.clients.get_mut(&id) {
Some(mut client) => {
Some(client) => {
client.subs.remove(&obj);
trace!("unsubscribe subscriptions removed={:?}", client.subs.len());
Ok(())
@ -194,7 +180,9 @@ impl Events {
if !dead.is_empty() {
trace!("dead connections={:?}", dead.len());
dead.iter().for_each(|id| self.remove_client(*id));
for id in dead.iter() {
self.clients.remove(id);
}
}
trace!("push subscribers={:?}", subs);

View File

@ -111,7 +111,7 @@ pub fn json_response(status: status::Status, response: Json) -> Response {
return Response::with((content_type, status, json));
}
pub fn json_object(status: status::Status, object: String) -> Response {
pub fn _json_object(status: status::Status, object: String) -> Response {
let content_type = "application/json".parse::<Mime>().unwrap();
return Response::with((content_type, status, object));
}

View File

@ -72,7 +72,7 @@ enum ConstructShapes {
Line,
V,
Tri,
Plus,
// Plus,
Blank,
}
@ -203,9 +203,7 @@ pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
write!(&mut svg, "<path stroke=\"{fill}\" stroke-width=\"{width}\" d=\"M{x0} {y0}L 0 0 M{x1} {y1}L 0 0 M{x2} {y2}L 0 0 \" transform=\"translate({x_translate}, {y_translate}) rotate({rotation})\" />",
fill = colour, width = width, x0 = x0, y0 = y0, x1 = x1, y1 = y1, x2 = x2, y2 = y2, rotation = rotation, x_translate = -x_translate, y_translate = -y_translate)?;
},
ConstructShapes::Plus => {
},
// ConstructShapes::Plus => { },
ConstructShapes::Blank => (),
}
}

View File

@ -122,11 +122,11 @@ pub fn start() {
let warden_tick_tx = warden_tx.clone();
let (mail_tx, mail_rx) = unbounded();
let http_mail_tx = mail_tx.clone();
let _http_mail_tx = mail_tx.clone();
// create a clone of the tx so ws handler can tell events
// about connection status
let events = events::Events::new(events_tx, events_rx, events_warden_tx, mail_tx);
let events = events::Events::new(events_tx, events_rx, events_warden_tx);
let warden = warden::Warden::new(warden_tx, warden_rx, events.tx.clone(), pool.clone());
let pg_pool = pool.clone();

View File

@ -261,7 +261,7 @@ pub fn set(tx: &mut Transaction, account: Uuid, email: &String) -> Result<(Uuid,
return Ok((id, confirm_token));
}
pub fn listen(rx: Receiver<Mail>) -> SmtpTransport {
pub fn listen(_rx: Receiver<Mail>) -> SmtpTransport {
let sender = env::var("MAIL_ADDRESS")
.expect("MAIL_ADDRESS must be set");
@ -271,7 +271,7 @@ pub fn listen(rx: Receiver<Mail>) -> SmtpTransport {
let domain = env::var("MAIL_DOMAIN")
.expect("MAIL_DOMAIN must be set");
let mut mailer = SmtpClient::new_simple("smtp.gmail.com").unwrap()
let mailer = SmtpClient::new_simple("smtp.gmail.com").unwrap()
.hello_name(ClientId::Domain(domain))
.credentials(Credentials::new(sender, password))
.smtp_utf8(true)
@ -281,19 +281,6 @@ pub fn listen(rx: Receiver<Mail>) -> SmtpTransport {
info!("mail connected");
// loop {
// match rx.recv() {
// Ok(m) => match send_mail(&mut mailer, m) {
// Ok(r) => info!("{:?}", r),
// Err(e) => warn!("{:?}", e),
// },
// Err(e) => {
// error!("{:?}", e);
// panic!("mail thread cannot continue");
// },
// };
// }
// Explicitly close the SMTP transaction as we enabled connection reuse
// mailer.close();
return mailer;

View File

@ -86,7 +86,7 @@ impl Mtx {
}
}
pub fn delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
pub fn _delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
let query = "
DELETE
FROM mtx

View File

@ -143,7 +143,7 @@ pub fn listen(pool: PgPool, events: Sender<Event>) -> Result<(), Error> {
}
pub fn construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<(), Error> {
pub fn _construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<(), Error> {
let query = "
DELETE
FROM constructs
@ -163,7 +163,7 @@ pub fn construct_delete(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Res
return Ok(());
}
pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Construct, Error> {
pub fn _construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Construct, Error> {
let query = "
SELECT data
FROM constructs
@ -290,7 +290,7 @@ pub fn game_get(tx: &mut Transaction, id: Uuid) -> Result<Game, Error> {
return Ok(game);
}
pub fn select(db: &Db, id: Uuid) -> Result<Game, Error> {
pub fn _game_select(db: &Db, id: Uuid) -> Result<Game, Error> {
let query = "
SELECT *
FROM games
@ -312,7 +312,7 @@ pub fn select(db: &Db, id: Uuid) -> Result<Game, Error> {
return Ok(game);
}
pub fn list(db: &Db, number: u32) -> Result<Vec<Game>, Error> {
pub fn _game_list(db: &Db, number: u32) -> Result<Vec<Game>, Error> {
let query = "
SELECT data
FROM games
@ -815,7 +815,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
Ok(())
}
pub fn bot_instance() -> Instance {
pub fn _bot_instance() -> Instance {
let mut instance = Instance::new();
let bot_player = bot_player();

View File

@ -1,7 +1,5 @@
use std::time::{Duration};
use uuid::Uuid;
use crossbeam_channel::{tick, Sender, Receiver};
// Db Commons
@ -24,13 +22,12 @@ use pg::{
pvp,
};
type Id = usize;
type Pair = (PvpRequest, PvpRequest);
pub enum GameEvent {
Upkeep,
Finish(Uuid),
// Finish(Uuid),
Match(Pair),
}
@ -76,10 +73,10 @@ impl Warden {
match msg {
GameEvent::Upkeep => self.on_upkeep(),
GameEvent::Match(pair) => self.on_match(pair),
GameEvent::Finish(id) => {
info!("game finished id={:?}", id);
Ok(())
},
// GameEvent::Finish(id) => {
// info!("game finished id={:?}", id);
// Ok(())
// },
}
}
@ -131,7 +128,7 @@ impl Warden {
fn fetch_games(mut tx: Transaction) -> Result<Transaction, Error> {
let games = games_need_upkeep(&mut tx)?;
for mut game in games {
for game in games {
let game = game.upkeep();
match game_update(&mut tx, &game) {
Ok(_) => (),
@ -146,7 +143,7 @@ fn fetch_games(mut tx: Transaction) -> Result<Transaction, Error> {
}
fn fetch_instances(mut tx: Transaction) -> Result<Transaction, Error> {
for mut instance in instances_need_upkeep(&mut tx)? {
for instance in instances_need_upkeep(&mut tx)? {
let (instance, new_game) = instance.upkeep();
if let Some(game) = new_game {