-
|
Hello, I am trying to use the crate smol-axum, but I've encountered a compile error (documented better here notgull/smol-axum#3) TL;DR + additional info: this change 58e0e7d seems to be breaking smol-hyper's implementation of Executor, which implements it over async_executor's executors. It goes like this: impl<'a, E: AsRef<async_executor::Executor<'a>> + ?Sized, Fut: Future + Send + 'a> hyper::rt::Executor<Fut>
for SmolExecutor<E>
where
Fut::Output: Send + 'a,
{
#[inline]
fn execute(&self, fut: Fut) {
self.get_ref().as_ref().spawn(fut).detach();
}
}Where The issue lies when passing this smol executor to an http2 builder and calling serve (try to compile smol-axum's As the author of both crates has stated that they won't be very active now, I wanted to help out and fix this myself, however I lack the technical skill, and trying to get to understand this project is a hard task. I struggle to find what's so different after the commit that made this no longer work, I'd guess the fact there is an added E generic trait parameter to a lot of types is holding hostage the Reading what I can find about hyper's executor trait, all the examples operate over a globally defined executor, with static lifetimes, so there's never an issue So, my question is: Is the implementation of an Executor over a non static lifetime possible, or was it an oversight to begin with? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Interesting. I don't think I every really considered a non-static executor. The current design does require that the executor be able to spawn itself, otherwise there shouldn't necessarily be a problem. |
Beta Was this translation helpful? Give feedback.
@seanmonstar I've tried to make use of a non static executor, taking example of how the smol crate does it (mostly the prior mentioned smol-axum that does not compile with latest hyper) and the http2 example from here, and got a compiling snippet supposed to spawn an http2 server, but it crashes on any incoming connections. Curling it gives
Received HTTP/0.9 when not allowedand my program's output isError serving connection: http2 errorThis is the code