From d48573a28eee5ac154fc9cd70e7cd033011dc5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 4 Jul 2020 13:47:22 +0200 Subject: [PATCH] aquatic_http: network: update inline hints, format code --- aquatic_http/src/lib/network/connection.rs | 15 ++++++++++++--- aquatic_http/src/lib/network/mod.rs | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/aquatic_http/src/lib/network/connection.rs b/aquatic_http/src/lib/network/connection.rs index 39af0f3..2b602e4 100644 --- a/aquatic_http/src/lib/network/connection.rs +++ b/aquatic_http/src/lib/network/connection.rs @@ -33,6 +33,7 @@ pub struct EstablishedConnection { impl EstablishedConnection { + #[inline] fn new(stream: Stream) -> Self { let peer_addr = stream.get_peer_addr(); @@ -113,6 +114,7 @@ impl EstablishedConnection { Ok(()) } + #[inline] pub fn clear_buffer(&mut self){ self.bytes_read = 0; self.buf = Vec::new(); @@ -152,7 +154,6 @@ impl <'a>TlsHandshakeMachine { /// Attempt to establish a TLS connection. On a WouldBlock error, return /// the machine wrapped in an error for later attempts. - #[inline] pub fn establish_tls(self) -> Result { let handshake_result = match self.inner { TlsHandshakeMachineInner::TcpStream(stream) => { @@ -212,9 +213,13 @@ impl Connection { ) -> Self { // Setup handshake machine if TLS is requested let inner = if let Some(tls_acceptor) = opt_tls_acceptor { - ConnectionInner::InProgress(TlsHandshakeMachine::new(tls_acceptor.clone(), tcp_stream)) + ConnectionInner::InProgress( + TlsHandshakeMachine::new(tls_acceptor.clone(), tcp_stream) + ) } else { - ConnectionInner::Established(EstablishedConnection::new(Stream::TcpStream(tcp_stream))) + ConnectionInner::Established( + EstablishedConnection::new(Stream::TcpStream(tcp_stream)) + ) }; Self { @@ -223,6 +228,7 @@ impl Connection { } } + #[inline] pub fn from_established( valid_until: ValidUntil, established: EstablishedConnection, @@ -233,6 +239,7 @@ impl Connection { } } + #[inline] pub fn from_in_progress( valid_until: ValidUntil, machine: TlsHandshakeMachine, @@ -243,6 +250,7 @@ impl Connection { } } + #[inline] pub fn get_established(&mut self) -> Option<&mut EstablishedConnection> { if let ConnectionInner::Established(ref mut established) = self.inner { Some(established) @@ -251,6 +259,7 @@ impl Connection { } } + #[inline] pub fn get_in_progress(self) -> Option { if let ConnectionInner::InProgress(machine) = self.inner { Some(machine) diff --git a/aquatic_http/src/lib/network/mod.rs b/aquatic_http/src/lib/network/mod.rs index 2b23757..fdaa351 100644 --- a/aquatic_http/src/lib/network/mod.rs +++ b/aquatic_http/src/lib/network/mod.rs @@ -150,7 +150,11 @@ fn accept_new_streams( .register(&mut stream, token, Interest::READABLE) .unwrap(); - let connection = Connection::new(opt_tls_acceptor, valid_until, stream); + let connection = Connection::new( + opt_tls_acceptor, + valid_until, + stream + ); connections.insert(token, connection); },