Skip to content

Commit

Permalink
add NewService impls for Rc<S> and Arc<S>
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Feb 19, 2019
1 parent 32f4718 commit 3d7daab
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
9 changes: 9 additions & 0 deletions actix-service/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changes

## [0.2.2] - 2019-02-19

### Added

* Added `NewService` impl for `Rc<S> where S: NewService`

* Added `NewService` impl for `Arc<S> where S: NewService`


## [0.2.1] - 2019-02-03

### 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.2.1"
version = "0.2.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Service"
keywords = ["network", "framework", "async", "futures"]
Expand Down
35 changes: 35 additions & 0 deletions actix-service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::rc::Rc;
use std::sync::Arc;

use futures::{Future, IntoFuture, Poll};

mod and_then;
Expand Down Expand Up @@ -377,6 +380,38 @@ where
}
}

impl<S> NewService for Rc<S>
where
S: NewService,
{
type Request = S::Request;
type Response = S::Response;
type Error = S::Error;
type Service = S::Service;
type InitError = S::InitError;
type Future = S::Future;

fn new_service(&self) -> S::Future {
self.as_ref().new_service()
}
}

impl<S> NewService for Arc<S>
where
S: NewService,
{
type Request = S::Request;
type Response = S::Response;
type Error = S::Error;
type Service = S::Service;
type InitError = S::InitError;
type Future = S::Future;

fn new_service(&self) -> S::Future {
self.as_ref().new_service()
}
}

/// Trait for types that can be converted to a `Service`
pub trait IntoService<T>
where
Expand Down

0 comments on commit 3d7daab

Please sign in to comment.