Skip to content

Commit f14e9ac

Browse files
authored
pool: make relevant items pub (#15)
Currently `pool` is not pub, and nothing `pub` uses it, so it isn't accessible. This exposes them for use.
1 parent 287b1f9 commit f14e9ac

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
@@ -24,7 +24,7 @@ use crate::common::{exec::Exec, ready};
2424

2525
// FIXME: allow() required due to `impl Trait` leaking types to this lint
2626
#[allow(missing_debug_implementations)]
27-
pub(super) struct Pool<T, K: Key> {
27+
pub struct Pool<T, K: Key> {
2828
// If the pool is disabled, this is None.
2929
inner: Option<Arc<Mutex<PoolInner<T, K>>>>,
3030
}
@@ -34,7 +34,7 @@ pub(super) struct Pool<T, K: Key> {
3434
// This is a trait to allow the `client::pool::tests` to work for `i32`.
3535
//
3636
// See https://github.com/hyperium/hyper/issues/1429
37-
pub(super) trait Poolable: Unpin + Send + Sized + 'static {
37+
pub trait Poolable: Unpin + Send + Sized + 'static {
3838
fn is_open(&self) -> bool;
3939
/// Reserve this connection.
4040
///
@@ -54,7 +54,7 @@ impl<T> Key for T where T: Eq + Hash + Clone + Debug + Unpin + Send + 'static {}
5454
/// used for multiple requests.
5555
// FIXME: allow() required due to `impl Trait` leaking types to this lint
5656
#[allow(missing_debug_implementations)]
57-
pub(super) enum Reservation<T> {
57+
pub enum Reservation<T> {
5858
/// This connection could be used multiple times, the first one will be
5959
/// reinserted into the `idle` pool, and the second will be given to
6060
/// the `Checkout`.
@@ -66,7 +66,7 @@ pub(super) enum Reservation<T> {
6666
}
6767

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

7171
struct PoolInner<T, K: Eq + Hash> {
7272
// A flag that a connection is being established, and the connection
@@ -101,19 +101,19 @@ struct PoolInner<T, K: Eq + Hash> {
101101
struct WeakOpt<T>(Option<Weak<T>>);
102102

103103
#[derive(Clone, Copy, Debug)]
104-
pub(super) struct Config {
105-
pub(super) idle_timeout: Option<Duration>,
106-
pub(super) max_idle_per_host: usize,
104+
pub struct Config {
105+
pub idle_timeout: Option<Duration>,
106+
pub max_idle_per_host: usize,
107107
}
108108

109109
impl Config {
110-
pub(super) fn is_enabled(&self) -> bool {
110+
pub fn is_enabled(&self) -> bool {
111111
self.max_idle_per_host > 0
112112
}
113113
}
114114

115115
impl<T, K: Key> Pool<T, K> {
116-
pub(super) fn new(config: Config, __exec: &Exec) -> Pool<T, K> {
116+
pub fn new(config: Config, __exec: &Exec) -> Pool<T, K> {
117117
let inner = if config.is_enabled() {
118118
Some(Arc::new(Mutex::new(PoolInner {
119119
connecting: HashSet::new(),
@@ -153,7 +153,7 @@ impl<T, K: Key> Pool<T, K> {
153153
impl<T: Poolable, K: Key> Pool<T, K> {
154154
/// Returns a `Checkout` which is a future that resolves if an idle
155155
/// connection becomes available.
156-
pub(super) fn checkout(&self, key: K) -> Checkout<T, K> {
156+
pub fn checkout(&self, key: K) -> Checkout<T, K> {
157157
Checkout {
158158
key,
159159
pool: self.clone(),
@@ -163,7 +163,7 @@ impl<T: Poolable, K: Key> Pool<T, K> {
163163

164164
/// Ensure that there is only ever 1 connecting task for HTTP/2
165165
/// connections. This does nothing for HTTP/1.
166-
pub(super) fn connecting(&self, key: &K, ver: Ver) -> Option<Connecting<T, K>> {
166+
pub fn connecting(&self, key: &K, ver: Ver) -> Option<Connecting<T, K>> {
167167
if ver == Ver::Http2 {
168168
if let Some(ref enabled) = self.inner {
169169
let mut inner = enabled.lock().unwrap();
@@ -213,7 +213,7 @@ impl<T: Poolable, K: Key> Pool<T, K> {
213213
}
214214
*/
215215

216-
pub(super) fn pooled(
216+
pub fn pooled(
217217
&self,
218218
#[cfg_attr(not(feature = "http2"), allow(unused_mut))] mut connecting: Connecting<T, K>,
219219
value: T,
@@ -496,19 +496,19 @@ impl<T, K: Key> Clone for Pool<T, K> {
496496

497497
/// A wrapped poolable value that tries to reinsert to the Pool on Drop.
498498
// Note: The bounds `T: Poolable` is needed for the Drop impl.
499-
pub(super) struct Pooled<T: Poolable, K: Key> {
499+
pub struct Pooled<T: Poolable, K: Key> {
500500
value: Option<T>,
501501
is_reused: bool,
502502
key: K,
503503
pool: WeakOpt<Mutex<PoolInner<T, K>>>,
504504
}
505505

506506
impl<T: Poolable, K: Key> Pooled<T, K> {
507-
pub(super) fn is_reused(&self) -> bool {
507+
pub fn is_reused(&self) -> bool {
508508
self.is_reused
509509
}
510510

511-
pub(super) fn is_pool_enabled(&self) -> bool {
511+
pub fn is_pool_enabled(&self) -> bool {
512512
self.pool.0.is_some()
513513
}
514514

@@ -569,14 +569,14 @@ struct Idle<T> {
569569

570570
// FIXME: allow() required due to `impl Trait` leaking types to this lint
571571
#[allow(missing_debug_implementations)]
572-
pub(super) struct Checkout<T, K: Key> {
572+
pub struct Checkout<T, K: Key> {
573573
key: K,
574574
pool: Pool<T, K>,
575575
waiter: Option<oneshot::Receiver<T>>,
576576
}
577577

578578
#[derive(Debug)]
579-
pub(super) struct CheckoutIsClosedError;
579+
pub struct CheckoutIsClosedError;
580580

581581
impl Error for CheckoutIsClosedError {}
582582

@@ -696,13 +696,13 @@ impl<T, K: Key> Drop for Checkout<T, K> {
696696

697697
// FIXME: allow() required due to `impl Trait` leaking types to this lint
698698
#[allow(missing_debug_implementations)]
699-
pub(super) struct Connecting<T: Poolable, K: Key> {
699+
pub struct Connecting<T: Poolable, K: Key> {
700700
key: K,
701701
pool: WeakOpt<Mutex<PoolInner<T, K>>>,
702702
}
703703

704704
impl<T: Poolable, K: Key> Connecting<T, K> {
705-
pub(super) fn alpn_h2(self, pool: &Pool<T, K>) -> Option<Self> {
705+
pub fn alpn_h2(self, pool: &Pool<T, K>) -> Option<Self> {
706706
debug_assert!(
707707
self.pool.0.is_none(),
708708
"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
#[cfg(feature = "runtime")]

0 commit comments

Comments
 (0)