fixed string return format

This commit is contained in:
Mitchell 2020-06-30 14:19:13 +01:00
parent 6e9d04ed35
commit 5eb3adbe8a
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
use crate::server::client::client_profile::Client;
//use crate::client_management::client_profile::Client;
use std::sync::Mutex;
use std::sync::Arc;
use std::collections::HashMap;
pub fn get_client_data(clients_ref: &Arc<Mutex<HashMap<String, Client>>>, data: &HashMap<String, String>) -> String{
let clients_hashmap = clients_ref.lock().unwrap();
let uuid = data.get("uuid").unwrap();
println!("uuid: {}", uuid);
for (key, value) in clients_hashmap.iter(){
println!("{}",key);
}
let client = clients_hashmap.get(uuid);
match client{
Some(data) => {
let mut message = String::from("!success:");
message.push_str(&" uuid:".to_string());
message.push_str(&data.get_uuid().to_string());
message.push_str(&" host:".to_string());
message.push_str(&data.get_address().to_string());
message.push_str(&" username:".to_string());
message.push_str(&data.get_username().to_string());
message
},
None => String::from("client not online"),
}
}