From 9cdc634f2ce4d0e88f4d3af1d6f555a5449da189 Mon Sep 17 00:00:00 2001 From: Ummon Date: Tue, 9 Dec 2014 11:24:02 +0100 Subject: [PATCH] Test the new syntax 'if let'. --- lab1_rust/Cargo.lock | 4 ++-- lab1_rust/src/end_point.rs | 7 +++---- lab1_rust/src/packet.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lab1_rust/Cargo.lock b/lab1_rust/Cargo.lock index d718268..7f3c078 100644 --- a/lab1_rust/Cargo.lock +++ b/lab1_rust/Cargo.lock @@ -8,7 +8,7 @@ dependencies = [ [[package]] name = "openssl" version = "0.2.2" -source = "git+https://github.com/sfackler/rust-openssl.git#b8a41f79a1a78791dddd453db0aab5f0957152fc" +source = "git+https://github.com/sfackler/rust-openssl.git#6cdd2cf577434ca3473c217e8a272ee965ef131f" dependencies = [ "openssl-sys 0.2.2 (git+https://github.com/sfackler/rust-openssl.git)", ] @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "openssl-sys" version = "0.2.2" -source = "git+https://github.com/sfackler/rust-openssl.git#b8a41f79a1a78791dddd453db0aab5f0957152fc" +source = "git+https://github.com/sfackler/rust-openssl.git#6cdd2cf577434ca3473c217e8a272ee965ef131f" dependencies = [ "pkg-config 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index f69f78e..97104c6 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -299,10 +299,9 @@ impl EndPoint { fn read(&mut self) -> ReadingResult { fn send_error(ep: &mut EndPoint, error_type: packet::ErrorType) { - match ep.send(Error(error_type)) { - Err(e) => println!("Unable to send error packet: {}", e), - Ok(_) => () - }; + if let Err(e) = ep.send(Error(error_type)) { + println!("Unable to send error packet: {}", e) + } }; self.socket.set_timeout(DEFAULT_TIMEOUT); diff --git a/lab1_rust/src/packet.rs b/lab1_rust/src/packet.rs index 4016ccb..7e9c38c 100644 --- a/lab1_rust/src/packet.rs +++ b/lab1_rust/src/packet.rs @@ -77,12 +77,12 @@ pub enum PacketType { /// 0x0A: Decrypt error /// 0x0B: Authentication error /// TTTTTTTT: Timestamp (64 bits) -/// D...D: Encrypted data (AES-256 CBC mode) of: -/// |I|C...C|P...P| for command and answer packet: -/// I: Command ID -/// C: Command payload (from 7 to 39 bytes) -/// P: Padding from 1 to 16, |I|C...C|P...P| size must be a multiple of 16 -/// |0000000000000000| for error packet (16 bytes length) +/// D...D: Encrypted data (AES-256 CBC mode) of: +/// |I|C...C|P...P| for command and answer packet: +/// I: Command ID +/// C: Command payload (from 7 to 39 bytes) +/// P: Padding from 1 to 16, |I|C...C|P...P| size must be a multiple of 16 +/// |0000000000000000| for error packet (16 bytes length) /// MMMMMMMMMM: first 10 bytes (most significant) of the HMAC-SHA256 of: /// for command and answer packet: /// |I|C...C| for weak variant -- 2.43.0