Skip to content

Commit 914e9c1

Browse files
committed
Replace custom BoxCloneService struct with tower::util::BoxCloneSyncService
1 parent c9f467d commit 914e9c1

File tree

5 files changed

+11
-93
lines changed

5 files changed

+11
-93
lines changed

.clippy.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
allow-mixed-uninlined-format-args = false
2-
disallowed-types = [
3-
{ path = "tower::util::BoxCloneService", reason = "Use our internal BoxCloneService which is Sync" },
4-
]

axum/src/box_clone_service.rs

Lines changed: 0 additions & 80 deletions
This file was deleted.

axum/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@
427427
#[macro_use]
428428
pub(crate) mod macros;
429429

430-
mod box_clone_service;
431430
mod boxed;
432431
mod extension;
433432
#[cfg(feature = "form")]

axum/src/middleware/from_fn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::box_clone_service::BoxCloneService;
21
use crate::response::{IntoResponse, Response};
32
use axum_core::extract::{FromRequest, FromRequestParts, Request};
43
use futures_util::future::BoxFuture;
@@ -12,6 +11,7 @@ use std::{
1211
task::{Context, Poll},
1312
};
1413
use tower::ServiceBuilder;
14+
use tower::util::BoxCloneSyncService;
1515
use tower_layer::Layer;
1616
use tower_service::Service;
1717

@@ -302,7 +302,7 @@ macro_rules! impl_service {
302302
};
303303

304304
let inner = ServiceBuilder::new()
305-
.layer_fn(BoxCloneService::new)
305+
.layer_fn(BoxCloneSyncService::new)
306306
.map_response(IntoResponse::into_response)
307307
.service(ready_inner);
308308
let next = Next { inner };
@@ -337,7 +337,7 @@ where
337337
/// The remainder of a middleware stack, including the handler.
338338
#[derive(Debug, Clone)]
339339
pub struct Next {
340-
inner: BoxCloneService<Request, Response, Infallible>,
340+
inner: BoxCloneSyncService<Request, Response, Infallible>,
341341
}
342342

343343
impl Next {

axum/src/routing/route.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{
22
body::{Body, HttpBody},
3-
box_clone_service::BoxCloneService,
43
response::Response,
54
};
65
use axum_core::{extract::Request, response::IntoResponse};
@@ -18,7 +17,7 @@ use std::{
1817
task::{ready, Context, Poll},
1918
};
2019
use tower::{
21-
util::{MapErrLayer, MapResponseLayer, Oneshot},
20+
util::{BoxCloneSyncService, MapErrLayer, MapResponseLayer, Oneshot},
2221
ServiceExt,
2322
};
2423
use tower_layer::Layer;
@@ -28,7 +27,7 @@ use tower_service::Service;
2827
///
2928
/// You normally shouldn't need to care about this type. It's used in
3029
/// [`Router::layer`](super::Router::layer).
31-
pub struct Route<E = Infallible>(BoxCloneService<Request, Response, E>);
30+
pub struct Route<E = Infallible>(BoxCloneSyncService<Request, Response, E>);
3231

3332
impl<E> Route<E> {
3433
pub(crate) fn new<T>(svc: T) -> Self
@@ -37,7 +36,7 @@ impl<E> Route<E> {
3736
T::Response: IntoResponse + 'static,
3837
T::Future: Send + 'static,
3938
{
40-
Self(BoxCloneService::new(
39+
Self(BoxCloneSyncService::new(
4140
svc.map_response(IntoResponse::into_response),
4241
))
4342
}
@@ -115,15 +114,18 @@ pin_project! {
115114
/// Response future for [`Route`].
116115
pub struct RouteFuture<E> {
117116
#[pin]
118-
inner: Oneshot<BoxCloneService<Request, Response, E>, Request>,
117+
inner: Oneshot<BoxCloneSyncService<Request, Response, E>, Request>,
119118
method: Method,
120119
allow_header: Option<Bytes>,
121120
top_level: bool,
122121
}
123122
}
124123

125124
impl<E> RouteFuture<E> {
126-
fn new(method: Method, inner: Oneshot<BoxCloneService<Request, Response, E>, Request>) -> Self {
125+
fn new(
126+
method: Method,
127+
inner: Oneshot<BoxCloneSyncService<Request, Response, E>, Request>,
128+
) -> Self {
127129
Self {
128130
inner,
129131
method,

0 commit comments

Comments
 (0)