Skip to content

Commit

Permalink
Simplify the creation of ClientRecord in close
Browse files Browse the repository at this point in the history
This commit removes the if/let expression in async TLsConnection's
close method and instead uses the the bool opened as the value of the
encrypted argument passed to ClientRecord::Alert.
  • Loading branch information
danbev authored and lulf committed Oct 13, 2021
1 parent 566323b commit a177705
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/tls_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,9 @@ where

/// Close a connection instance, returning the ownership of the config, random generator and the async I/O provider.
pub async fn close(self) -> Result<(TlsContext<'a, CipherSuite, RNG>, Socket), TlsError> {
let record = if self.opened {
ClientRecord::Alert(
Alert::new(AlertLevel::Warning, AlertDescription::CloseNotify),
true,
)
} else {
ClientRecord::Alert(
Alert::new(AlertLevel::Warning, AlertDescription::CloseNotify),
false,
)
};
let record = ClientRecord::Alert(
Alert::new(AlertLevel::Warning, AlertDescription::CloseNotify),
self.opened);

let mut key_schedule = self.key_schedule;
let mut delegate = self.delegate;
Expand Down

0 comments on commit a177705

Please sign in to comment.