You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like the single-threaded example, It is okay to use these separately. But If I want to make a generic function to process both of them, I could not find any solution..
For example,
fn launch<S, E>(svc: S, exec: E)
where E: (What should I do??)
{
// blabla...
let server = hyper::server::Builder::new(incoming, Http::new().with_executor(exec));
server.serve(svc) // <- This causes error
}
Since Builder::serve requires these trait bounds, I think I should provide corresponding bounds
E: NewSvcExec<I::Conn, S::Future, S::Service, E, NoopWatcher>,
E: ConnStreamExec<<S::Service as HttpService<Body>>::Future, B>,
But the problem is these are crate-private traits.
And I've found these codes:
#[cfg(feature = "server")]
impl<E, F, B> ConnStreamExec<F, B> for E
where
E: Executor<H2Stream<F, B>> + Clone,
H2Stream<F, B>: Future<Output = ()>,
B: HttpBody,
{
fn execute_h2stream(&mut self, fut: H2Stream<F, B>) {
self.execute(fut)
}
}
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
impl<I, N, S, E, W> NewSvcExec<I, N, S, E, W> for E
where
E: Executor<NewSvcTask<I, N, S, E, W>> + Clone,
NewSvcTask<I, N, S, E, W>: Future<Output = ()>,
S: HttpService<Body>,
W: Watcher<I, S, E>,
{
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) {
self.execute(fut)
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I am using hyper 0.14 and implemented two custom Executors such as:
Like the single-threaded example, It is okay to use these separately. But If I want to make a generic function to process both of them, I could not find any solution..
For example,
Since Builder::serve requires these trait bounds, I think I should provide corresponding bounds
But the problem is these are crate-private traits.
And I've found these codes:
But NewSvcTask and H2Stream are also private....
Can I ask any solution about this?
Beta Was this translation helpful? Give feedback.
All reactions