fix(sqlx): minor blocking fixes

This commit is contained in:
Ryan Leckey 2021-01-20 19:48:41 -08:00
parent e10f1bf5d5
commit ecec956f67
No known key found for this signature in database
GPG Key ID: F8AA68C235AB08C9
8 changed files with 23 additions and 25 deletions

View File

@ -108,10 +108,10 @@ impl<Rt: Runtime> Close<Rt> for MySqlConnection<Rt> {
#[cfg(feature = "blocking")]
mod blocking {
use super::{MySqlConnectOptions, MySqlConnection};
use sqlx_core::blocking::{Close, Connect, Connection, Runtime};
use super::{MySqlConnectOptions, MySqlConnection};
impl<Rt: Runtime> Connection<Rt> for MySqlConnection<Rt> {
#[inline]
fn ping(&mut self) -> sqlx_core::Result<()> {

View File

@ -88,10 +88,10 @@ where
#[cfg(feature = "blocking")]
mod blocking {
use super::{MySqlConnectOptions, MySqlConnection};
use sqlx_core::blocking::{ConnectOptions, Runtime};
use super::{MySqlConnectOptions, MySqlConnection};
impl<Rt: Runtime> ConnectOptions<Rt> for MySqlConnectOptions<Rt> {
fn connect(&self) -> sqlx_core::Result<Self::Connection>
where

View File

@ -21,7 +21,7 @@ blocking = ["sqlx-core/blocking"]
# abstract async runtime
# not meant to be used directly
# activates several crates used in all async runtimes
async = ["futures-util"]
async = ["futures-util", "sqlx-core/async"]
# async runtimes
async-std = ["async", "sqlx-core/async-std"]

View File

@ -1,4 +1,4 @@
use crate::blocking::{self, Close, Connect, Connection, Runtime};
use crate::blocking::{Close, Connect, Connection, Runtime};
use crate::mysql::connection::MySqlConnection;
use crate::{Blocking, Result};
@ -40,20 +40,20 @@ impl MySqlConnection<Blocking> {
impl<Rt: Runtime> Close<Rt> for MySqlConnection<Rt> {
#[inline]
fn close(self) -> Result<()> {
self.close()
self.0.close()
}
}
impl<Rt: Runtime> Connect<Rt> for MySqlConnection<Rt> {
#[inline]
fn connect(url: &str) -> Result<Self> {
Self::connect(url)
sqlx_mysql::MySqlConnection::<Rt>::connect(url).map(Self)
}
}
impl<Rt: Runtime> Connection<Rt> for MySqlConnection<Rt> {
#[inline]
fn ping(&mut self) -> Result<()> {
self.ping()
self.0.ping()
}
}

View File

@ -9,20 +9,20 @@ impl MySqlConnectOptions<Blocking> {
/// this: [`connect`](#method.connect).
///
/// Implemented with [`ConnectOptions::connect`].
pub fn connect(&self) -> Result<MySqlConnectOptions<Blocking>> {
<sqlx_mysql::MySqlConnectOptions<Rt> as ConnectOptions<Rt>>::connect(&self.0)
.map(MySqlConnectOptions::<Blocking>)
#[inline]
pub fn connect(&self) -> Result<MySqlConnection<Blocking>> {
<sqlx_mysql::MySqlConnectOptions<Blocking> as ConnectOptions<Blocking>>::connect(&self.0)
.map(MySqlConnection::<Blocking>)
}
}
impl<Rt> ConnectOptions<Rt> for MySqlConnectOptions<Rt>
where
Rt: Runtime,
{
impl<Rt: Runtime> ConnectOptions<Rt> for MySqlConnectOptions<Rt> {
#[inline]
fn connect(&self) -> Result<Self::Connection>
where
Self::Connection: Sized,
{
self.connect()
<sqlx_mysql::MySqlConnectOptions<Rt> as ConnectOptions<Rt>>::connect(&self.0)
.map(MySqlConnection::<Rt>)
}
}

View File

@ -1,7 +1,7 @@
use std::fmt::{self, Debug, Formatter};
#[cfg(feature = "async")]
use futures_util::future::{BoxFuture, FutureExt, TryFutureExt};
use futures_util::future::{BoxFuture, FutureExt};
use super::{MySql, MySqlConnectOptions};
#[cfg(feature = "async")]

View File

@ -2,7 +2,7 @@ use std::fmt::{self, Debug, Formatter};
use std::str::FromStr;
#[cfg(feature = "async")]
use futures_util::future::{BoxFuture, FutureExt, TryFutureExt};
use futures_util::future::{BoxFuture, FutureExt};
use crate::mysql::MySqlConnection;
#[cfg(feature = "async")]

View File

@ -3,14 +3,12 @@
// make it more convenient, if your application only uses 1 runtime (99%+)
// most of the time you won't have to worry about picking the runtime
mod default {
#[cfg(feature = "async-std")]
pub use sqlx_core::AsyncStd as Runtime;
#[cfg(all(not(feature = "async-std"), feature = "tokio"))]
pub use sqlx_core::Tokio as Runtime;
#[cfg(all(not(all(feature = "async-std", feature = "tokio")), feature = "actix"))]
pub use sqlx_core::Actix as Runtime;
#[cfg(feature = "async-std")]
pub use sqlx_core::AsyncStd as Runtime;
#[cfg(all(not(feature = "async-std"), feature = "tokio"))]
pub use sqlx_core::Tokio as Runtime;
#[cfg(all(
not(any(feature = "async-std", feature = "tokio", feature = "actix")),