Skip to content

Commit 3b4d142

Browse files
committed
Hide DisconnectPool
The only thing a user could do with it is await, so there is no need to expose the type.
1 parent 01efa4c commit 3b4d142

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

src/conn/pool/futures/disconnect_pool.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ use std::sync::{atomic, Arc};
2929
/// are dropped or disonnected. Also all pending and new `GetConn`'s will resolve to error.
3030
#[derive(Debug)]
3131
#[must_use = "futures do nothing unless you `.await` or poll them"]
32-
pub struct DisconnectPool {
32+
struct DisconnectPool {
3333
pool_inner: Arc<Inner>,
3434
drop: Option<UnboundedSender<Option<Conn>>>,
3535
}
3636

3737
impl DisconnectPool {
38-
pub(crate) fn new(pool: Pool) -> Self {
38+
fn new(pool: Pool) -> Self {
3939
Self {
4040
pool_inner: pool.inner,
4141
drop: Some(pool.drop),
@@ -73,3 +73,7 @@ impl Future for DisconnectPool {
7373
}
7474
}
7575
}
76+
77+
pub(crate) async fn disconnect_pool(pool: Pool) -> Result<(), Error> {
78+
DisconnectPool::new(pool).await
79+
}

src/conn/pool/futures/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// option. All files in the project carrying such notice may not be copied,
77
// modified, or distributed except according to those terms.
88

9+
pub use self::get_conn::GetConn;
910
pub(super) use self::get_conn::GetConnInner;
10-
pub use self::{disconnect_pool::DisconnectPool, get_conn::GetConn};
11+
pub(crate) use disconnect_pool::disconnect_pool;
1112

1213
mod disconnect_pool;
1314
mod get_conn;

src/conn/pool/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ impl Pool {
287287
///
288288
/// **Note:** This Future won't resolve until all active connections, taken from it,
289289
/// are dropped or disonnected. Also all pending and new `GetConn`'s will resolve to error.
290-
pub fn disconnect(self) -> DisconnectPool {
291-
DisconnectPool::new(self)
290+
pub async fn disconnect(self) -> Result<()> {
291+
disconnect_pool(self).await
292292
}
293293

294294
/// A way to return connection taken from a pool.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ pub use crate::connection_like::{Connection, ToConnectionResult};
558558

559559
/// Futures used in this crate
560560
pub mod futures {
561-
pub use crate::conn::pool::futures::{DisconnectPool, GetConn};
561+
pub use crate::conn::pool::futures::GetConn;
562562
}
563563

564564
/// Traits used in this crate

tests/exports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[allow(unused_imports)]
22
use mysql_async::{
33
consts, from_row, from_row_opt, from_value, from_value_opt,
4-
futures::{DisconnectPool, GetConn},
4+
futures::GetConn,
55
params,
66
prelude::{
77
BatchQuery, FromRow, FromValue, GlobalHandler, Protocol, Query, Queryable, StatementLike,

0 commit comments

Comments
 (0)