added deprecated attribute to unused methods
This commit is contained in:
parent
0ab49de27f
commit
646163b3e3
|
|
@ -42,22 +42,27 @@ impl<'a> Client<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn get_stream(&self) -> &TcpStream{
|
fn get_stream(&self) -> &TcpStream{
|
||||||
&self.stream
|
&self.stream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_transmitter(&self) -> &Sender<Commands>{
|
pub fn get_transmitter(&self) -> &Sender<Commands>{
|
||||||
&self.tx_channel
|
&self.tx_channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_uuid(&self) -> &String{
|
pub fn get_uuid(&self) -> &String{
|
||||||
&self.uuid
|
&self.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_username(&self) -> &String{
|
pub fn get_username(&self) -> &String{
|
||||||
&self.username
|
&self.username
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_address(&self) -> &String{
|
pub fn get_address(&self) -> &String{
|
||||||
&self.address
|
&self.address
|
||||||
}
|
}
|
||||||
|
|
@ -189,8 +194,8 @@ impl<'a> Client<'a> {
|
||||||
self.get_stream().flush().unwrap();
|
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){
|
pub fn disconnect(&mut self){
|
||||||
self.stream.shutdown(Shutdown::Both).expect("shutdown call failed");
|
self.stream.shutdown(Shutdown::Both).expect("shutdown call failed");
|
||||||
self.connected = false;
|
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]){
|
pub fn confirm_success(&self, buffer: &mut [u8; 1024]){
|
||||||
let success_regex = Regex::new(r###"!success:"###).unwrap();
|
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){
|
pub fn transmit_success(&self, data: &String){
|
||||||
let mut success_message = "!success:".to_string();
|
let mut success_message = "!success:".to_string();
|
||||||
if !data.is_empty(){
|
if !data.is_empty(){
|
||||||
|
|
@ -224,6 +232,8 @@ impl<'a> Client<'a> {
|
||||||
self.transmit_data(&success_message);
|
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){
|
fn transmit_error(&self, data: &String){
|
||||||
let mut error_message = "!error:".to_string();
|
let mut error_message = "!error:".to_string();
|
||||||
if !data.is_empty(){
|
if !data.is_empty(){
|
||||||
|
|
|
||||||
|
|
@ -106,15 +106,6 @@ impl<'z> Server<'z> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_info(&self, tx: Sender<Commands>) {
|
|
||||||
let mut params: HashMap<String, String> = 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){
|
pub fn update_client(&self, uuid: &str, command: &Commands){
|
||||||
let clients = self.connected_clients.lock().unwrap();
|
let clients = self.connected_clients.lock().unwrap();
|
||||||
let tx = clients.get(&uuid.to_string()).unwrap();
|
let tx = clients.get(&uuid.to_string()).unwrap();
|
||||||
|
|
@ -141,46 +132,19 @@ impl<'z> Server<'z> {
|
||||||
stream.flush().unwrap();
|
stream.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
//deprecated
|
#[deprecated(since="24.7.20", note="will be removed in future, please do not use!")]
|
||||||
/*
|
#[allow(dead_code)]
|
||||||
pub fn tokenize(&self, incoming_message: &str) -> Result<ClientCommands, &'static str>{
|
pub fn get_info(&self, tx: Sender<Commands>) {
|
||||||
let command_regex = Regex::new(r###"(\?|!)([a-zA-z0-9]*):|([a-zA-z]*):([a-zA-Z0-9\-\+\[\]{}_=/]+|("(.*?)")+)"###).unwrap();
|
let mut params: HashMap<String, String> = 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 = Commands::Info(Some(params));
|
||||||
let command = self.match_command(&incoming_message.to_string());
|
tx.send(command).unwrap();
|
||||||
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!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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<String, String>){
|
fn regex_data(&self, command_regex: &Regex, data: &str, command_addons: &mut HashMap<String, String>){
|
||||||
for figure in command_regex.find_iter(data){
|
for figure in command_regex.find_iter(data){
|
||||||
let segment = figure.as_str().to_string();
|
let segment = figure.as_str().to_string();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue