refactor(lib): apply unreachable_pub lint (#2400)

Closes #2390
This commit is contained in:
Taiki Endo
2021-01-15 02:57:55 +09:00
committed by GitHub
parent a15f3f7f0f
commit f0ddb66932
28 changed files with 196 additions and 185 deletions

View File

@@ -272,7 +272,7 @@ where
ResponseFuture { inner }
}
pub(crate) fn send_request_retryable(
pub(super) fn send_request_retryable(
&mut self,
req: Request<B>,
) -> impl Future<Output = Result<Response<Body>, (crate::Error, Option<Request<B>>)>> + Unpin

View File

@@ -346,7 +346,7 @@ mod sealed {
}
}
pub(crate) async fn resolve<R>(resolver: &mut R, name: Name) -> Result<R::Addrs, R::Error>
pub(super) async fn resolve<R>(resolver: &mut R, name: Name) -> Result<R::Addrs, R::Error>
where
R: Resolve,
{

View File

@@ -6,10 +6,10 @@ use tokio::sync::{mpsc, oneshot};
use crate::common::{task, Pin, Poll};
pub type RetryPromise<T, U> = oneshot::Receiver<Result<U, (crate::Error, Option<T>)>>;
pub type Promise<T> = oneshot::Receiver<Result<T, crate::Error>>;
pub(crate) type RetryPromise<T, U> = oneshot::Receiver<Result<U, (crate::Error, Option<T>)>>;
pub(crate) type Promise<T> = oneshot::Receiver<Result<T, crate::Error>>;
pub fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) {
pub(crate) fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) {
let (tx, rx) = mpsc::unbounded_channel();
let (giver, taker) = want::new();
let tx = Sender {
@@ -25,7 +25,7 @@ pub fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) {
///
/// While the inner sender is unbounded, the Giver is used to determine
/// if the Receiver is ready for another request.
pub struct Sender<T, U> {
pub(crate) struct Sender<T, U> {
/// One message is always allowed, even if the Receiver hasn't asked
/// for it yet. This boolean keeps track of whether we've sent one
/// without notice.
@@ -44,24 +44,24 @@ pub struct Sender<T, U> {
/// Cannot poll the Giver, but can still use it to determine if the Receiver
/// has been dropped. However, this version can be cloned.
#[cfg(feature = "http2")]
pub struct UnboundedSender<T, U> {
pub(crate) struct UnboundedSender<T, U> {
/// Only used for `is_closed`, since mpsc::UnboundedSender cannot be checked.
giver: want::SharedGiver,
inner: mpsc::UnboundedSender<Envelope<T, U>>,
}
impl<T, U> Sender<T, U> {
pub fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
pub(crate) fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
self.giver
.poll_want(cx)
.map_err(|_| crate::Error::new_closed())
}
pub fn is_ready(&self) -> bool {
pub(crate) fn is_ready(&self) -> bool {
self.giver.is_wanting()
}
pub fn is_closed(&self) -> bool {
pub(crate) fn is_closed(&self) -> bool {
self.giver.is_canceled()
}
@@ -78,7 +78,7 @@ impl<T, U> Sender<T, U> {
}
}
pub fn try_send(&mut self, val: T) -> Result<RetryPromise<T, U>, T> {
pub(crate) fn try_send(&mut self, val: T) -> Result<RetryPromise<T, U>, T> {
if !self.can_send() {
return Err(val);
}
@@ -89,7 +89,7 @@ impl<T, U> Sender<T, U> {
.map_err(|mut e| (e.0).0.take().expect("envelope not dropped").0)
}
pub fn send(&mut self, val: T) -> Result<Promise<U>, T> {
pub(crate) fn send(&mut self, val: T) -> Result<Promise<U>, T> {
if !self.can_send() {
return Err(val);
}
@@ -101,7 +101,7 @@ impl<T, U> Sender<T, U> {
}
#[cfg(feature = "http2")]
pub fn unbound(self) -> UnboundedSender<T, U> {
pub(crate) fn unbound(self) -> UnboundedSender<T, U> {
UnboundedSender {
giver: self.giver.shared(),
inner: self.inner,
@@ -111,15 +111,15 @@ impl<T, U> Sender<T, U> {
#[cfg(feature = "http2")]
impl<T, U> UnboundedSender<T, U> {
pub fn is_ready(&self) -> bool {
pub(crate) fn is_ready(&self) -> bool {
!self.giver.is_canceled()
}
pub fn is_closed(&self) -> bool {
pub(crate) fn is_closed(&self) -> bool {
self.giver.is_canceled()
}
pub fn try_send(&mut self, val: T) -> Result<RetryPromise<T, U>, T> {
pub(crate) fn try_send(&mut self, val: T) -> Result<RetryPromise<T, U>, T> {
let (tx, rx) = oneshot::channel();
self.inner
.send(Envelope(Some((val, Callback::Retry(tx)))))
@@ -139,7 +139,7 @@ impl<T, U> Clone for UnboundedSender<T, U> {
}
#[pin_project::pin_project(PinnedDrop)]
pub struct Receiver<T, U> {
pub(crate) struct Receiver<T, U> {
#[pin]
inner: mpsc::UnboundedReceiver<Envelope<T, U>>,
taker: want::Taker,
@@ -199,7 +199,7 @@ impl<T, U> Drop for Envelope<T, U> {
}
}
pub enum Callback<T, U> {
pub(crate) enum Callback<T, U> {
Retry(oneshot::Sender<Result<U, (crate::Error, Option<T>)>>),
NoRetry(oneshot::Sender<Result<U, crate::Error>>),
}

View File

@@ -63,7 +63,7 @@ cfg_feature! {
mod client;
pub mod conn;
pub(crate) mod dispatch;
pub(super) mod dispatch;
mod pool;
pub mod service;
}

View File

@@ -100,7 +100,7 @@ impl Config {
}
impl<T> Pool<T> {
pub fn new(config: Config, __exec: &Exec) -> Pool<T> {
pub(super) fn new(config: Config, __exec: &Exec) -> Pool<T> {
let inner = if config.is_enabled() {
Some(Arc::new(Mutex::new(PoolInner {
connecting: HashSet::new(),
@@ -140,7 +140,7 @@ impl<T> Pool<T> {
impl<T: Poolable> Pool<T> {
/// Returns a `Checkout` which is a future that resolves if an idle
/// connection becomes available.
pub fn checkout(&self, key: Key) -> Checkout<T> {
pub(super) fn checkout(&self, key: Key) -> Checkout<T> {
Checkout {
key,
pool: self.clone(),
@@ -489,11 +489,11 @@ pub(super) struct Pooled<T: Poolable> {
}
impl<T: Poolable> Pooled<T> {
pub fn is_reused(&self) -> bool {
pub(super) fn is_reused(&self) -> bool {
self.is_reused
}
pub fn is_pool_enabled(&self) -> bool {
pub(super) fn is_pool_enabled(&self) -> bool {
self.pool.0.is_some()
}