1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 16:34:36 +01:00

Make Out::Error convertable from T::Error for apply combinator

This commit is contained in:
Nikolay Kim 2019-01-13 22:58:23 -08:00
parent 605a947c3e
commit cfb62ccc40
3 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,12 @@
# Changes # Changes
## [0.1.5] - 2019-01-13
### Changed
* Make `Out::Error` convertable from `T::Error` for apply combinator
## [0.1.4] - 2019-01-11 ## [0.1.4] - 2019-01-11
### Changed ### Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-service" name = "actix-service"
version = "0.1.4" version = "0.1.5"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Service" description = "Actix Service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]

View File

@ -19,6 +19,7 @@ where
T: Service<Request>, T: Service<Request>,
F: Fn(In, &mut T) -> Out, F: Fn(In, &mut T) -> Out,
Out: IntoFuture, Out: IntoFuture,
Out::Error: From<T::Error>,
{ {
/// Create new `Apply` combinator /// Create new `Apply` combinator
pub fn new<I: IntoService<T, Request>>(service: I, f: F) -> Self { pub fn new<I: IntoService<T, Request>>(service: I, f: F) -> Self {
@ -46,16 +47,17 @@ where
impl<T, F, In, Out, Request> Service<In> for Apply<T, F, In, Out, Request> impl<T, F, In, Out, Request> Service<In> for Apply<T, F, In, Out, Request>
where where
T: Service<Request, Error = Out::Error>, T: Service<Request>,
F: Fn(In, &mut T) -> Out, F: Fn(In, &mut T) -> Out,
Out: IntoFuture, Out: IntoFuture,
Out::Error: From<T::Error>,
{ {
type Response = Out::Item; type Response = Out::Item;
type Error = Out::Error; type Error = Out::Error;
type Future = Out::Future; type Future = Out::Future;
fn poll_ready(&mut self) -> Poll<(), Self::Error> { fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.poll_ready() self.service.poll_ready().map_err(|e| e.into())
} }
fn call(&mut self, req: In) -> Self::Future { fn call(&mut self, req: In) -> Self::Future {
@ -78,6 +80,7 @@ where
T: NewService<Request>, T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out, F: Fn(In, &mut T::Service) -> Out,
Out: IntoFuture, Out: IntoFuture,
Out::Error: From<T::Error>,
{ {
/// Create new `ApplyNewService` new service instance /// Create new `ApplyNewService` new service instance
pub fn new<F1: IntoNewService<T, Request>>(service: F1, f: F) -> Self { pub fn new<F1: IntoNewService<T, Request>>(service: F1, f: F) -> Self {
@ -92,7 +95,7 @@ where
impl<T, F, In, Out, Request> Clone for ApplyNewService<T, F, In, Out, Request> impl<T, F, In, Out, Request> Clone for ApplyNewService<T, F, In, Out, Request>
where where
T: NewService<Request> + Clone, T: NewService<Request> + Clone,
F: Fn(Out, &mut T::Service) -> Out + Clone, F: Fn(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture, Out: IntoFuture,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
@ -106,9 +109,10 @@ where
impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request> impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request>
where where
T: NewService<Request, Error = Out::Error>, T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out + Clone, F: Fn(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture, Out: IntoFuture,
Out::Error: From<T::Error>,
{ {
type Response = Out::Item; type Response = Out::Item;
type Error = Out::Error; type Error = Out::Error;
@ -153,6 +157,7 @@ where
T: NewService<Request>, T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out, F: Fn(In, &mut T::Service) -> Out,
Out: IntoFuture, Out: IntoFuture,
Out::Error: From<T::Error>,
{ {
type Item = Apply<T::Service, F, In, Out, Request>; type Item = Apply<T::Service, F, In, Out, Request>;
type Error = T::InitError; type Error = T::InitError;