mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-05 01:43:48 +00:00
remove now unused pieces of ConnectionSource and MaybeOwnedConnection
This commit is contained in:
@@ -48,7 +48,6 @@ mod internal {
|
||||
where
|
||||
C: super::Connect,
|
||||
{
|
||||
Empty,
|
||||
Connection(MaybeOwnedConnection<'c, C>),
|
||||
Pool(super::Pool<C>),
|
||||
}
|
||||
@@ -56,18 +55,6 @@ mod internal {
|
||||
|
||||
pub(crate) use self::internal::{ConnectionSource, MaybeOwnedConnection};
|
||||
|
||||
impl<'c, C> MaybeOwnedConnection<'c, C>
|
||||
where
|
||||
C: Connect,
|
||||
{
|
||||
pub(crate) fn borrow(&mut self) -> &'_ mut C {
|
||||
match self {
|
||||
MaybeOwnedConnection::Borrowed(conn) => &mut *conn,
|
||||
MaybeOwnedConnection::Owned(ref mut conn) => conn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, C> ConnectionSource<'c, C>
|
||||
where
|
||||
C: Connect,
|
||||
@@ -79,37 +66,13 @@ where
|
||||
}
|
||||
|
||||
Ok(match self {
|
||||
ConnectionSource::Empty => panic!("`PgCursor` must not be used after being polled"),
|
||||
ConnectionSource::Connection(conn) => conn.borrow(),
|
||||
ConnectionSource::Connection(conn) => match conn {
|
||||
MaybeOwnedConnection::Borrowed(conn) => &mut *conn,
|
||||
MaybeOwnedConnection::Owned(ref mut conn) => conn,
|
||||
},
|
||||
ConnectionSource::Pool(_) => unreachable!(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn resolve(mut self) -> crate::Result<MaybeOwnedConnection<'c, C>> {
|
||||
if let ConnectionSource::Pool(pool) = self {
|
||||
self = ConnectionSource::Connection(MaybeOwnedConnection::Owned(pool.acquire().await?));
|
||||
}
|
||||
|
||||
Ok(self.into_connection())
|
||||
}
|
||||
|
||||
pub(crate) fn into_connection(self) -> MaybeOwnedConnection<'c, C> {
|
||||
match self {
|
||||
ConnectionSource::Connection(conn) => conn,
|
||||
ConnectionSource::Empty | ConnectionSource::Pool(_) => {
|
||||
panic!("`PgCursor` must not be used after being polled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Default for ConnectionSource<'_, C>
|
||||
where
|
||||
C: Connect,
|
||||
{
|
||||
fn default() -> Self {
|
||||
ConnectionSource::Empty
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, C> From<&'c mut C> for MaybeOwnedConnection<'c, C>
|
||||
@@ -129,29 +92,3 @@ where
|
||||
MaybeOwnedConnection::Owned(conn)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, C> Deref for MaybeOwnedConnection<'c, C>
|
||||
where
|
||||
C: Connect,
|
||||
{
|
||||
type Target = C;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
MaybeOwnedConnection::Borrowed(conn) => conn,
|
||||
MaybeOwnedConnection::Owned(conn) => conn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, C> DerefMut for MaybeOwnedConnection<'c, C>
|
||||
where
|
||||
C: Connect,
|
||||
{
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self {
|
||||
MaybeOwnedConnection::Borrowed(conn) => conn,
|
||||
MaybeOwnedConnection::Owned(conn) => conn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user