mirror of https://github.com/fafhrd91/actix-net
chore: prefer `core::future::{ready, Ready}` (#800)
This commit is contained in:
parent
7cf62ad80b
commit
7a908e01ea
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- internal: Use `core::future::{ready, Ready}` instead of actix-utils'
|
||||||
|
|
||||||
## 2.6.0
|
## 2.6.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl<T> Future for JoinAll<T> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use actix_utils::future::ready;
|
use core::future::ready;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
|
|
@ -5,7 +6,6 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
||||||
use actix_utils::future::{ready, Ready};
|
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- internal: Use `core::future::{ready, Ready}` instead of hand-crafted one
|
||||||
|
|
||||||
## 2.0.3
|
## 2.0.3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,15 +246,16 @@ mod tests {
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::{
|
use core::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
|
future::{ready, Ready},
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
fn_factory, ok,
|
fn_factory,
|
||||||
pipeline::{pipeline, pipeline_factory},
|
pipeline::{pipeline, pipeline_factory},
|
||||||
ready, Ready, Service, ServiceFactory,
|
Service, ServiceFactory,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Srv1(Rc<Cell<usize>>);
|
struct Srv1(Rc<Cell<usize>>);
|
||||||
|
|
@ -270,7 +271,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, req: &'static str) -> Self::Future {
|
fn call(&self, req: &'static str) -> Self::Future {
|
||||||
ok(req)
|
ready(Ok(req))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,7 +289,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, req: &'static str) -> Self::Future {
|
fn call(&self, req: &'static str) -> Self::Future {
|
||||||
ok((req, "srv2"))
|
ready(Ok((req, "srv2")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,14 +208,12 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use core::future::{ready, Ready};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::pipeline::{pipeline, pipeline_factory};
|
||||||
ok,
|
|
||||||
pipeline::{pipeline, pipeline_factory},
|
|
||||||
Ready,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Srv;
|
struct Srv;
|
||||||
|
|
@ -228,7 +226,7 @@ mod tests {
|
||||||
crate::always_ready!();
|
crate::always_ready!();
|
||||||
|
|
||||||
fn call(&self, _: ()) -> Self::Future {
|
fn call(&self, _: ()) -> Self::Future {
|
||||||
ok(())
|
ready(Ok(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,7 +250,7 @@ mod tests {
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_new_service() {
|
async fn test_new_service() {
|
||||||
let new_srv = pipeline_factory(apply_fn_factory(
|
let new_srv = pipeline_factory(apply_fn_factory(
|
||||||
|| ok::<_, ()>(Srv),
|
|| ready(Ok::<_, ()>(Srv)),
|
||||||
|req: &'static str, srv| {
|
|req: &'static str, srv| {
|
||||||
let fut = srv.call(());
|
let fut = srv.call(());
|
||||||
async move {
|
async move {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
use core::{future::Future, marker::PhantomData};
|
use core::{
|
||||||
|
future::{ready, Future, Ready},
|
||||||
|
marker::PhantomData,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{ok, IntoService, IntoServiceFactory, Ready, Service, ServiceFactory};
|
use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory};
|
||||||
|
|
||||||
/// Create `ServiceFactory` for function that can act as a `Service`
|
/// Create `ServiceFactory` for function that can act as a `Service`
|
||||||
pub fn fn_service<F, Fut, Req, Res, Err, Cfg>(f: F) -> FnServiceFactory<F, Fut, Req, Res, Err, Cfg>
|
pub fn fn_service<F, Fut, Req, Res, Err, Cfg>(f: F) -> FnServiceFactory<F, Fut, Req, Res, Err, Cfg>
|
||||||
|
|
@ -210,7 +213,7 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: Cfg) -> Self::Future {
|
fn new_service(&self, _: Cfg) -> Self::Future {
|
||||||
ok(FnService::new(self.f.clone()))
|
ready(Ok(FnService::new(self.f.clone())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,7 +349,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::task::Poll;
|
use core::{future::ready, task::Poll};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
|
|
@ -354,7 +357,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_fn_service() {
|
async fn test_fn_service() {
|
||||||
let new_srv = fn_service(|()| ok::<_, ()>("srv"));
|
let new_srv = fn_service(|()| ready(Ok::<_, ()>("srv")));
|
||||||
|
|
||||||
let srv = new_srv.new_service(()).await.unwrap();
|
let srv = new_srv.new_service(()).await.unwrap();
|
||||||
let res = srv.call(()).await;
|
let res = srv.call(()).await;
|
||||||
|
|
@ -365,7 +368,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_fn_service_service() {
|
async fn test_fn_service_service() {
|
||||||
let srv = fn_service(|()| ok::<_, ()>("srv"));
|
let srv = fn_service(|()| ready(Ok::<_, ()>("srv")));
|
||||||
|
|
||||||
let res = srv.call(()).await;
|
let res = srv.call(()).await;
|
||||||
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
|
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
|
||||||
|
|
@ -376,7 +379,9 @@ mod tests {
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_fn_service_with_config() {
|
async fn test_fn_service_with_config() {
|
||||||
let new_srv = fn_factory_with_config(|cfg: usize| {
|
let new_srv = fn_factory_with_config(|cfg: usize| {
|
||||||
ok::<_, ()>(fn_service(move |()| ok::<_, ()>(("srv", cfg))))
|
ready(Ok::<_, ()>(fn_service(move |()| {
|
||||||
|
ready(Ok::<_, ()>(("srv", cfg)))
|
||||||
|
})))
|
||||||
});
|
});
|
||||||
|
|
||||||
let srv = new_srv.new_service(1).await.unwrap();
|
let srv = new_srv.new_service(1).await.unwrap();
|
||||||
|
|
@ -392,14 +397,19 @@ mod tests {
|
||||||
|
|
||||||
use crate::{map_config, ServiceExt, ServiceFactoryExt};
|
use crate::{map_config, ServiceExt, ServiceFactoryExt};
|
||||||
|
|
||||||
let srv_1 = fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8)));
|
let srv_1 = fn_service(|_: Rc<u8>| ready(Ok::<_, Rc<u8>>(Rc::new(0u8))));
|
||||||
|
|
||||||
let fac_1 = fn_factory_with_config(|_: Rc<u8>| {
|
let fac_1 = fn_factory_with_config(|_: Rc<u8>| {
|
||||||
ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8))))
|
ready(Ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| {
|
||||||
|
ready(Ok::<_, Rc<u8>>(Rc::new(0u8)))
|
||||||
|
})))
|
||||||
});
|
});
|
||||||
|
|
||||||
let fac_2 =
|
let fac_2 = fn_factory(|| {
|
||||||
fn_factory(|| ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| ok::<_, Rc<u8>>(Rc::new(0u8)))));
|
ready(Ok::<_, Rc<u8>>(fn_service(|_: Rc<u8>| {
|
||||||
|
ready(Ok::<_, Rc<u8>>(Rc::new(0u8)))
|
||||||
|
})))
|
||||||
|
});
|
||||||
|
|
||||||
fn is_send<T: Send + Sync + Clone>(_: &T) {}
|
fn is_send<T: Send + Sync + Clone>(_: &T) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,10 @@ mod map_config;
|
||||||
mod map_err;
|
mod map_err;
|
||||||
mod map_init_err;
|
mod map_init_err;
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
mod ready;
|
|
||||||
mod then;
|
mod then;
|
||||||
mod transform;
|
mod transform;
|
||||||
mod transform_err;
|
mod transform_err;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
use self::ready::{err, ok, ready, Ready};
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
apply::{apply_fn, apply_fn_factory},
|
apply::{apply_fn, apply_fn_factory},
|
||||||
apply_cfg::{apply_cfg, apply_cfg_factory},
|
apply_cfg::{apply_cfg, apply_cfg_factory},
|
||||||
|
|
|
||||||
|
|
@ -199,10 +199,12 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use core::future::{ready, Ready};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{ok, IntoServiceFactory, Ready, ServiceExt, ServiceFactoryExt};
|
use crate::{IntoServiceFactory, ServiceExt, ServiceFactoryExt};
|
||||||
|
|
||||||
struct Srv;
|
struct Srv;
|
||||||
|
|
||||||
|
|
@ -214,7 +216,7 @@ mod tests {
|
||||||
crate::always_ready!();
|
crate::always_ready!();
|
||||||
|
|
||||||
fn call(&self, _: ()) -> Self::Future {
|
fn call(&self, _: ()) -> Self::Future {
|
||||||
ok(())
|
ready(Ok(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +237,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_new_service() {
|
async fn test_new_service() {
|
||||||
let new_srv = (|| ok::<_, ()>(Srv)).into_factory().map(|_| "ok");
|
let new_srv = (|| ready(Ok::<_, ()>(Srv))).into_factory().map(|_| "ok");
|
||||||
let srv = new_srv.new_service(&()).await.unwrap();
|
let srv = new_srv.new_service(&()).await.unwrap();
|
||||||
let res = srv.call(()).await;
|
let res = srv.call(()).await;
|
||||||
assert!(res.is_ok());
|
assert!(res.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -202,10 +202,12 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use core::future::{ready, Ready};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{err, ok, IntoServiceFactory, Ready, ServiceExt, ServiceFactoryExt};
|
use crate::{IntoServiceFactory, ServiceExt, ServiceFactoryExt};
|
||||||
|
|
||||||
struct Srv;
|
struct Srv;
|
||||||
|
|
||||||
|
|
@ -219,7 +221,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, _: ()) -> Self::Future {
|
fn call(&self, _: ()) -> Self::Future {
|
||||||
err(())
|
ready(Err(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +242,9 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_new_service() {
|
async fn test_new_service() {
|
||||||
let new_srv = (|| ok::<_, ()>(Srv)).into_factory().map_err(|_| "error");
|
let new_srv = (|| ready(Ok::<_, ()>(Srv)))
|
||||||
|
.into_factory()
|
||||||
|
.map_err(|_| "error");
|
||||||
let srv = new_srv.new_service(&()).await.unwrap();
|
let srv = new_srv.new_service(&()).await.unwrap();
|
||||||
let res = srv.call(()).await;
|
let res = srv.call(()).await;
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
//! When MSRV is 1.82, replace with `core::future::Ready` and `core::future::ready()`.
|
|
||||||
|
|
||||||
use core::{
|
|
||||||
future::Future,
|
|
||||||
pin::Pin,
|
|
||||||
task::{Context, Poll},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Future for the [`ready`](ready()) function.
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
|
||||||
pub struct Ready<T> {
|
|
||||||
val: Option<T>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Ready<T> {
|
|
||||||
/// Unwraps the value from this immediately ready future.
|
|
||||||
#[inline]
|
|
||||||
pub fn into_inner(mut self) -> T {
|
|
||||||
self.val.take().unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Unpin for Ready<T> {}
|
|
||||||
|
|
||||||
impl<T> Future for Ready<T> {
|
|
||||||
type Output = T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
|
|
||||||
let val = self.val.take().expect("Ready can not be polled twice.");
|
|
||||||
Poll::Ready(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a future that is immediately ready with a value.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn ready<T>(val: T) -> Ready<T> {
|
|
||||||
Ready { val: Some(val) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a future that is immediately ready with a success value.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn ok<T, E>(val: T) -> Ready<Result<T, E>> {
|
|
||||||
Ready { val: Some(Ok(val)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a future that is immediately ready with an error value.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn err<T, E>(err: E) -> Ready<Result<T, E>> {
|
|
||||||
Ready {
|
|
||||||
val: Some(Err(err)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -241,15 +241,15 @@ mod tests {
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::{
|
use core::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
|
future::{ready, Ready},
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures_util::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
err, ok,
|
|
||||||
pipeline::{pipeline, pipeline_factory},
|
pipeline::{pipeline, pipeline_factory},
|
||||||
ready, Ready, Service, ServiceFactory,
|
Service, ServiceFactory,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
@ -267,8 +267,8 @@ mod tests {
|
||||||
|
|
||||||
fn call(&self, req: Result<&'static str, &'static str>) -> Self::Future {
|
fn call(&self, req: Result<&'static str, &'static str>) -> Self::Future {
|
||||||
match req {
|
match req {
|
||||||
Ok(msg) => ok(msg),
|
Ok(msg) => ready(Ok(msg)),
|
||||||
Err(_) => err(()),
|
Err(_) => ready(Err(())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -287,8 +287,8 @@ mod tests {
|
||||||
|
|
||||||
fn call(&self, req: Result<&'static str, ()>) -> Self::Future {
|
fn call(&self, req: Result<&'static str, ()>) -> Self::Future {
|
||||||
match req {
|
match req {
|
||||||
Ok(msg) => ok((msg, "ok")),
|
Ok(msg) => ready(Ok((msg, "ok"))),
|
||||||
Err(()) => ok(("srv2", "err")),
|
Err(()) => ready(Ok(("srv2", "err"))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -221,9 +221,10 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::time::Duration;
|
use core::{
|
||||||
|
future::{ready, Ready},
|
||||||
use actix_utils::future::{ready, Ready};
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- internal: Use `core::future::{ready, Ready}` instead of actix-utils'
|
||||||
|
|
||||||
## 3.5.0
|
## 3.5.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
io::{self, IoSlice},
|
io::{self, IoSlice},
|
||||||
|
|
@ -15,10 +16,7 @@ use actix_rt::{
|
||||||
time::timeout,
|
time::timeout,
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::Counter;
|
||||||
counter::Counter,
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio_native_tls::{native_tls::Error, TlsAcceptor};
|
use tokio_native_tls::{native_tls::Error, TlsAcceptor};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -16,10 +17,7 @@ use actix_rt::{
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
counter::{Counter, CounterGuard},
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use openssl::ssl::{Error, Ssl, SslAcceptor};
|
use openssl::ssl::{Error, Ssl, SslAcceptor};
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -17,10 +18,7 @@ use actix_rt::{
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
counter::{Counter, CounterGuard},
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio_rustls::{Accept, TlsAcceptor};
|
use tokio_rustls::{Accept, TlsAcceptor};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -17,10 +18,7 @@ use actix_rt::{
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
counter::{Counter, CounterGuard},
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio_rustls::{Accept, TlsAcceptor};
|
use tokio_rustls::{Accept, TlsAcceptor};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -17,10 +18,7 @@ use actix_rt::{
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
counter::{Counter, CounterGuard},
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio_rustls::{Accept, TlsAcceptor};
|
use tokio_rustls::{Accept, TlsAcceptor};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`Acceptor`] for main service factory docs.
|
//! See [`Acceptor`] for main service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready as FutReady};
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -17,10 +18,7 @@ use actix_rt::{
|
||||||
time::{sleep, Sleep},
|
time::{sleep, Sleep},
|
||||||
};
|
};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::{
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
counter::{Counter, CounterGuard},
|
|
||||||
future::{ready, Ready as FutReady},
|
|
||||||
};
|
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio_rustls::{Accept, TlsAcceptor};
|
use tokio_rustls::{Accept, TlsAcceptor};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
|
@ -6,7 +7,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -49,7 +49,7 @@ impl<R: Host> ServiceFactory<ConnectInfo<R>> for Connector {
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(self.service())
|
ready(Ok(self.service()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use tokio_native_tls::{
|
use tokio_native_tls::{
|
||||||
native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector,
|
native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector,
|
||||||
|
|
@ -51,7 +51,7 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(self.clone())
|
ready(Ok(self.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -11,7 +12,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use openssl::ssl::SslConnector;
|
use openssl::ssl::SslConnector;
|
||||||
use tokio_openssl::SslStream as AsyncSslStream;
|
use tokio_openssl::SslStream as AsyncSslStream;
|
||||||
|
|
@ -64,9 +64,9 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(TlsConnectorService {
|
ready(Ok(TlsConnectorService {
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -10,7 +11,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::task::{spawn_blocking, JoinHandle};
|
use actix_rt::task::{spawn_blocking, JoinHandle};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::{future::LocalBoxFuture, ready};
|
use futures_core::{future::LocalBoxFuture, ready};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ impl<R: Host> ServiceFactory<ConnectInfo<R>> for Resolver {
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(self.resolver.clone())
|
ready(Ok(self.resolver.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -12,7 +13,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use tokio_rustls::{
|
use tokio_rustls::{
|
||||||
client::TlsStream as AsyncTlsStream,
|
client::TlsStream as AsyncTlsStream,
|
||||||
|
|
@ -100,9 +100,9 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(TlsConnectorService {
|
ready(Ok(TlsConnectorService {
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -12,7 +13,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use tokio_rustls::{
|
use tokio_rustls::{
|
||||||
client::TlsStream as AsyncTlsStream,
|
client::TlsStream as AsyncTlsStream,
|
||||||
|
|
@ -100,9 +100,9 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(TlsConnectorService {
|
ready(Ok(TlsConnectorService {
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -12,7 +13,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use rustls_pki_types_1::ServerName;
|
use rustls_pki_types_1::ServerName;
|
||||||
use tokio_rustls::{
|
use tokio_rustls::{
|
||||||
|
|
@ -91,9 +91,9 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(TlsConnectorService {
|
ready(Ok(TlsConnectorService {
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TlsConnector`] for main connector service factory docs.
|
//! See [`TlsConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
io,
|
io,
|
||||||
|
|
@ -12,7 +13,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::ActixStream;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use rustls_pki_types_1::ServerName;
|
use rustls_pki_types_1::ServerName;
|
||||||
use tokio_rustls::{
|
use tokio_rustls::{
|
||||||
|
|
@ -91,9 +91,9 @@ where
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(TlsConnectorService {
|
ready(Ok(TlsConnectorService {
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See [`TcpConnector`] for main connector service factory docs.
|
//! See [`TcpConnector`] for main connector service factory docs.
|
||||||
|
|
||||||
|
use core::future::{ready, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -13,7 +14,6 @@ use std::{
|
||||||
|
|
||||||
use actix_rt::net::{TcpSocket, TcpStream};
|
use actix_rt::net::{TcpSocket, TcpStream};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::future::{ok, Ready};
|
|
||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use tokio_util::sync::ReusableBoxFuture;
|
use tokio_util::sync::ReusableBoxFuture;
|
||||||
use tracing::{error, trace};
|
use tracing::{error, trace};
|
||||||
|
|
@ -41,7 +41,7 @@ impl<R: Host> ServiceFactory<ConnectInfo<R>> for TcpConnector {
|
||||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
ok(self.service())
|
ready(Ok(self.service()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
feature = "openssl"
|
feature = "openssl"
|
||||||
))]
|
))]
|
||||||
|
|
||||||
|
use core::future::ready;
|
||||||
use std::{io::Write as _, sync::Arc};
|
use std::{io::Write as _, sync::Arc};
|
||||||
|
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
|
|
@ -16,7 +17,6 @@ use actix_tls::{
|
||||||
accept::openssl::{Acceptor, TlsStream},
|
accept::openssl::{Acceptor, TlsStream},
|
||||||
connect::rustls_0_23::reexports::ClientConfig,
|
connect::rustls_0_23::reexports::ClientConfig,
|
||||||
};
|
};
|
||||||
use actix_utils::future::ok;
|
|
||||||
use rustls_pki_types_1::ServerName;
|
use rustls_pki_types_1::ServerName;
|
||||||
use tokio_rustls_026::rustls::RootCertStore;
|
use tokio_rustls_026::rustls::RootCertStore;
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ async fn accepts_connections() {
|
||||||
|
|
||||||
tls_acceptor
|
tls_acceptor
|
||||||
.map_err(|err| println!("OpenSSL error: {err:?}"))
|
.map_err(|err| println!("OpenSSL error: {err:?}"))
|
||||||
.and_then(move |_stream: TlsStream<TcpStream>| ok(()))
|
.and_then(move |_stream: TlsStream<TcpStream>| ready(Ok(())))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
extern crate tls_openssl as openssl;
|
extern crate tls_openssl as openssl;
|
||||||
|
|
||||||
|
use core::future::ready;
|
||||||
use std::io::{BufReader, Write};
|
use std::io::{BufReader, Write};
|
||||||
|
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
|
|
@ -18,7 +19,6 @@ use actix_tls::{
|
||||||
accept::rustls_0_23::{reexports::ServerConfig, Acceptor, TlsStream},
|
accept::rustls_0_23::{reexports::ServerConfig, Acceptor, TlsStream},
|
||||||
connect::openssl::reexports::SslConnector,
|
connect::openssl::reexports::SslConnector,
|
||||||
};
|
};
|
||||||
use actix_utils::future::ok;
|
|
||||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||||
use rustls_pki_types_1::PrivateKeyDer;
|
use rustls_pki_types_1::PrivateKeyDer;
|
||||||
use tls_openssl::ssl::SslVerifyMode;
|
use tls_openssl::ssl::SslVerifyMode;
|
||||||
|
|
@ -88,7 +88,7 @@ async fn accepts_connections() {
|
||||||
|
|
||||||
tls_acceptor
|
tls_acceptor
|
||||||
.map_err(|err| println!("Rustls error: {err:?}"))
|
.map_err(|err| println!("Rustls error: {err:?}"))
|
||||||
.and_then(move |_stream: TlsStream<TcpStream>| ok(()))
|
.and_then(move |_stream: TlsStream<TcpStream>| ready(Ok(())))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- internal: Use `core::future::{ready, Ready}` instead of actix-utils'
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,15 @@
|
||||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::{
|
||||||
|
future::{ready, Ready},
|
||||||
|
marker::PhantomData,
|
||||||
|
};
|
||||||
|
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
apply, ApplyTransform, IntoServiceFactory, Service, ServiceFactory, Transform,
|
apply, ApplyTransform, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||||
};
|
};
|
||||||
use actix_utils::future::{ok, Either, Ready};
|
use actix_utils::future::Either;
|
||||||
use tracing_futures::{Instrument, Instrumented};
|
use tracing_futures::{Instrument, Instrumented};
|
||||||
|
|
||||||
/// A `Service` implementation that automatically enters/exits tracing spans
|
/// A `Service` implementation that automatically enters/exits tracing spans
|
||||||
|
|
@ -84,7 +87,7 @@ where
|
||||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||||
|
|
||||||
fn new_transform(&self, service: S) -> Self::Future {
|
fn new_transform(&self, service: S) -> Self::Future {
|
||||||
ok(TracingService::new(service, self.make_span.clone()))
|
ready(Ok(TracingService::new(service, self.make_span.clone())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,6 +121,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use core::future::ready;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::{BTreeMap, BTreeSet},
|
collections::{BTreeMap, BTreeSet},
|
||||||
|
|
@ -221,10 +225,10 @@ mod test {
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn service_call() {
|
async fn service_call() {
|
||||||
let service_factory = fn_factory(|| {
|
let service_factory = fn_factory(|| {
|
||||||
ok::<_, ()>(fn_service(|req: &'static str| {
|
ready(Ok::<_, ()>(fn_service(|req: &'static str| {
|
||||||
tracing::event!(Level::TRACE, "It's happening - {}!", req);
|
tracing::event!(Level::TRACE, "It's happening - {}!", req);
|
||||||
ok::<_, ()>(())
|
ready(Ok::<_, ()>(()))
|
||||||
}))
|
})))
|
||||||
});
|
});
|
||||||
|
|
||||||
let subscriber = TestSubscriber::default();
|
let subscriber = TestSubscriber::default();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.88.
|
- Minimum supported Rust version (MSRV) is now 1.88.
|
||||||
|
- Deprecate `crate::ready::*` in favor of `core::future::{ready, Ready}`
|
||||||
|
|
||||||
## 3.0.1
|
## 3.0.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ pin_project! {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use actix_utils::future::{ready, Ready, Either};
|
/// use actix_utils::future::Either;
|
||||||
|
/// use core::future::{ready, Ready};
|
||||||
///
|
///
|
||||||
/// # async fn run() {
|
/// # async fn run() {
|
||||||
/// let res = Either::<_, Ready<usize>>::left(ready(42));
|
/// let res = Either::<_, Ready<usize>>::left(ready(42));
|
||||||
|
|
@ -81,8 +82,9 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use core::future::{ready, Ready};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::future::{ready, Ready};
|
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_either() {
|
async fn test_either() {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ mod either;
|
||||||
mod poll_fn;
|
mod poll_fn;
|
||||||
mod ready;
|
mod ready;
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
|
pub use self::ready::{err, ok, ready, Ready};
|
||||||
pub use self::{
|
pub use self::{
|
||||||
either::Either,
|
either::Either,
|
||||||
poll_fn::{poll_fn, PollFn},
|
poll_fn::{poll_fn, PollFn},
|
||||||
ready::{err, ok, ready, Ready},
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
//! When `core::future::Ready` has a `into_inner()` method, this can be deprecated.
|
//! Deprecated. Use `core::future::Ready` instead, it has the same functionality.
|
||||||
|
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|
@ -26,6 +28,7 @@ use core::{
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||||
|
#[deprecated(since = "3.0.2", note = "Use `core::future::Ready` instead.")]
|
||||||
pub struct Ready<T> {
|
pub struct Ready<T> {
|
||||||
val: Option<T>,
|
val: Option<T>,
|
||||||
}
|
}
|
||||||
|
|
@ -66,6 +69,7 @@ impl<T> Future for Ready<T> {
|
||||||
/// assert_eq!(a.into_inner(), 1);
|
/// assert_eq!(a.into_inner(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[deprecated(since = "3.0.2", note = "Use `core::future::ready(val)` instead.")]
|
||||||
pub fn ready<T>(val: T) -> Ready<T> {
|
pub fn ready<T>(val: T) -> Ready<T> {
|
||||||
Ready { val: Some(val) }
|
Ready { val: Some(val) }
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +86,7 @@ pub fn ready<T>(val: T) -> Ready<T> {
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[deprecated(since = "3.0.2", note = "Use `core::future::ready(Ok(val))` instead.")]
|
||||||
pub fn ok<T, E>(val: T) -> Ready<Result<T, E>> {
|
pub fn ok<T, E>(val: T) -> Ready<Result<T, E>> {
|
||||||
Ready { val: Some(Ok(val)) }
|
Ready { val: Some(Ok(val)) }
|
||||||
}
|
}
|
||||||
|
|
@ -98,6 +103,7 @@ pub fn ok<T, E>(val: T) -> Ready<Result<T, E>> {
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[deprecated(since = "3.0.2", note = "Use `core::future::ready(Err(err))` instead.")]
|
||||||
pub fn err<T, E>(err: E) -> Ready<Result<T, E>> {
|
pub fn err<T, E>(err: E) -> Ready<Result<T, E>> {
|
||||||
Ready {
|
Ready {
|
||||||
val: Some(Err(err)),
|
val: Some(Err(err)),
|
||||||
|
|
@ -105,6 +111,7 @@ pub fn err<T, E>(err: E) -> Ready<Result<T, E>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(deprecated)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue