Allowing dead code

This commit is contained in:
michael-bailey 2020-09-27 16:50:09 +01:00
parent cfd9388979
commit e98c5c58a5
7 changed files with 22 additions and 0 deletions

View File

@ -8,6 +8,7 @@ use crate::{
server::client::client_profile::Client,
};
#[allow(dead_code)]
pub struct ClientApi {
socket: TcpStream,
addr: String,
@ -17,6 +18,8 @@ pub struct ClientApi {
}
impl ClientApi {
#[allow(dead_code)]
pub fn new(addr: &str) -> Result<Self, io::Error> {
let socket = TcpStream::connect(addr)?;
@ -31,14 +34,17 @@ impl ClientApi {
Ok(a)
}
#[allow(dead_code)]
pub fn set_on_client_add(&mut self, func: fn(Client) -> ()) {
self.on_client_add_handle = func;
}
#[allow(dead_code)]
pub fn set_on_client_removed(&mut self, func: fn(String) -> ()) {
self.on_client_remove_handle = func;
}
#[allow(dead_code)]
pub fn get_info(host: &str) -> Result<Commands, io::Error> {
let mut buffer: [u8; 1024] = [0; 1024];
let addr = host.parse().unwrap();

View File

@ -52,6 +52,7 @@ pub enum Commands {
Error(Option<HashMap<String, String>>),
}
#[allow(dead_code)]
#[derive(Debug)]
pub enum CommandParseError {
UnknownCommand,

View File

@ -17,6 +17,7 @@ pub struct ThreadPool{
type Job = Box<dyn FnOnce() + Send + 'static>;
#[allow(dead_code)]
impl ThreadPool{
/// Create a new ThreadPool.
///

View File

@ -43,6 +43,7 @@ pub struct Client {
}
impl Client {
#[allow(dead_code)]
pub fn new(stream: TcpStream, server_sender: Sender<ServerMessages>, uuid: &str, username: &str, address: &str) -> Self {
let (sender, receiver): (Sender<Commands>, Receiver<Commands>) = unbounded();
stream.set_read_timeout(Some(Duration::from_secs(1))).unwrap();
@ -83,6 +84,7 @@ impl Client {
}
// TODO: - add heartbeat timer.
#[allow(dead_code)]
pub fn handle_connection(&mut self) {
let mut buffer = [0; 1024];
@ -180,6 +182,7 @@ impl Client {
self.stream.lock().unwrap().shutdown(Shutdown::Both).expect("shutdown call failed");
}
#[allow(dead_code)]
pub fn send_data(&self, data: &str) {
println!("Transmitting data: {}", data);
@ -195,6 +198,7 @@ impl Client {
}
}
#[allow(dead_code)]
fn read_data(&mut self, buffer: &mut [u8; 1024]) -> Result<Commands, Error> {
let _ = self.stream.lock().unwrap().read(buffer)?;
let command = Commands::from(buffer);

View File

@ -30,6 +30,7 @@ pub enum ServerMessages {
}
// MARK: - server struct
#[allow(dead_code)]
pub struct Server {
pub name: String,
pub address: String,
@ -213,6 +214,7 @@ impl Server {
Ok(())
}
#[allow(dead_code)]
pub fn stop(&mut self) {
info!("server: sending stop message");
let _ = self.sender.send(ServerMessages::Shutdown);

View File

@ -14,6 +14,7 @@ pub enum ServerMessages {
Shutdown,
}
#[allow(dead_code)]
pub enum ServerState {
starting,
started,
@ -22,6 +23,7 @@ pub enum ServerState {
}
// MARK: - server struct
#[allow(dead_code)]
pub struct Server {
pub name: String,
pub address: String,
@ -95,6 +97,7 @@ impl Server {
self.owner.clone()
}
#[allow(dead_code)]
pub fn tick(&mut self) {
// check to see if this server is ready to execute things.
@ -232,6 +235,7 @@ impl Server {
}
}
#[allow(dead_code)]
pub fn start(&mut self) -> Result<(), io::Error> {
let listener = TcpListener::bind(self.address)?;
@ -240,12 +244,14 @@ impl Server {
self.listener = Some(listener);
}
#[allow(dead_code)]
pub fn stop(&mut self) {
info!("server: sending stop message");
let _ = self.sender.send(ServerMessages::Shutdown);
self.state = ServerState::stopping;
}
#[allow(dead_code)]
fn send_data(stream: &mut TcpStream, data: &str) -> Result<(), io::Error>{
println!("Transmitting...");
println!("data: {}", data);
@ -260,6 +266,7 @@ impl Server {
Ok(())
}
#[allow(dead_code)]
fn recv_data(stream: &mut TcpStream, buffer: &mut [u8; 1024]) -> Result<Commands, io::Error> {
let _ = stream.read(buffer)?;
let command = Commands::from(buffer);

View File

@ -3,6 +3,7 @@ use cursive::view::SizeConstraint;
use cursive::views::{LinearLayout, ListView, Panel, ResizedView, TextView};
use crate::server::server_v3::Server;
#[allow(dead_code)]
pub fn control_panel(s: &mut Cursive) -> Box<dyn View> {
Box::new(
ResizedView::new(