Skip to content

Commit

Permalink
fust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydewaal committed Sep 26, 2024
1 parent 203a2b8 commit 64efad6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
3 changes: 1 addition & 2 deletions sqlx-core/src/any/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ impl AnyConnection {
#[cfg(feature = "migrate")]
pub(crate) fn get_migrate(
&mut self,
) -> crate::Result<&mut (dyn crate::migrate::Migrate + Send + 'static)>
{
) -> crate::Result<&mut (dyn crate::migrate::Migrate + Send + 'static)> {
self.backend.as_migrate()
}
}
Expand Down
12 changes: 9 additions & 3 deletions sqlx-core/src/any/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ impl AnyDriver {
{
Self {
migrate_database: Some(AnyMigrateDatabase {
create_database: DebugFn(|url| Box::pin(async move { DB::create_database(url).await })),
database_exists: DebugFn(|url| Box::pin(async move { DB::database_exists(url).await })),
create_database: DebugFn(|url| {
Box::pin(async move { DB::create_database(url).await })
}),
database_exists: DebugFn(|url| {
Box::pin(async move { DB::database_exists(url).await })
}),
drop_database: DebugFn(|url| Box::pin(async move { DB::drop_database(url).await })),
force_drop_database: DebugFn(|url| Box::pin(async move { DB::force_drop_database(url).await })),
force_drop_database: DebugFn(|url| {
Box::pin(async move { DB::force_drop_database(url).await })
}),
}),
..Self::without_migrate::<DB>()
}
Expand Down
20 changes: 13 additions & 7 deletions sqlx-core/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::database::{Database, HasStatementCache};
use std::future::Future;
use crate::error::Error;
use std::future::Future;

use crate::transaction::Transaction;
use futures_core::future::BoxFuture;
Expand Down Expand Up @@ -46,7 +46,9 @@ pub trait Connection: Send {
/// Begin a new transaction or establish a savepoint within the active transaction.
///
/// Returns a [`Transaction`] for controlling and tracking the new transaction.
fn begin(&mut self) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_
fn begin(
&mut self,
) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_
where
Self: Sized;

Expand All @@ -67,7 +69,10 @@ pub trait Connection: Send {
/// })).await
/// # }
/// ```
fn transaction<'a, F, R, E>(&'a mut self, callback: F) -> impl Future<Output = Result<R, E>> + Send + 'a
fn transaction<'a, F, R, E>(
&'a mut self,
callback: F,
) -> impl Future<Output = Result<R, E>> + Send + 'a
where
for<'c> F: FnOnce(&'c mut Transaction<'_, Self::Database>) -> BoxFuture<'c, Result<R, E>>
+ 'a
Expand Down Expand Up @@ -137,7 +142,7 @@ pub trait Connection: Send {
///
/// A value of [`Options`][Self::Options] is parsed from the provided connection string. This parsing
/// is database-specific.
#[inline]
#[inline]
fn connect(url: &str) -> impl Future<Output = Result<Self, Error>> + Send + 'static
where
Self: Sized,
Expand All @@ -147,11 +152,12 @@ pub trait Connection: Send {
async move { Self::connect_with(&options?).await }
}


/// Establish a new database connection with the provided options.
fn connect_with(options: &Self::Options) -> impl Future<Output = Result<Self, Error>> + Send + '_
fn connect_with(
options: &Self::Options,
) -> impl Future<Output = Result<Self, Error>> + Send + '_
where
Self: Sized
Self: Sized,
{
options.connect()
}
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/migrate/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::error::Error;
use crate::migrate::{AppliedMigration, MigrateError, Migration};
use futures_core::future::BoxFuture;
use std::time::Duration;
use std::future::Future;
use std::time::Duration;

pub trait MigrateDatabase {
// create database in url
Expand Down
4 changes: 3 additions & 1 deletion sqlx-core/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub trait TestSupport: Database {
///
/// The implementation may require `DATABASE_URL` to be set in order to manage databases.
/// The user credentials it contains must have the privilege to create and drop databases.
fn test_context(args: &TestArgs) -> impl Future<Output = Result<TestContext<Self>, Error>> + Send + '_;
fn test_context(
args: &TestArgs,
) -> impl Future<Output = Result<TestContext<Self>, Error>> + Send + '_;

fn cleanup_test(db_name: &str) -> impl Future<Output = Result<(), Error>> + Send + '_;

Expand Down
5 changes: 2 additions & 3 deletions sqlx-core/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::future::Future;
use std::fmt::{self, Debug, Formatter};
use std::future::Future;
use std::ops::{Deref, DerefMut};

use futures_core::future::BoxFuture;
Expand Down Expand Up @@ -31,7 +31,6 @@ pub trait TransactionManager {
conn: &mut <Self::Database as Database>::Connection,
) -> impl Future<Output = Result<(), Error>> + Send;


/// Starts to abort the active transaction or restore from the most recent snapshot.
fn start_rollback(conn: &mut <Self::Database as Database>::Connection);
}
Expand Down Expand Up @@ -233,7 +232,7 @@ impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'
type Connection = &'t mut <DB as Database>::Connection;

#[inline]
fn acquire(self) -> BoxFuture<'t, Result<Self::Connection, Error>> {
fn acquire(self) -> BoxFuture<'t, Result<Self::Connection, Error>> {
Box::pin(futures_util::future::ok(&mut **self))
}

Expand Down

0 comments on commit 64efad6

Please sign in to comment.