mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-03 09:01:01 +00:00
chore: remove BoxFuture's (non-breaking) (#3629)
* chore: reduce BoxFuture's when using recursion. * remove BoxFuture's in WithSocket * chore: better document previous changes
This commit is contained in:
@@ -143,7 +143,10 @@ where
|
||||
pub trait WithSocket {
|
||||
type Output;
|
||||
|
||||
fn with_socket<S: Socket>(self, socket: S) -> Self::Output;
|
||||
fn with_socket<S: Socket>(
|
||||
self,
|
||||
socket: S,
|
||||
) -> impl std::future::Future<Output = Self::Output> + Send;
|
||||
}
|
||||
|
||||
pub struct SocketIntoBox;
|
||||
@@ -151,7 +154,7 @@ pub struct SocketIntoBox;
|
||||
impl WithSocket for SocketIntoBox {
|
||||
type Output = Box<dyn Socket>;
|
||||
|
||||
fn with_socket<S: Socket>(self, socket: S) -> Self::Output {
|
||||
async fn with_socket<S: Socket>(self, socket: S) -> Self::Output {
|
||||
Box::new(socket)
|
||||
}
|
||||
}
|
||||
@@ -197,7 +200,7 @@ pub async fn connect_tcp<Ws: WithSocket>(
|
||||
let stream = TcpStream::connect((host, port)).await?;
|
||||
stream.set_nodelay(true)?;
|
||||
|
||||
return Ok(with_socket.with_socket(stream));
|
||||
return Ok(with_socket.with_socket(stream).await);
|
||||
}
|
||||
|
||||
#[cfg(feature = "_rt-async-std")]
|
||||
@@ -217,7 +220,7 @@ pub async fn connect_tcp<Ws: WithSocket>(
|
||||
Ok(s)
|
||||
});
|
||||
match stream {
|
||||
Ok(stream) => return Ok(with_socket.with_socket(stream)),
|
||||
Ok(stream) => return Ok(with_socket.with_socket(stream).await),
|
||||
Err(e) => last_err = Some(e),
|
||||
}
|
||||
}
|
||||
@@ -255,7 +258,7 @@ pub async fn connect_uds<P: AsRef<Path>, Ws: WithSocket>(
|
||||
|
||||
let stream = UnixStream::connect(path).await?;
|
||||
|
||||
return Ok(with_socket.with_socket(stream));
|
||||
return Ok(with_socket.with_socket(stream).await);
|
||||
}
|
||||
|
||||
#[cfg(feature = "_rt-async-std")]
|
||||
@@ -265,7 +268,7 @@ pub async fn connect_uds<P: AsRef<Path>, Ws: WithSocket>(
|
||||
|
||||
let stream = Async::<UnixStream>::connect(path).await?;
|
||||
|
||||
Ok(with_socket.with_socket(stream))
|
||||
Ok(with_socket.with_socket(stream).await)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "_rt-async-std"))]
|
||||
|
||||
@@ -75,10 +75,14 @@ where
|
||||
Ws: WithSocket,
|
||||
{
|
||||
#[cfg(feature = "_tls-native-tls")]
|
||||
return Ok(with_socket.with_socket(tls_native_tls::handshake(socket, config).await?));
|
||||
return Ok(with_socket
|
||||
.with_socket(tls_native_tls::handshake(socket, config).await?)
|
||||
.await);
|
||||
|
||||
#[cfg(all(feature = "_tls-rustls", not(feature = "_tls-native-tls")))]
|
||||
return Ok(with_socket.with_socket(tls_rustls::handshake(socket, config).await?));
|
||||
return Ok(with_socket
|
||||
.with_socket(tls_rustls::handshake(socket, config).await?)
|
||||
.await);
|
||||
|
||||
#[cfg(not(any(feature = "_tls-native-tls", feature = "_tls-rustls")))]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user