X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=lab1_rust%2Fsrc%2Fend_point.rs;h=128a017a167fb44536ad51a62347384c5a6feb9a;hb=fe03a7f9df6b8f4cf03e2399aeb68a7dc2605a67;hp=cb672260532ce9e56f6435f387e988e052234102;hpb=ed4d8f3e7e028bf645089edb775af84e6c3f7bd4;p=crypto_lab1.git diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index cb67226..128a017 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -8,7 +8,7 @@ use packet::{ Packet, Command, Answer, Error, ReadingResult, PacketType }; static DEFAULT_TIMEOUT: Option = Some(500); // [ms]. pub struct Server { - acceptor: TcpAcceptor + acceptor: TcpAcceptor, } pub struct Client { @@ -83,6 +83,7 @@ impl Client { }}) } + #[allow(dead_code)] pub fn close(&mut self) -> IoResult<()> { self.end_point.close() } @@ -117,7 +118,7 @@ impl Client { } } - /// Send some valid and not-valid packets to the server and check the result. + /// Sends some valid and not-valid packets to the server and check the result. /// For each test a new client is created. pub fn start_tests(address: &str, port: u16, variant: packet::Variant) { let execute = |f: &mut |&mut Client| -> bool| -> bool { @@ -257,6 +258,7 @@ impl EndPoint { EndPoint { socket: socket, current_timestamp: 0 , variant: variant} } + #[allow(dead_code)] fn close(&mut self) -> IoResult<()> { try!(self.socket.close_read()); try!(self.socket.close_write()); @@ -267,7 +269,7 @@ impl EndPoint { println!("[{}] time: {}. {}", prefix, self.current_timestamp, s); } - /// Send a packet and wait for an answer synchronously. + /// Sends a packet and wait for an answer synchronously. fn send_with_result(&mut self, p: PacketType) -> IoResult { match self.send(p) { Err(e) => Err(e), @@ -275,8 +277,8 @@ impl EndPoint { } } - /// Send arbitrary data and wait for an answer synchronously. - /// Do not increment the current timestamp. + /// Sends arbitrary data and wait for an answer synchronously. + /// Doesn't increment the current timestamp. pub fn send_raw_with_result(&mut self, p: &[u8]) -> IoResult { self.socket.set_timeout(DEFAULT_TIMEOUT); match self.socket.write(p) {