-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add combinator for boxing ServiceFactory::Future (#118)
* add combinator for boxing ServiceFactory::Future * fix lint * fix typo
- Loading branch information
1 parent
0f81d07
commit 0c7980c
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use alloc::boxed::Box; | ||
|
||
use crate::BoxFuture; | ||
|
||
use super::ServiceFactory; | ||
|
||
pub struct BoxedServiceFactory<F> { | ||
factory: F, | ||
} | ||
|
||
impl<F> BoxedServiceFactory<F> { | ||
pub(super) fn new(factory: F) -> Self { | ||
Self { factory } | ||
} | ||
} | ||
|
||
impl<F, Req> ServiceFactory<Req> for BoxedServiceFactory<F> | ||
where | ||
F: ServiceFactory<Req>, | ||
F::Future: 'static, | ||
{ | ||
type Response = F::Response; | ||
type Error = F::Error; | ||
type Config = F::Config; | ||
type Service = F::Service; | ||
type InitError = F::InitError; | ||
type Future = BoxFuture<'static, Self::Service, Self::InitError>; | ||
|
||
fn new_service(&self, cfg: Self::Config) -> Self::Future { | ||
Box::pin(self.factory.new_service(cfg)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub(crate) mod pipeline; | ||
|
||
mod and_then; | ||
mod boxed; | ||
mod ext; | ||
mod function; | ||
mod map; | ||
|