// #![feature(proc_macro_hygiene, decl_macro)]
// #[macro_use]
// extern crate serde_derive;
// #[macro_use]
// extern crate rocket;
// #[macro_use]
// extern crate rocket_contrib;
// #[macro_use]
// extern crate lazy_static;
// extern crate serde_json;

// // use serde_json;
// use std::collections::HashMap;
// use std::fs::File;
// use std::io::BufReader;
// use std::io::BufWriter;
// use std::sync::Mutex;
// use std::{thread, time};

// /// Fucking egun is a mess. It does not even use css and is built using tables. This is an attempt to parse it.
// mod query;
// use query::*;
// mod server;
// const DBFILE: &str = "accounts.json";


// lazy_static! {
//     static ref ACCOUNTS: Mutex<HashMap<String, Account>> = Mutex::new(HashMap::new());
// }


// fn daemon() {
//     println!(">>> Running update...");

//         let accounts_unlocked = ACCOUNTS.lock().unwrap().clone();

//         for (account_name, account) in accounts_unlocked {
//             dbg!(&account_name);
//             let mut accounts = ACCOUNTS.lock().unwrap();
//             accounts.insert(account_name.to_string(), account.updated());
//         }


//     let accounts_unlocked = ACCOUNTS.lock().unwrap();
//     let writer = BufWriter::new(File::create(DBFILE).unwrap());
//     serde_json::to_writer_pretty(writer, &*accounts_unlocked).unwrap();

//     println!(">>> Done.");
// }

// fn main() {
    
//     //server::proxy("http://www.egun.de/market/cache/aucimg/100x100/3.7564934.665580173.jpg");
//     server::run();
//     return;


//     match File::open(DBFILE) {
//         Ok(f) => {
//             match serde_json::from_reader::<_, HashMap<String, Account>>(BufReader::new(f)) {
//                 Ok(accounts) => {
//                     {
//                         // Lock once, shove loaded ccounts in
//                         let mut accounts_unlocked = ACCOUNTS.lock().unwrap();
//                         *accounts_unlocked = accounts;
//                     }
//                     // start daemon before running web server
//                         daemon();
//                 },
//                 Err(e) => println!("Parsing account da'a has failed: {:?}", e)
//             }
//         }
//         Err(e) => println!("Opening accounts file failed. {:?}", e),
//     }
// }
