Skip to content

Commit

Permalink
Make Out::Error convertable from T::Error for apply combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jan 14, 2019
1 parent 605a947 commit cfb62cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions actix-service/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

## [0.1.5] - 2019-01-13

### Changed

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


## [0.1.4] - 2019-01-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion actix-service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-service"
version = "0.1.4"
version = "0.1.5"
authors = ["Nikolay Kim <[email protected]>"]
description = "Actix Service"
keywords = ["network", "framework", "async", "futures"]
Expand Down
13 changes: 9 additions & 4 deletions actix-service/src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ where
T: Service<Request>,
F: Fn(In, &mut T) -> Out,
Out: IntoFuture,
Out::Error: From<T::Error>,
{
/// Create new `Apply` combinator
pub fn new<I: IntoService<T, Request>>(service: I, f: F) -> Self {
Expand Down Expand Up @@ -46,16 +47,17 @@ where

impl<T, F, In, Out, Request> Service<In> for Apply<T, F, In, Out, Request>
where
T: Service<Request, Error = Out::Error>,
T: Service<Request>,
F: Fn(In, &mut T) -> Out,
Out: IntoFuture,
Out::Error: From<T::Error>,
{
type Response = Out::Item;
type Error = Out::Error;
type Future = Out::Future;

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 {
Expand All @@ -78,6 +80,7 @@ where
T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out,
Out: IntoFuture,
Out::Error: From<T::Error>,
{
/// Create new `ApplyNewService` new service instance
pub fn new<F1: IntoNewService<T, Request>>(service: F1, f: F) -> Self {
Expand All @@ -92,7 +95,7 @@ where
impl<T, F, In, Out, Request> Clone for ApplyNewService<T, F, In, Out, Request>
where
T: NewService<Request> + Clone,
F: Fn(Out, &mut T::Service) -> Out + Clone,
F: Fn(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture,
{
fn clone(&self) -> Self {
Expand All @@ -106,9 +109,10 @@ where

impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request>
where
T: NewService<Request, Error = Out::Error>,
T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out + Clone,
Out: IntoFuture,
Out::Error: From<T::Error>,
{
type Response = Out::Item;
type Error = Out::Error;
Expand Down Expand Up @@ -153,6 +157,7 @@ where
T: NewService<Request>,
F: Fn(In, &mut T::Service) -> Out,
Out: IntoFuture,
Out::Error: From<T::Error>,
{
type Item = Apply<T::Service, F, In, Out, Request>;
type Error = T::InitError;
Expand Down

0 comments on commit cfb62cc

Please sign in to comment.