1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 22:07:42 +02:00

use convert err on forward_ready! (#246)

This commit is contained in:
Rob Ede
2021-01-09 14:13:16 +00:00
committed by GitHub
parent a1982bdbad
commit f751cf5acb
15 changed files with 34 additions and 35 deletions

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2021-xx-xx
* The `forward_ready!` macro converts errors. [#246]
[#246]: https://github.com/actix/actix-net/pull/246
## 2.0.0-beta.2 - 2021-01-03

View File

@ -17,7 +17,7 @@ where
///
/// # Example
///
/// ```rust
/// ```
/// use std::io;
/// use actix_service::{fn_factory, fn_service, Service, ServiceFactory};
/// use futures_util::future::ok;
@ -67,7 +67,7 @@ where
///
/// # Example
///
/// ```rust
/// ```
/// use std::io;
/// use actix_service::{fn_factory_with_config, fn_service, Service, ServiceFactory};
/// use futures_util::future::ok;

View File

@ -48,7 +48,7 @@ use self::ready::{err, ok, ready, Ready};
/// replies. You can think about a service as a function with one argument that returns some result
/// asynchronously. Conceptually, the operation looks like this:
///
/// ```rust,ignore
/// ```ignore
/// async fn(Request) -> Result<Response, Err>
/// ```
///
@ -60,7 +60,7 @@ use self::ready::{err, ok, ready, Ready};
/// simple API surfaces. This leads to simpler design of each service, improves test-ability and
/// makes composition easier.
///
/// ```rust,ignore
/// ```ignore
/// struct MyService;
///
/// impl Service for MyService {
@ -78,7 +78,7 @@ use self::ready::{err, ok, ready, Ready};
/// Sometimes it is not necessary to implement the Service trait. For example, the above service
/// could be rewritten as a simple function and passed to [fn_service](fn_service()).
///
/// ```rust,ignore
/// ```ignore
/// async fn my_service(req: u8) -> Result<u64, MyError>;
/// ```
pub trait Service<Req> {
@ -327,7 +327,9 @@ macro_rules! forward_ready {
&mut self,
cx: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<Result<(), Self::Error>> {
self.$field.poll_ready(cx)
self.$field
.poll_ready(cx)
.map_err(::core::convert::Into::into)
}
};
}

View File

@ -30,7 +30,7 @@ where
///
/// For example, timeout transform:
///
/// ```rust,ignore
/// ```ignore
/// pub struct Timeout<S> {
/// service: S,
/// timeout: Duration,
@ -45,9 +45,7 @@ where
/// type Error = TimeoutError<S::Error>;
/// type Future = TimeoutServiceResponse<S>;
///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
/// ready!(self.service.poll_ready(cx)).map_err(TimeoutError::Service)
/// }
/// actix_service::forward_ready!(service);
///
/// fn call(&mut self, req: S::Request) -> Self::Future {
/// TimeoutServiceResponse {
@ -69,7 +67,7 @@ where
///
/// Factory for `Timeout` middleware from the above example could look like this:
///
/// ```rust,,ignore
/// ```ignore
/// pub struct TimeoutTransform {
/// timeout: Duration,
/// }