Skip to content

Commit f8311dd

Browse files
committed
pool: make relevant items pub
Currently `pool` is not pub, and nothing `pub` uses it, so it isn't accessible. This exposes them for use.
1 parent 446001b commit f8311dd

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/client/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// A marker to identify what version a pooled connection is.
22
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
33
#[allow(dead_code)]
4-
pub(super) enum Ver {
4+
pub enum Ver {
55
Auto,
66
Http2,
77
}

src/client/pool.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::common::{exec::Exec, ready};
2323

2424
// FIXME: allow() required due to `impl Trait` leaking types to this lint
2525
#[allow(missing_debug_implementations)]
26-
pub(super) struct Pool<T> {
26+
pub struct Pool<T> {
2727
// If the pool is disabled, this is None.
2828
inner: Option<Arc<Mutex<PoolInner<T>>>>,
2929
}
@@ -33,7 +33,7 @@ pub(super) struct Pool<T> {
3333
// This is a trait to allow the `client::pool::tests` to work for `i32`.
3434
//
3535
// See https://github.com/hyperium/hyper/issues/1429
36-
pub(super) trait Poolable: Unpin + Send + Sized + 'static {
36+
pub trait Poolable: Unpin + Send + Sized + 'static {
3737
fn is_open(&self) -> bool;
3838
/// Reserve this connection.
3939
///
@@ -49,7 +49,7 @@ pub(super) trait Poolable: Unpin + Send + Sized + 'static {
4949
/// used for multiple requests.
5050
// FIXME: allow() required due to `impl Trait` leaking types to this lint
5151
#[allow(missing_debug_implementations)]
52-
pub(super) enum Reservation<T> {
52+
pub enum Reservation<T> {
5353
/// This connection could be used multiple times, the first one will be
5454
/// reinserted into the `idle` pool, and the second will be given to
5555
/// the `Checkout`.
@@ -61,7 +61,7 @@ pub(super) enum Reservation<T> {
6161
}
6262

6363
/// Simple type alias in case the key type needs to be adjusted.
64-
pub(super) type Key = (http::uri::Scheme, http::uri::Authority); //Arc<String>;
64+
pub type Key = (http::uri::Scheme, http::uri::Authority); //Arc<String>;
6565

6666
struct PoolInner<T> {
6767
// A flag that a connection is being established, and the connection
@@ -96,19 +96,19 @@ struct PoolInner<T> {
9696
struct WeakOpt<T>(Option<Weak<T>>);
9797

9898
#[derive(Clone, Copy, Debug)]
99-
pub(super) struct Config {
100-
pub(super) idle_timeout: Option<Duration>,
101-
pub(super) max_idle_per_host: usize,
99+
pub struct Config {
100+
pub idle_timeout: Option<Duration>,
101+
pub max_idle_per_host: usize,
102102
}
103103

104104
impl Config {
105-
pub(super) fn is_enabled(&self) -> bool {
105+
pub fn is_enabled(&self) -> bool {
106106
self.max_idle_per_host > 0
107107
}
108108
}
109109

110110
impl<T> Pool<T> {
111-
pub(super) fn new(config: Config, __exec: &Exec) -> Pool<T> {
111+
pub fn new(config: Config, __exec: &Exec) -> Pool<T> {
112112
let inner = if config.is_enabled() {
113113
Some(Arc::new(Mutex::new(PoolInner {
114114
connecting: HashSet::new(),
@@ -148,7 +148,7 @@ impl<T> Pool<T> {
148148
impl<T: Poolable> Pool<T> {
149149
/// Returns a `Checkout` which is a future that resolves if an idle
150150
/// connection becomes available.
151-
pub(super) fn checkout(&self, key: Key) -> Checkout<T> {
151+
pub fn checkout(&self, key: Key) -> Checkout<T> {
152152
Checkout {
153153
key,
154154
pool: self.clone(),
@@ -158,7 +158,7 @@ impl<T: Poolable> Pool<T> {
158158

159159
/// Ensure that there is only ever 1 connecting task for HTTP/2
160160
/// connections. This does nothing for HTTP/1.
161-
pub(super) fn connecting(&self, key: &Key, ver: Ver) -> Option<Connecting<T>> {
161+
pub fn connecting(&self, key: &Key, ver: Ver) -> Option<Connecting<T>> {
162162
if ver == Ver::Http2 {
163163
if let Some(ref enabled) = self.inner {
164164
let mut inner = enabled.lock().unwrap();
@@ -208,7 +208,7 @@ impl<T: Poolable> Pool<T> {
208208
}
209209
*/
210210

211-
pub(super) fn pooled(
211+
pub fn pooled(
212212
&self,
213213
#[cfg_attr(not(feature = "http2"), allow(unused_mut))] mut connecting: Connecting<T>,
214214
value: T,
@@ -491,19 +491,19 @@ impl<T> Clone for Pool<T> {
491491

492492
/// A wrapped poolable value that tries to reinsert to the Pool on Drop.
493493
// Note: The bounds `T: Poolable` is needed for the Drop impl.
494-
pub(super) struct Pooled<T: Poolable> {
494+
pub struct Pooled<T: Poolable> {
495495
value: Option<T>,
496496
is_reused: bool,
497497
key: Key,
498498
pool: WeakOpt<Mutex<PoolInner<T>>>,
499499
}
500500

501501
impl<T: Poolable> Pooled<T> {
502-
pub(super) fn is_reused(&self) -> bool {
502+
pub fn is_reused(&self) -> bool {
503503
self.is_reused
504504
}
505505

506-
pub(super) fn is_pool_enabled(&self) -> bool {
506+
pub fn is_pool_enabled(&self) -> bool {
507507
self.pool.0.is_some()
508508
}
509509

@@ -564,14 +564,14 @@ struct Idle<T> {
564564

565565
// FIXME: allow() required due to `impl Trait` leaking types to this lint
566566
#[allow(missing_debug_implementations)]
567-
pub(super) struct Checkout<T> {
567+
pub struct Checkout<T> {
568568
key: Key,
569569
pool: Pool<T>,
570570
waiter: Option<oneshot::Receiver<T>>,
571571
}
572572

573573
#[derive(Debug)]
574-
pub(super) struct CheckoutIsClosedError;
574+
pub struct CheckoutIsClosedError;
575575

576576
impl Error for CheckoutIsClosedError {}
577577

@@ -691,13 +691,13 @@ impl<T> Drop for Checkout<T> {
691691

692692
// FIXME: allow() required due to `impl Trait` leaking types to this lint
693693
#[allow(missing_debug_implementations)]
694-
pub(super) struct Connecting<T: Poolable> {
694+
pub struct Connecting<T: Poolable> {
695695
key: Key,
696696
pool: WeakOpt<Mutex<PoolInner<T>>>,
697697
}
698698

699699
impl<T: Poolable> Connecting<T> {
700-
pub(super) fn alpn_h2(self, pool: &Pool<T>) -> Option<Self> {
700+
pub fn alpn_h2(self, pool: &Pool<T>) -> Option<Self> {
701701
debug_assert!(
702702
self.pool.0.is_none(),
703703
"Connecting::alpn_h2 but already Http2"

src/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ macro_rules! ready {
1010
}
1111

1212
pub(crate) use ready;
13-
pub(crate) mod exec;
13+
pub mod exec;
1414
pub(crate) mod never;
1515

1616
pub(crate) use never::Never;

0 commit comments

Comments
 (0)