diff --git a/src/client/data/config.rs b/src/client/data/config.rs index 3455a62..556011c 100644 --- a/src/client/data/config.rs +++ b/src/client/data/config.rs @@ -46,7 +46,7 @@ pub struct Config { impl Config { /// Loads a JSON configuration from the desired path. - pub fn load(path: &Path) -> Result { + pub fn load>(path: P) -> Result { let mut file = try!(File::open(path)); let mut data = String::new(); try!(file.read_to_string(&mut data)); @@ -55,11 +55,6 @@ impl Config { ) } - /// Loads a JSON configuration using the string as a UTF-8 path. - pub fn load_utf8(path: &str) -> Result { - Config::load(Path::new(path)) - } - /// Determines whether or not the nickname provided is the owner of the bot. pub fn is_owner(&self, nickname: &str) -> bool { self.owners.as_ref().map(|o| o.contains(&nickname.to_string())).unwrap() @@ -186,7 +181,7 @@ mod test { } #[test] - fn load_utf8() { + fn load_from_str() { let cfg = Config { owners: Some(vec![format!("test")]), nickname: Some(format!("test")), @@ -204,7 +199,7 @@ mod test { user_info: None, options: Some(HashMap::new()), }; - assert_eq!(Config::load_utf8("client_config.json").unwrap(), cfg); + assert_eq!(Config::load("client_config.json").unwrap(), cfg); } diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index 34b2306..cf8d5ee 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -5,6 +5,7 @@ use std::borrow::ToOwned; use std::collections::HashMap; use std::error::Error as StdError; use std::io::{BufReader, BufWriter, Error, ErrorKind, Result}; +use std::path::Path; use std::sync::{Mutex, RwLock}; use std::iter::Map; use client::conn::{Connection, NetStream}; @@ -49,8 +50,8 @@ pub type NetIrcServer = IrcServer, BufWriter>; impl IrcServer, BufWriter> { /// Creates a new IRC Server connection from the configuration at the specified path, /// connecting immediately. - pub fn new(config: &str) -> Result { - IrcServer::from_config(try!(Config::load_utf8(config))) + pub fn new>(config: P) -> Result { + IrcServer::from_config(try!(Config::load(config))) } /// Creates a new IRC server connection from the specified configuration, connecting