From e719f698f41e4807282b25a5085ecf35583833cb Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 14 Jan 2021 19:01:39 -0800 Subject: [PATCH] polish: collapse a couple async/blocking groups --- sqlx-core/src/close.rs | 1 - sqlx-mysql/src/connection/connect.rs | 15 ++++++--------- sqlx-mysql/src/connection/stream.rs | 11 ++++------- sqlx-mysql/src/options.rs | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/sqlx-core/src/close.rs b/sqlx-core/src/close.rs index f8c840743..0a0ee797f 100644 --- a/sqlx-core/src/close.rs +++ b/sqlx-core/src/close.rs @@ -1,6 +1,5 @@ use crate::Runtime; -// for<'a> &'a mut Rt::TcpStream: crate::io::Stream<'a>, pub trait Close where Rt: Runtime, diff --git a/sqlx-mysql/src/connection/connect.rs b/sqlx-mysql/src/connection/connect.rs index c76be1e0d..a0f763662 100644 --- a/sqlx-mysql/src/connection/connect.rs +++ b/sqlx-mysql/src/connection/connect.rs @@ -114,26 +114,23 @@ macro_rules! connect { }}; } -#[cfg(feature = "async")] impl MySqlConnection where Rt: sqlx_core::Runtime, { + #[cfg(feature = "async")] pub(crate) async fn connect_async(options: &MySqlConnectOptions) -> Result where Rt: sqlx_core::Async, - for<'s> Rt::TcpStream: sqlx_core::io::Stream<'s, Rt>, { connect!(options) } -} -#[cfg(feature = "blocking")] -impl MySqlConnection -where - Rt: sqlx_core::blocking::Runtime, -{ - pub(crate) fn connect(options: &MySqlConnectOptions) -> Result { + #[cfg(feature = "blocking")] + pub(crate) fn connect(options: &MySqlConnectOptions) -> Result + where + Rt: sqlx_core::blocking::Runtime, + { connect!(@blocking options) } } diff --git a/sqlx-mysql/src/connection/stream.rs b/sqlx-mysql/src/connection/stream.rs index 938bf1c13..ad60ab0b3 100644 --- a/sqlx-mysql/src/connection/stream.rs +++ b/sqlx-mysql/src/connection/stream.rs @@ -134,11 +134,12 @@ macro_rules! read_packet { }; } -#[cfg(feature = "async")] impl MySqlConnection where Rt: Runtime, { + #[cfg(feature = "async")] + pub(super) async fn read_packet_async<'de, T>(&'de mut self) -> Result where T: Deserialize<'de, Capabilities> + Debug, @@ -146,13 +147,9 @@ where { read_packet!(self) } -} -#[cfg(feature = "blocking")] -impl MySqlConnection -where - Rt: Runtime, -{ + #[cfg(feature = "blocking")] + pub(super) fn read_packet<'de, T>(&'de mut self) -> Result where T: Deserialize<'de, Capabilities> + Debug, diff --git a/sqlx-mysql/src/options.rs b/sqlx-mysql/src/options.rs index 67d1bf31c..11dc013fa 100644 --- a/sqlx-mysql/src/options.rs +++ b/sqlx-mysql/src/options.rs @@ -145,7 +145,7 @@ where Self::Connection: Sized, Rt: sqlx_core::Async, { - Box::pin(MySqlConnection::connect_async(self)) + Box::pin(MySqlConnection::::connect_async(self)) } }