From: Ummon Date: Sun, 2 Nov 2014 22:36:34 +0000 (+0100) Subject: Clean some warnings. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=68e7d763a544d163073b1ba059b445676beb15c6;p=crypto_lab1.git Clean some warnings. --- diff --git a/src/end_point.rs b/src/end_point.rs index 199fff7..6ed1fad 100644 --- a/src/end_point.rs +++ b/src/end_point.rs @@ -1,3 +1,4 @@ +use std::io; use std::io::{ MemWriter, Acceptor, Listener, TcpStream, IoResult, IoError, EndOfFile }; use std::io::net::tcp::{ TcpAcceptor, TcpListener }; use packet; @@ -118,7 +119,7 @@ impl Client { fn raw_packet(timestamp: u64) -> Vec { let mut m = MemWriter::new(); match (Packet { t: Command(Packet::random_packet_data([42])), timestamp: timestamp }).write(&mut m) { - Err(e) => vec!(), + Err(_) => vec!(), _ => m.unwrap() } } @@ -127,7 +128,7 @@ impl Client { |client: &mut Client| -> bool { println!("Send a valid packet..."); match client.end_point.send_with_result(Command(Packet::random_packet_data([42]))) { - Ok(Ok(packet@Packet { t: Answer(..), .. })) => true, + Ok(Ok(Packet { t: Answer(..), .. })) => true, other => { println!("Error: {}", other); false @@ -141,7 +142,7 @@ impl Client { let mut raw_packet = raw_packet(client.end_point.current_timestamp); raw_packet[2] = 0xEE; // Alter the type. match client.end_point.send_raw_with_result(raw_packet.as_slice()) { - Ok(Err(packet::IOReadError( IoError { kind: TimedOut, .. }))) => true, // OK: the server should not send any packet. + Ok(Err(packet::IOReadError( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => { println!("Error: {}", other); false @@ -154,7 +155,7 @@ impl Client { client.end_point.current_timestamp += 1; let raw_packet = raw_packet(0); match client.end_point.send_raw_with_result(raw_packet.as_slice()) { - Ok(Err(packet::IOReadError( IoError { kind: TimedOut, .. }))) => true, // OK: the server should not send any packet. + Ok(Err(packet::IOReadError( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => { println!("Error: {}", other); false @@ -171,7 +172,7 @@ impl Client { raw_packet[13] = 0xBE; raw_packet[14] = 0xEF; match client.end_point.send_raw_with_result(raw_packet.as_slice()) { - Ok(Ok(packet@Packet { t: Error(packet::AuthError), .. })) => true, + Ok(Ok(Packet { t: Error(packet::AuthError), .. })) => true, other => { println!("Error: {}", other); false @@ -181,9 +182,9 @@ impl Client { |client: &mut Client| -> bool { println!("Send a packet with too small data..."); - let mut command = Command(Packet::new_packet_data(0, Vec::from_elem(6, 0x00))); + let command = Command(Packet::new_packet_data(0, Vec::from_elem(6, 0x00))); match client.end_point.send_with_result(command) { - Ok(Err(packet::IOReadError( IoError { kind: TimedOut, .. }))) => true, // OK: the server should not send any packet. + Ok(Err(packet::IOReadError( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => { println!("Error: {}", other); false @@ -193,9 +194,9 @@ impl Client { |client: &mut Client| -> bool { println!("Send a packet with too large data..."); - let mut command = Command(Packet::new_packet_data(0, Vec::from_elem(40, 0x00))); + let command = Command(Packet::new_packet_data(0, Vec::from_elem(40, 0x00))); match client.end_point.send_with_result(command) { - Ok(Err(packet::IOReadError( IoError { kind: TimedOut, .. }))) => true, // OK: the server should not send any packet. + Ok(Err(packet::IOReadError( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => { println!("Error: {}", other); false @@ -208,12 +209,12 @@ impl Client { client.end_point.current_timestamp += 1; let mut m = MemWriter::new(); let raw_packet = match (Packet { t: Command(Packet::random_packet_data([42])), timestamp: client.end_point.current_timestamp }).write_with_padding_fun(&mut m, |_, _| -> u8 { 0 }) { - Err(e) => vec!(), + Err(_) => vec!(), _ => m.unwrap() }; match client.end_point.send_raw_with_result(raw_packet.as_slice()) { - Ok(Ok(packet@Packet { t: Error(packet::CryptError), .. })) => true, + Ok(Ok(Packet { t: Error(packet::CryptError), .. })) => true, other => { println!("Error: {}", other); false