From f592ecf73b81fcae68590e4d9e07e77a77513492 Mon Sep 17 00:00:00 2001 From: Emi Tatsuo Date: Thu, 3 Dec 2020 15:04:12 -0500 Subject: [PATCH] Move opt_timeout to lib.rs --- src/lib.rs | 10 +++++++++- src/util.rs | 7 ------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 882aa37..afa3698 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,6 +81,7 @@ compile_error!("Please enable at least one of either the `gemini_srv` or `scgi_s use std::{ sync::Arc, time::Duration, + future::Future, }; #[cfg(feature = "gemini_srv")] use std::convert::TryFrom; @@ -99,6 +100,7 @@ use tokio::{ io::BufReader, net::TcpListener, net::ToSocketAddrs, + time, prelude::*, }; #[cfg(feature = "scgi_srv")] @@ -111,7 +113,6 @@ use tokio::{ #[cfg(feature = "ratelimiting")] use tokio::time::interval; use anyhow::*; -use crate::util::opt_timeout; use routing::RoutingNode; #[cfg(feature = "ratelimiting")] use ratelimiting::RateLimiter; @@ -832,3 +833,10 @@ async fn prune_ratelimit_log(rate_limits: Arc>>) #[cfg(feature = "ratelimiting")] enum Never {} + +async fn opt_timeout(duration: Option, future: impl Future) -> Result { + match duration { + Some(duration) => time::timeout(duration, future).await, + None => Ok(future.await), + } +} diff --git a/src/util.rs b/src/util.rs index 4ac9062..d3166dd 100644 --- a/src/util.rs +++ b/src/util.rs @@ -173,10 +173,3 @@ where C: AsRef + Into, T: ToOwned + ?Sized, {} - -pub(crate) async fn opt_timeout(duration: Option, future: impl Future) -> Result { - match duration { - Some(duration) => time::timeout(duration, future).await, - None => Ok(future.await), - } -}