Skip to content

Commit 37a1502

Browse files
committed
fix: resolve large enum variant and naming warnings
- Box the TlsStream variant to reduce enum size - Rename from_iter methods to avoid confusion with std trait - Update all pattern matches to handle boxed variant
1 parent b064905 commit 37a1502

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

sqlx-core/src/net/tls/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898
S: AsyncRead + AsyncWrite + Unpin,
9999
{
100100
Raw(S),
101-
Tls(TlsStream<S>),
101+
Tls(Box<TlsStream<S>>),
102102
Upgrading,
103103
}
104104

@@ -135,24 +135,24 @@ where
135135
.map_err(|err| Error::Tls(err.into()))?
136136
.to_owned();
137137

138-
*self = MaybeTlsStream::Tls(connector.connect(host, stream).await?);
138+
*self = MaybeTlsStream::Tls(Box::new(connector.connect(host, stream).await?));
139139

140140
Ok(())
141141
}
142142

143143
pub fn downgrade(&mut self) -> Result<(), Error> {
144144
match replace(self, MaybeTlsStream::Upgrading) {
145-
MaybeTlsStream::Tls(stream) => {
145+
MaybeTlsStream::Tls(mut boxed_stream) => {
146146
#[cfg(feature = "_tls-rustls")]
147147
{
148-
let raw = stream.into_inner().0;
148+
let raw = boxed_stream.into_inner().0;
149149
*self = MaybeTlsStream::Raw(raw);
150150
Ok(())
151151
}
152152

153153
#[cfg(feature = "_tls-native-tls")]
154154
{
155-
let _ = stream; // Use the variable to avoid warning
155+
let _ = boxed_stream; // Use the variable to avoid warning
156156
return Err(Error::tls("No way to downgrade a native-tls stream, use rustls instead, or never disable tls"));
157157
}
158158
}
@@ -216,7 +216,7 @@ where
216216
) -> Poll<io::Result<super::PollReadOut>> {
217217
match &mut *self {
218218
MaybeTlsStream::Raw(s) => Pin::new(s).poll_read(cx, buf),
219-
MaybeTlsStream::Tls(s) => Pin::new(s).poll_read(cx, buf),
219+
MaybeTlsStream::Tls(s) => Pin::new(&mut **s).poll_read(cx, buf),
220220

221221
MaybeTlsStream::Upgrading => Poll::Ready(Err(io::ErrorKind::ConnectionAborted.into())),
222222
}
@@ -234,7 +234,7 @@ where
234234
) -> Poll<io::Result<usize>> {
235235
match &mut *self {
236236
MaybeTlsStream::Raw(s) => Pin::new(s).poll_write(cx, buf),
237-
MaybeTlsStream::Tls(s) => Pin::new(s).poll_write(cx, buf),
237+
MaybeTlsStream::Tls(s) => Pin::new(&mut **s).poll_write(cx, buf),
238238

239239
MaybeTlsStream::Upgrading => Poll::Ready(Err(io::ErrorKind::ConnectionAborted.into())),
240240
}
@@ -243,7 +243,7 @@ where
243243
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
244244
match &mut *self {
245245
MaybeTlsStream::Raw(s) => Pin::new(s).poll_flush(cx),
246-
MaybeTlsStream::Tls(s) => Pin::new(s).poll_flush(cx),
246+
MaybeTlsStream::Tls(s) => Pin::new(&mut **s).poll_flush(cx),
247247

248248
MaybeTlsStream::Upgrading => Poll::Ready(Err(io::ErrorKind::ConnectionAborted.into())),
249249
}
@@ -253,7 +253,7 @@ where
253253
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
254254
match &mut *self {
255255
MaybeTlsStream::Raw(s) => Pin::new(s).poll_shutdown(cx),
256-
MaybeTlsStream::Tls(s) => Pin::new(s).poll_shutdown(cx),
256+
MaybeTlsStream::Tls(s) => Pin::new(&mut **s).poll_shutdown(cx),
257257

258258
MaybeTlsStream::Upgrading => Poll::Ready(Err(io::ErrorKind::ConnectionAborted.into())),
259259
}
@@ -263,7 +263,7 @@ where
263263
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
264264
match &mut *self {
265265
MaybeTlsStream::Raw(s) => Pin::new(s).poll_close(cx),
266-
MaybeTlsStream::Tls(s) => Pin::new(s).poll_close(cx),
266+
MaybeTlsStream::Tls(s) => Pin::new(&mut **s).poll_close(cx),
267267

268268
MaybeTlsStream::Upgrading => Poll::Ready(Err(io::ErrorKind::ConnectionAborted.into())),
269269
}

sqlx-core/src/postgres/message/parse.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use crate::io::{BufMutExt, Encode};
32
use crate::postgres::io::PgBufMutExt;
43
use crate::postgres::types::Oid;

sqlx-core/src/postgres/types/lquery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl PgLQuery {
7575
}
7676

7777
/// creates lquery from an iterator with checking labels
78-
pub fn from_iter<I, S>(levels: I) -> Result<Self, PgLQueryParseError>
78+
pub fn from_level_iter<I, S>(levels: I) -> Result<Self, PgLQueryParseError>
7979
where
8080
S: Into<String>,
8181
I: IntoIterator<Item = S>,

sqlx-core/src/postgres/types/ltree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl PgLTree {
103103
}
104104

105105
/// creates ltree from an iterator with checking labels
106-
pub fn from_iter<I, S>(labels: I) -> Result<Self, PgLTreeParseError>
106+
pub fn from_label_iter<I, S>(labels: I) -> Result<Self, PgLTreeParseError>
107107
where
108108
String: From<S>,
109109
I: IntoIterator<Item = S>,

0 commit comments

Comments
 (0)