From 646163b3e3d68be4f70eb92f753d6282532fb6cc Mon Sep 17 00:00:00 2001 From: Mitchell Date: Fri, 24 Jul 2020 12:22:32 +0100 Subject: [PATCH] added deprecated attribute to unused methods --- src/server/client/client_profile.rs | 16 +++++++-- src/server/server_profile.rs | 56 ++++++----------------------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/src/server/client/client_profile.rs b/src/server/client/client_profile.rs index 441ac58..4b020c8 100644 --- a/src/server/client/client_profile.rs +++ b/src/server/client/client_profile.rs @@ -42,22 +42,27 @@ impl<'a> Client<'a> { } } + #[allow(dead_code)] fn get_stream(&self) -> &TcpStream{ &self.stream } + #[allow(dead_code)] pub fn get_transmitter(&self) -> &Sender{ &self.tx_channel } + #[allow(dead_code)] pub fn get_uuid(&self) -> &String{ &self.uuid } + #[allow(dead_code)] pub fn get_username(&self) -> &String{ &self.username } + #[allow(dead_code)] pub fn get_address(&self) -> &String{ &self.address } @@ -189,8 +194,8 @@ impl<'a> Client<'a> { self.get_stream().flush().unwrap(); } - - + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] pub fn disconnect(&mut self){ self.stream.shutdown(Shutdown::Both).expect("shutdown call failed"); self.connected = false; @@ -198,7 +203,8 @@ impl<'a> Client<'a> { - // deprecated + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] pub fn confirm_success(&self, buffer: &mut [u8; 1024]){ let success_regex = Regex::new(r###"!success:"###).unwrap(); @@ -215,6 +221,8 @@ impl<'a> Client<'a> { }; } + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] pub fn transmit_success(&self, data: &String){ let mut success_message = "!success:".to_string(); if !data.is_empty(){ @@ -224,6 +232,8 @@ impl<'a> Client<'a> { self.transmit_data(&success_message); } + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] fn transmit_error(&self, data: &String){ let mut error_message = "!error:".to_string(); if !data.is_empty(){ diff --git a/src/server/server_profile.rs b/src/server/server_profile.rs index 21ea3fc..4cfdac2 100644 --- a/src/server/server_profile.rs +++ b/src/server/server_profile.rs @@ -106,15 +106,6 @@ impl<'z> Server<'z> { } } - pub fn get_info(&self, tx: Sender) { - let mut params: HashMap = HashMap::new(); - params.insert(String::from("name"), self.name.to_string().clone()); - params.insert(String::from("owner"), self.author.to_string().clone()); - - let command = Commands::Info(Some(params)); - tx.send(command).unwrap(); - } - pub fn update_client(&self, uuid: &str, command: &Commands){ let clients = self.connected_clients.lock().unwrap(); let tx = clients.get(&uuid.to_string()).unwrap(); @@ -141,46 +132,19 @@ impl<'z> Server<'z> { stream.flush().unwrap(); } - //deprecated - /* - pub fn tokenize(&self, incoming_message: &str) -> Result{ - let command_regex = Regex::new(r###"(\?|!)([a-zA-z0-9]*):|([a-zA-z]*):([a-zA-Z0-9\-\+\[\]{}_=/]+|("(.*?)")+)"###).unwrap(); + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] + pub fn get_info(&self, tx: Sender) { + let mut params: HashMap = HashMap::new(); + params.insert(String::from("name"), self.name.to_string().clone()); + params.insert(String::from("owner"), self.author.to_string().clone()); - if command_regex.is_match(incoming_message){ - let command = self.match_command(&incoming_message.to_string()); - let command = match command{ - ClientCommands::Connect(mut addons) => { - self.regex_data(&command_regex, &incoming_message.replace("!connect: ", ""), &mut addons); - ClientCommands::Connect(addons) - }, - ClientCommands::ClientInfo(mut addons) => { - self.regex_data(&command_regex, &incoming_message.replace("!clientInfo: ", ""), &mut addons); - ClientCommands::ClientInfo(addons) - }, - _ => { - println!("no addons"); - command - }, - }; - Ok(command) - } else { - Err("data did not match regex!") - } + let command = Commands::Info(Some(params)); + tx.send(command).unwrap(); } - - - fn match_command(&self, command: &String) -> ClientCommands{ - match command{ - _ if command.starts_with("!info:") => ClientCommands::Info, - _ if command.starts_with("!connect:") => ClientCommands::Connect(HashMap::new()), - _ if command.starts_with("!disconnect:") => ClientCommands::Disconnect, - _ if command.starts_with("!clientUpdate:") => ClientCommands::ClientUpdate, - _ if command.starts_with("!clientInfo:") => ClientCommands::ClientInfo(HashMap::new()), - _ => ClientCommands::Unknown, - } - } - */ + #[deprecated(since="24.7.20", note="will be removed in future, please do not use!")] + #[allow(dead_code)] fn regex_data(&self, command_regex: &Regex, data: &str, command_addons: &mut HashMap){ for figure in command_regex.find_iter(data){ let segment = figure.as_str().to_string();