summaryrefslogtreecommitdiff
path: root/vendor/hyper-util/src/common/timer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/hyper-util/src/common/timer.rs')
-rw-r--r--vendor/hyper-util/src/common/timer.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/hyper-util/src/common/timer.rs b/vendor/hyper-util/src/common/timer.rs
new file mode 100644
index 00000000..390be3b0
--- /dev/null
+++ b/vendor/hyper-util/src/common/timer.rs
@@ -0,0 +1,38 @@
+#![allow(dead_code)]
+
+use std::fmt;
+use std::pin::Pin;
+use std::sync::Arc;
+use std::time::Duration;
+use std::time::Instant;
+
+use hyper::rt::Sleep;
+
+#[derive(Clone)]
+pub(crate) struct Timer(Arc<dyn hyper::rt::Timer + Send + Sync>);
+
+// =====impl Timer=====
+impl Timer {
+ pub(crate) fn new<T>(inner: T) -> Self
+ where
+ T: hyper::rt::Timer + Send + Sync + 'static,
+ {
+ Self(Arc::new(inner))
+ }
+}
+
+impl fmt::Debug for Timer {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("Timer").finish()
+ }
+}
+
+impl hyper::rt::Timer for Timer {
+ fn sleep(&self, duration: Duration) -> Pin<Box<dyn Sleep>> {
+ self.0.sleep(duration)
+ }
+
+ fn sleep_until(&self, deadline: Instant) -> Pin<Box<dyn Sleep>> {
+ self.0.sleep_until(deadline)
+ }
+}