1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-13 07:18:22 +02:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Nikolay Kim
3d7daabdd7 add NewService impls for Rc<S> and Arc<S> 2019-02-19 11:31:54 -08:00
Nikolay Kim
32f4718880 Add Display impl for InOrderError 2019-02-11 08:39:28 -08:00
Nikolay Kim
b8f9bf4bc8 Add Display impl for TimeoutError 2019-02-11 08:34:57 -08:00
7 changed files with 73 additions and 2 deletions

View File

@@ -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

View File

@@ -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"]

View File

@@ -1,3 +1,6 @@
use std::rc::Rc;
use std::sync::Arc;
use futures::{Future, IntoFuture, Poll};
mod and_then;
@@ -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

View File

@@ -1,5 +1,14 @@
# Changes
## [0.2.2] - 2019-02-11
### Added
* Add `Display` impl for `TimeoutError`
* Add `Display` impl for `InOrderError`
## [0.2.1] - 2019-02-06
### Added

View File

@@ -1,6 +1,6 @@
[package]
name = "actix-utils"
version = "0.2.1"
version = "0.2.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix utils - various actix net related services"
keywords = ["network", "framework", "async", "futures"]

View File

@@ -37,6 +37,15 @@ impl<E: fmt::Debug> fmt::Debug for InOrderError<E> {
}
}
impl<E: fmt::Display> fmt::Display for InOrderError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
InOrderError::Service(e) => e.fmt(f),
InOrderError::Disconnected => write!(f, "InOrder service disconnected"),
}
}
}
/// InOrder - The service will yield responses as they become available,
/// in the order that their originating requests were submitted to the service.
pub struct InOrder<S> {

View File

@@ -41,6 +41,15 @@ impl<E: fmt::Debug> fmt::Debug for TimeoutError<E> {
}
}
impl<E: fmt::Display> fmt::Display for TimeoutError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
TimeoutError::Service(e) => e.fmt(f),
TimeoutError::Timeout => write!(f, "Service call timeout"),
}
}
}
impl<E: PartialEq> PartialEq for TimeoutError<E> {
fn eq(&self, other: &TimeoutError<E>) -> bool {
match self {