From 8cdfa445d6629ffef4cb84967ff7017654045bc2 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 2 Jul 2025 18:36:06 -0600 Subject: chore: add vendor directory --- vendor/hyper-util/src/common/exec.rs | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 vendor/hyper-util/src/common/exec.rs (limited to 'vendor/hyper-util/src/common/exec.rs') diff --git a/vendor/hyper-util/src/common/exec.rs b/vendor/hyper-util/src/common/exec.rs new file mode 100644 index 00000000..40860ee1 --- /dev/null +++ b/vendor/hyper-util/src/common/exec.rs @@ -0,0 +1,53 @@ +#![allow(dead_code)] + +use hyper::rt::Executor; +use std::fmt; +use std::future::Future; +use std::pin::Pin; +use std::sync::Arc; + +pub(crate) type BoxSendFuture = Pin + Send>>; + +// Either the user provides an executor for background tasks, or we use +// `tokio::spawn`. +#[derive(Clone)] +pub(crate) enum Exec { + Executor(Arc + Send + Sync>), +} + +// ===== impl Exec ===== + +impl Exec { + pub(crate) fn new(inner: E) -> Self + where + E: Executor + Send + Sync + 'static, + { + Exec::Executor(Arc::new(inner)) + } + + pub(crate) fn execute(&self, fut: F) + where + F: Future + Send + 'static, + { + match *self { + Exec::Executor(ref e) => { + e.execute(Box::pin(fut)); + } + } + } +} + +impl fmt::Debug for Exec { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Exec").finish() + } +} + +impl hyper::rt::Executor for Exec +where + F: Future + Send + 'static, +{ + fn execute(&self, fut: F) { + Exec::execute(self, fut); + } +} -- cgit v1.2.3