From 45f1c02027d0214bae66faf529bb9a865bf7f9b1 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Sun, 25 Aug 2019 14:55:38 -0700 Subject: [PATCH] Remove useless flush fn on postgres raw conn --- src/postgres/connection/establish.rs | 6 +++--- src/postgres/connection/execute.rs | 2 +- src/postgres/connection/fetch.rs | 2 +- src/postgres/connection/fetch_optional.rs | 2 +- src/postgres/connection/mod.rs | 6 ------ 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/postgres/connection/establish.rs b/src/postgres/connection/establish.rs index e076c761..14d085a4 100644 --- a/src/postgres/connection/establish.rs +++ b/src/postgres/connection/establish.rs @@ -38,7 +38,7 @@ pub async fn establish<'a, 'b: 'a>( let message = StartupMessage { params }; conn.write(message); - conn.flush().await?; + conn.stream.flush().await?; while let Some(message) = conn.receive().await? { match message { @@ -52,7 +52,7 @@ pub async fn establish<'a, 'b: 'a>( // FIXME: Should error early (before send) if the user did not supply a password conn.write(PasswordMessage::Cleartext(password)); - conn.flush().await?; + conn.stream.flush().await?; } Authentication::Md5Password { salt } => { @@ -63,7 +63,7 @@ pub async fn establish<'a, 'b: 'a>( salt, }); - conn.flush().await?; + conn.stream.flush().await?; } auth => { diff --git a/src/postgres/connection/execute.rs b/src/postgres/connection/execute.rs index ca46ff1d..6fdd923a 100644 --- a/src/postgres/connection/execute.rs +++ b/src/postgres/connection/execute.rs @@ -3,7 +3,7 @@ use crate::{error::Error, postgres::protocol::Message}; use std::io; pub async fn execute(conn: &mut PostgresRawConnection) -> Result { - conn.flush().await?; + conn.stream.flush().await?; let mut rows = 0; diff --git a/src/postgres/connection/fetch.rs b/src/postgres/connection/fetch.rs index f0335281..1b5e154c 100644 --- a/src/postgres/connection/fetch.rs +++ b/src/postgres/connection/fetch.rs @@ -7,7 +7,7 @@ pub fn fetch<'a>( conn: &'a mut PostgresRawConnection, ) -> impl Stream> + 'a { async_stream::try_stream! { - conn.flush().await?; + conn.stream.flush().await.map_err(Error::Io)?; while let Some(message) = conn.receive().await? { match message { diff --git a/src/postgres/connection/fetch_optional.rs b/src/postgres/connection/fetch_optional.rs index 42797920..b87f1d55 100644 --- a/src/postgres/connection/fetch_optional.rs +++ b/src/postgres/connection/fetch_optional.rs @@ -5,7 +5,7 @@ use std::io; pub async fn fetch_optional<'a>( conn: &'a mut PostgresRawConnection, ) -> Result, Error> { - conn.flush().await?; + conn.stream.flush().await?; let mut row: Option = None; diff --git a/src/postgres/connection/mod.rs b/src/postgres/connection/mod.rs index 232473dd..7aa2c7a1 100644 --- a/src/postgres/connection/mod.rs +++ b/src/postgres/connection/mod.rs @@ -123,12 +123,6 @@ impl PostgresRawConnection { pub(super) fn write(&mut self, message: impl Encode) { message.encode(self.stream.buffer_mut()); } - - async fn flush(&mut self) -> Result<(), Error> { - self.stream.flush().await?; - - Ok(()) - } } impl RawConnection for PostgresRawConnection {