rust/hedgewars-server/src/server/core.rs
changeset 14801 65861ba8b4e8
parent 14800 f43ab2bd76ae
child 14802 01f8ab45f806
--- a/rust/hedgewars-server/src/server/core.rs	Tue Apr 09 21:08:35 2019 +0300
+++ b/rust/hedgewars-server/src/server/core.rs	Tue Apr 09 23:03:12 2019 +0300
@@ -8,8 +8,6 @@
 
 use log::*;
 use slab;
-use std::fs::{File, OpenOptions};
-use std::io::{Read, Write};
 use std::{borrow::BorrowMut, iter, num::NonZeroU16};
 
 type Slab<T> = slab::Slab<T>;
@@ -48,18 +46,16 @@
 pub struct HWServer {
     pub clients: IndexSlab<HWClient>,
     pub rooms: Slab<HWRoom>,
-    pub io: Box<dyn HWServerIO>,
     pub anteroom: HWAnteroom,
 }
 
 impl HWServer {
-    pub fn new(clients_limit: usize, rooms_limit: usize, io: Box<dyn HWServerIO>) -> Self {
+    pub fn new(clients_limit: usize, rooms_limit: usize) -> Self {
         let rooms = Slab::with_capacity(rooms_limit);
         let clients = IndexSlab::with_capacity(clients_limit);
         Self {
             clients,
             rooms,
-            io,
             anteroom: HWAnteroom::new(clients_limit),
         }
     }
@@ -205,48 +201,3 @@
         }
     }
 }
-
-pub trait HWServerIO {
-    fn write_file(&mut self, name: &str, content: &str) -> std::io::Result<()>;
-    fn read_file(&mut self, name: &str) -> std::io::Result<String>;
-}
-
-pub struct EmptyServerIO {}
-
-impl EmptyServerIO {
-    pub fn new() -> Self {
-        Self {}
-    }
-}
-
-impl HWServerIO for EmptyServerIO {
-    fn write_file(&mut self, _name: &str, _content: &str) -> std::io::Result<()> {
-        Ok(())
-    }
-
-    fn read_file(&mut self, _name: &str) -> std::io::Result<String> {
-        Ok("".to_string())
-    }
-}
-
-pub struct FileServerIO {}
-
-impl FileServerIO {
-    pub fn new() -> Self {
-        Self {}
-    }
-}
-
-impl HWServerIO for FileServerIO {
-    fn write_file(&mut self, name: &str, content: &str) -> std::io::Result<()> {
-        let mut writer = OpenOptions::new().create(true).write(true).open(name)?;
-        writer.write_all(content.as_bytes())
-    }
-
-    fn read_file(&mut self, name: &str) -> std::io::Result<String> {
-        let mut reader = File::open(name)?;
-        let mut result = String::new();
-        reader.read_to_string(&mut result)?;
-        Ok(result)
-    }
-}