mirror of https://github.com/fafhrd91/actix-net
				
				
				
			fix boxed service
This commit is contained in:
		
							parent
							
								
									d530094920
								
							
						
					
					
						commit
						ed83360605
					
				|  | @ -1,10 +1,5 @@ | ||||||
| #![allow(unused_imports, unused_variables, dead_code)] |  | ||||||
| 
 |  | ||||||
| use std::future::Future; |  | ||||||
| use std::pin::Pin; |  | ||||||
| use std::task::{Context, Poll}; | use std::task::{Context, Poll}; | ||||||
| 
 | 
 | ||||||
| use futures::future::{err, ok, Either, Ready}; |  | ||||||
| use futures::future::{FutureExt, LocalBoxFuture}; | use futures::future::{FutureExt, LocalBoxFuture}; | ||||||
| 
 | 
 | ||||||
| use crate::{Service, ServiceFactory}; | use crate::{Service, ServiceFactory}; | ||||||
|  | @ -18,8 +13,7 @@ pub type BoxedService<Req, Res, Err> = Box< | ||||||
|     >, |     >, | ||||||
| >; | >; | ||||||
| 
 | 
 | ||||||
| pub type BoxedServiceResponse<Res, Err> = | pub type BoxedServiceResponse<Res, Err> = LocalBoxFuture<'static, Result<Res, Err>>; | ||||||
|     Either<Ready<Result<Res, Err>>, LocalBoxFuture<'static, Result<Res, Err>>>; |  | ||||||
| 
 | 
 | ||||||
| pub struct BoxedNewService<C, Req, Res, Err, InitErr>(Inner<C, Req, Res, Err, InitErr>); | pub struct BoxedNewService<C, Req, Res, Err, InitErr>(Inner<C, Req, Res, Err, InitErr>); | ||||||
| 
 | 
 | ||||||
|  | @ -115,15 +109,10 @@ where | ||||||
|     type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>; |     type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>; | ||||||
| 
 | 
 | ||||||
|     fn new_service(&self, cfg: &C) -> Self::Future { |     fn new_service(&self, cfg: &C) -> Self::Future { | ||||||
|         /* TODO: Figure out what the hell is hapenning here
 |         self.factory | ||||||
|          Box::new( |             .new_service(cfg) | ||||||
|             self.service |             .map(|res| res.map(ServiceWrapper::boxed)) | ||||||
|                 .new_service(cfg) |             .boxed_local() | ||||||
|                 .into_future() |  | ||||||
|                 .map(ServiceWrapper::boxed), |  | ||||||
|         ) |  | ||||||
|         */ |  | ||||||
|         unimplemented!() |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -147,27 +136,13 @@ where | ||||||
|     type Request = Req; |     type Request = Req; | ||||||
|     type Response = Res; |     type Response = Res; | ||||||
|     type Error = Err; |     type Error = Err; | ||||||
|     type Future = Either< |     type Future = LocalBoxFuture<'static, Result<Res, Err>>; | ||||||
|         Ready<Result<Self::Response, Self::Error>>, |  | ||||||
|         LocalBoxFuture<'static, Result<Res, Err>>, |  | ||||||
|     >; |  | ||||||
| 
 | 
 | ||||||
|     fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { |     fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { | ||||||
|         self.0.poll_ready(ctx) |         self.0.poll_ready(ctx) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn call(&mut self, req: Self::Request) -> Self::Future { |     fn call(&mut self, req: Self::Request) -> Self::Future { | ||||||
|         unimplemented!() |         self.0.call(req).boxed_local() | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     /* |  | ||||||
|     fn call(&mut self, req: Self::Request) -> Self::Future { |  | ||||||
|         let mut fut = self.0.call(req); |  | ||||||
|         match fut.poll() { |  | ||||||
|             Ok(Async::Ready(res)) => Either::A(ok(res)), |  | ||||||
|             Err(e) => Either::A(err(e)), |  | ||||||
|             Ok(Async::NotReady) => Either::B(Box::new(fut)), |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     */ |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue