X-Git-Url: http://git.euphorik.ch/?p=crypto_lab1.git;a=blobdiff_plain;f=lab1_rust%2Fsrc%2Fend_point.rs;h=83967dac4640651ecce039c4ecc277da7d58ccfe;hp=d2cedcb9ff2e511079eee11e6b6d021020e8ea0c;hb=d7f0bb987b21e93a5798403d294f7905151682f7;hpb=a8641e8dd205140af9206e82169ff5ad107c23f8 diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index d2cedcb..83967da 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -5,6 +5,7 @@ use std::thread::Thread; use packet; use packet::{ Packet, ReadingResult, PacketType }; use packet::PacketType::{ Command, Answer, Error }; +use utils::from_elem; // Default timeout when waiting data on a stream (for instance: 'TcpStream::read'). static DEFAULT_TIMEOUT: Option = Some(500); // [ms]. @@ -195,7 +196,7 @@ impl Client { // 5) |client: &mut Client| -> bool { println!("Sending a packet with too small data..."); - let command = Command(Packet::new_packet_data(0, Vec::from_elem(6, 0x00))); + let command = Command(Packet::new_packet_data(0, from_elem(6, 0x00))); match client.end_point.send_with_result(command) { Ok(Err(packet::ReadingError::IO( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => { @@ -207,7 +208,7 @@ impl Client { // 6) |client: &mut Client| -> bool { println!("Sending a packet with too large data..."); - let command = Command(Packet::new_packet_data(0, Vec::from_elem(40, 0x00))); + let command = Command(Packet::new_packet_data(0, from_elem(40, 0x00))); match client.end_point.send_with_result(command) { Ok(Err(packet::ReadingError::IO( IoError { kind: io::TimedOut, .. }))) => true, // OK: the server should not send any packet. other => {