|
@@ -1,7 +1,7 @@
|
|
|
use crate::{
|
|
|
errors::{DispatchError, Error, InternalError},
|
|
|
module::{as_module_map, Module, ModuleMap, ModuleRequest},
|
|
|
- response::EventResponse,
|
|
|
+ response::{EventResponse, Responder},
|
|
|
service::{Service, ServiceFactory},
|
|
|
util::tokio_default_runtime,
|
|
|
};
|
|
@@ -38,7 +38,7 @@ impl EventDispatch {
|
|
|
*(EVENT_DISPATCH.write().unwrap()) = Some(dispatch);
|
|
|
}
|
|
|
|
|
|
- pub fn async_send<Req>(request: Req) -> DispatchFuture
|
|
|
+ pub fn async_send<Req>(request: Req) -> DispatchFuture<EventResponse>
|
|
|
where
|
|
|
Req: std::convert::Into<ModuleRequest>,
|
|
|
{
|
|
@@ -48,7 +48,7 @@ impl EventDispatch {
|
|
|
pub fn async_send_with_callback<Req, Callback>(
|
|
|
request: Req,
|
|
|
callback: Callback,
|
|
|
- ) -> DispatchFuture
|
|
|
+ ) -> DispatchFuture<EventResponse>
|
|
|
where
|
|
|
Req: std::convert::Into<ModuleRequest>,
|
|
|
Callback: FnOnce(EventResponse) -> BoxFuture<'static, ()> + 'static + Send + Sync,
|
|
@@ -99,13 +99,16 @@ impl EventDispatch {
|
|
|
}
|
|
|
|
|
|
#[pin_project]
|
|
|
-pub struct DispatchFuture {
|
|
|
+pub struct DispatchFuture<T: Responder + Send + Sync> {
|
|
|
#[pin]
|
|
|
- fut: BoxFuture<'static, EventResponse>,
|
|
|
+ pub fut: Pin<Box<dyn Future<Output = T> + Sync + Send>>,
|
|
|
}
|
|
|
|
|
|
-impl Future for DispatchFuture {
|
|
|
- type Output = EventResponse;
|
|
|
+impl<T> Future for DispatchFuture<T>
|
|
|
+where
|
|
|
+ T: Responder + Send + Sync,
|
|
|
+{
|
|
|
+ type Output = T;
|
|
|
|
|
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
|
let this = self.as_mut().project();
|