mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
fix(sqlx): minor blocking fixes
This commit is contained in:
parent
e10f1bf5d5
commit
ecec956f67
@ -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<()> {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"]
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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")]
|
||||
|
||||
@ -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")]
|
||||
|
||||
@ -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")),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user