mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-01 08:56:15 +01:00
Use std::future::ready
(#231)
`std::future::ready` has been stable since 1.48 so since axum's MSRV is 1.51 we can use this rather the one from `futures_util`.
This commit is contained in:
parent
82dc847d47
commit
8a61b9ffe1
5 changed files with 12 additions and 9 deletions
|
@ -7,6 +7,7 @@
|
||||||
use super::{Extension, FromRequest, RequestParts};
|
use super::{Extension, FromRequest, RequestParts};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use hyper::server::conn::AddrStream;
|
use hyper::server::conn::AddrStream;
|
||||||
|
use std::future::ready;
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
fmt,
|
fmt,
|
||||||
|
@ -90,7 +91,7 @@ where
|
||||||
let connect_info = ConnectInfo(C::connect_info(target));
|
let connect_info = ConnectInfo(C::connect_info(target));
|
||||||
let svc = AddExtension::new(self.svc.clone(), connect_info);
|
let svc = AddExtension::new(self.svc.clone(), connect_info);
|
||||||
ResponseFuture {
|
ResponseFuture {
|
||||||
future: futures_util::future::ok(svc),
|
future: ready(Ok(svc)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +99,7 @@ where
|
||||||
opaque_future! {
|
opaque_future! {
|
||||||
/// Response future for [`IntoMakeServiceWithConnectInfo`].
|
/// Response future for [`IntoMakeServiceWithConnectInfo`].
|
||||||
pub type ResponseFuture<T> =
|
pub type ResponseFuture<T> =
|
||||||
futures_util::future::Ready<Result<T, Infallible>>;
|
std::future::Ready<Result<T, Infallible>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extractor for getting connection information produced by a [`Connected`].
|
/// Extractor for getting connection information produced by a [`Connected`].
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub use super::or::ResponseFuture as OrResponseFuture;
|
||||||
opaque_future! {
|
opaque_future! {
|
||||||
/// Response future for [`EmptyRouter`](super::EmptyRouter).
|
/// Response future for [`EmptyRouter`](super::EmptyRouter).
|
||||||
pub type EmptyRouterFuture<E> =
|
pub type EmptyRouterFuture<E> =
|
||||||
futures_util::future::Ready<Result<Response<BoxBody>, E>>;
|
std::future::Ready<Result<Response<BoxBody>, E>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
|
@ -185,5 +185,5 @@ where
|
||||||
opaque_future! {
|
opaque_future! {
|
||||||
/// Response future from [`MakeRouteService`] services.
|
/// Response future from [`MakeRouteService`] services.
|
||||||
pub type MakeRouteServiceFuture<S> =
|
pub type MakeRouteServiceFuture<S> =
|
||||||
futures_util::future::Ready<Result<S, Infallible>>;
|
std::future::Ready<Result<S, Infallible>>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
fmt,
|
fmt,
|
||||||
|
future::ready,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
|
@ -722,7 +723,7 @@ where
|
||||||
|
|
||||||
*res.status_mut() = self.status;
|
*res.status_mut() = self.status;
|
||||||
EmptyRouterFuture {
|
EmptyRouterFuture {
|
||||||
future: futures_util::future::ok(res),
|
future: ready(Ok(res)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1060,7 @@ where
|
||||||
|
|
||||||
fn call(&mut self, _target: T) -> Self::Future {
|
fn call(&mut self, _target: T) -> Self::Future {
|
||||||
future::MakeRouteServiceFuture {
|
future::MakeRouteServiceFuture {
|
||||||
future: futures_util::future::ready(Ok(self.service.clone())),
|
future: ready(Ok(self.service.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use futures_util::future::{pending, ready};
|
use std::future::{pending, ready};
|
||||||
use tower::{timeout::TimeoutLayer, MakeService};
|
use tower::{timeout::TimeoutLayer, MakeService};
|
||||||
|
|
||||||
async fn unit() {}
|
async fn unit() {}
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
||||||
service, Router,
|
service, Router,
|
||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_util::future::Ready;
|
|
||||||
use http::{
|
use http::{
|
||||||
header::{HeaderMap, AUTHORIZATION},
|
header::{HeaderMap, AUTHORIZATION},
|
||||||
Request, Response, StatusCode, Uri,
|
Request, Response, StatusCode, Uri,
|
||||||
|
@ -17,9 +16,11 @@ use http::{
|
||||||
use hyper::{Body, Server};
|
use hyper::{Body, Server};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
use std::future::Ready;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
|
future::ready,
|
||||||
net::{SocketAddr, TcpListener},
|
net::{SocketAddr, TcpListener},
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
|
@ -550,7 +551,7 @@ async fn wrong_method_service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, _req: R) -> Self::Future {
|
fn call(&mut self, _req: R) -> Self::Future {
|
||||||
futures_util::future::ok(Response::new(http_body::Empty::new()))
|
ready(Ok(Response::new(http_body::Empty::new())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue