Skip to content

Commit 7674109

Browse files
authored
tower: prepare to release 0.4.11 (#618)
* tower: prepare to release 0.4.11 Added - **util**: Add `CloneBoxService` which is a `Clone + Send` boxed `Service` ([#615]) - **util**: Add `ServiceExt::boxed` and `ServiceExt::clone_boxed` for applying the `BoxService` and `CloneBoxService` middleware ([#616]) - **builder**: Add `ServiceBuilder::boxed` and `ServiceBuilder::clone_boxed` for applying `BoxService` and `CloneBoxService` layers ([#616]) Fixed - **balance**: Remove redundant `Req: Clone` bound from `Clone` impls for `MakeBalance`, and `MakeBalanceLayer` ([#607]) - **balance**: Remove redundant `Req: Debug` bound from `Debug` impls for `MakeBalance`, `MakeFuture`, `Balance`, and `Pool` ([#607]) - **ready-cache**: Remove redundant `Req: Debug` bound from `Debug` impl for `ReadyCache` ([#607]) - **steer**: Remove redundant `Req: Debug` bound from `Debug` impl for `Steer` ([#607]) - **util**: Remove redundant `F: Clone` bound from `ServiceExt::map_request` ([#607]) - **docs**: Fix `doc(cfg(...))` attributes of `PeakEwmaDiscover`, and `PendingRequestsDiscover` ([#610]) - **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService` ([#617]) - **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService` ([#617]) [#607]: #607 [#610]: #610 [#616]: #616 [#617]: #617 [#615]: #615 * sorting * Rename `CloneBoxService` to `BoxCloneService` * formatting * also update changelog
1 parent 4d80f7e commit 7674109

File tree

7 files changed

+54
-46
lines changed

7 files changed

+54
-46
lines changed

tower/CHANGELOG.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
# Unreleased
99

10-
- **util**: Add `CloneBoxService` which is a `Clone + Send` boxed `Service`.
11-
- **util:** Add `ServiceExt::boxed` and `ServiceExt::clone_boxed` for applying the
12-
`BoxService` and `CloneBoxService` middleware.
13-
- **builder:** Add `ServiceBuilder::boxed` and `ServiceBuilder::clone_boxed` for
14-
applying `BoxService` and `CloneBoxService` layers.
15-
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService`.
16-
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService`.
10+
- None.
11+
12+
# 0.4.11 (November 18, 2021)
13+
14+
### Added
15+
16+
- **util**: Add `BoxCloneService` which is a `Clone + Send` boxed `Service` ([#615])
17+
- **util**: Add `ServiceExt::boxed` and `ServiceExt::boxed_clone` for applying the
18+
`BoxService` and `BoxCloneService` middleware ([#616])
19+
- **builder**: Add `ServiceBuilder::boxed` and `ServiceBuilder::boxed_clone` for
20+
applying `BoxService` and `BoxCloneService` layers ([#616])
1721

1822
### Fixed
1923

24+
- **util**: Remove redundant `F: Clone` bound from `ServiceExt::map_request` ([#607])
25+
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService` ([#617])
26+
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService` ([#617])
2027
- **balance**: Remove redundant `Req: Clone` bound from `Clone` impls
2128
for `MakeBalance`, and `MakeBalanceLayer` ([#607])
2229
- **balance**: Remove redundant `Req: Debug` bound from `Debug` impls
@@ -25,13 +32,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2532
for `ReadyCache` ([#607])
2633
- **steer**: Remove redundant `Req: Debug` bound from `Debug` impl
2734
for `Steer` ([#607])
28-
- **util**: Remove redundant `F: Clone` bound
29-
from `ServiceExt::map_request` ([#607])
3035
- **docs**: Fix `doc(cfg(...))` attributes
3136
of `PeakEwmaDiscover`, and `PendingRequestsDiscover` ([#610])
3237

3338
[#607]: https://github.com/tower-rs/tower/pull/607
3439
[#610]: https://github.com/tower-rs/tower/pull/610
40+
[#615]: https://github.com/tower-rs/tower/pull/615
41+
[#616]: https://github.com/tower-rs/tower/pull/616
42+
[#617]: https://github.com/tower-rs/tower/pull/617
3543

3644
# 0.4.10 (October 19, 2021)
3745

tower/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ name = "tower"
88
# - README.md
99
# - Update CHANGELOG.md.
1010
# - Create "vX.X.X" git tag.
11-
version = "0.4.10"
11+
version = "0.4.11"
1212
authors = ["Tower Maintainers <[email protected]>"]
1313
license = "MIT"
1414
readme = "README.md"
1515
repository = "https://github.com/tower-rs/tower"
1616
homepage = "https://github.com/tower-rs/tower"
17-
documentation = "https://docs.rs/tower/0.4.10"
17+
documentation = "https://docs.rs/tower/0.4.11"
1818
description = """
1919
Tower is a library of modular and reusable components for building robust
2020
clients and servers.

tower/src/builder/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -745,17 +745,17 @@ impl<L> ServiceBuilder<L> {
745745
self.layer(crate::util::BoxService::layer())
746746
}
747747

748-
/// This wraps the inner service with the [`Layer`] returned by [`CloneBoxService::layer()`].
748+
/// This wraps the inner service with the [`Layer`] returned by [`BoxCloneService::layer()`].
749749
///
750750
/// This is similar to the [`boxed`] method, but it requires that `Self` implement
751751
/// [`Clone`], and the returned boxed service implements [`Clone`].
752752
///
753-
/// See [`CloneBoxService`] for more details.
753+
/// See [`BoxCloneService`] for more details.
754754
///
755755
/// # Example
756756
///
757757
/// ```
758-
/// use tower::{Service, ServiceBuilder, BoxError, util::CloneBoxService};
758+
/// use tower::{Service, ServiceBuilder, BoxError, util::BoxCloneService};
759759
/// use std::time::Duration;
760760
/// #
761761
/// # struct Request;
@@ -764,8 +764,8 @@ impl<L> ServiceBuilder<L> {
764764
/// # fn new() -> Self { Self }
765765
/// # }
766766
///
767-
/// let service: CloneBoxService<Request, Response, BoxError> = ServiceBuilder::new()
768-
/// .clone_boxed()
767+
/// let service: BoxCloneService<Request, Response, BoxError> = ServiceBuilder::new()
768+
/// .boxed_clone()
769769
/// .load_shed()
770770
/// .concurrency_limit(64)
771771
/// .timeout(Duration::from_secs(10))
@@ -780,19 +780,19 @@ impl<L> ServiceBuilder<L> {
780780
/// # where S: Service<R> { svc }
781781
/// ```
782782
///
783-
/// [`CloneBoxService::layer()`]: crate::util::CloneBoxService::layer()
784-
/// [`CloneBoxService`]: crate::util::CloneBoxService
783+
/// [`BoxCloneService::layer()`]: crate::util::BoxCloneService::layer()
784+
/// [`BoxCloneService`]: crate::util::BoxCloneService
785785
/// [`boxed`]: Self::boxed
786786
#[cfg(feature = "util")]
787787
#[cfg_attr(docsrs, doc(cfg(feature = "util")))]
788-
pub fn clone_boxed<S, R>(
788+
pub fn boxed_clone<S, R>(
789789
self,
790790
) -> ServiceBuilder<
791791
Stack<
792792
tower_layer::LayerFn<
793793
fn(
794794
L::Service,
795-
) -> crate::util::CloneBoxService<
795+
) -> crate::util::BoxCloneService<
796796
R,
797797
<L::Service as Service<R>>::Response,
798798
<L::Service as Service<R>>::Error,
@@ -806,7 +806,7 @@ impl<L> ServiceBuilder<L> {
806806
L::Service: Service<R> + Clone + Send + 'static,
807807
<L::Service as Service<R>>::Future: Send + 'static,
808808
{
809-
self.layer(crate::util::CloneBoxService::layer())
809+
self.layer(crate::util::BoxCloneService::layer())
810810
}
811811
}
812812

tower/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc(html_root_url = "https://docs.rs/tower/0.4.10")]
1+
#![doc(html_root_url = "https://docs.rs/tower/0.4.11")]
22
#![warn(
33
missing_debug_implementations,
44
missing_docs,

tower/src/util/boxed/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{
1616
/// response future to be [`Send`].
1717
///
1818
/// If you need a boxed [`Service`] that implements [`Clone`] consider using
19-
/// [`CloneBoxService`](crate::util::CloneBoxService).
19+
/// [`BoxCloneService`](crate::util::BoxCloneService).
2020
///
2121
/// See module level documentation for more details.
2222
pub struct BoxService<T, U, E> {

tower/src/util/clone_boxed.rs renamed to tower/src/util/boxed_clone.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tower_service::Service;
99

1010
/// A [`Clone`] + [`Send`] boxed [`Service`].
1111
///
12-
/// [`CloneBoxService`] turns a service into a trait object, allowing the
12+
/// [`BoxCloneService`] turns a service into a trait object, allowing the
1313
/// response future type to be dynamic, and allowing the service to be cloned.
1414
///
1515
/// This is similar to [`BoxService`](super::BoxService) except the resulting
@@ -18,7 +18,7 @@ use tower_service::Service;
1818
/// # Example
1919
///
2020
/// ```
21-
/// use tower::{Service, ServiceBuilder, BoxError, util::CloneBoxService};
21+
/// use tower::{Service, ServiceBuilder, BoxError, util::BoxCloneService};
2222
/// use std::time::Duration;
2323
/// #
2424
/// # struct Request;
@@ -45,8 +45,8 @@ use tower_service::Service;
4545
/// });
4646
/// # let service = assert_service(service);
4747
///
48-
/// // `CloneBoxService` will erase the type so it's nameable
49-
/// let service: CloneBoxService<Request, Response, BoxError> = CloneBoxService::new(service);
48+
/// // `BoxCloneService` will erase the type so it's nameable
49+
/// let service: BoxCloneService<Request, Response, BoxError> = BoxCloneService::new(service);
5050
/// # let service = assert_service(service);
5151
///
5252
/// // And we can still clone the service
@@ -55,25 +55,25 @@ use tower_service::Service;
5555
/// # fn assert_service<S, R>(svc: S) -> S
5656
/// # where S: Service<R> { svc }
5757
/// ```
58-
pub struct CloneBoxService<T, U, E>(
58+
pub struct BoxCloneService<T, U, E>(
5959
Box<
6060
dyn CloneService<T, Response = U, Error = E, Future = BoxFuture<'static, Result<U, E>>>
6161
+ Send,
6262
>,
6363
);
6464

65-
impl<T, U, E> CloneBoxService<T, U, E> {
66-
/// Create a new `CloneBoxService`.
65+
impl<T, U, E> BoxCloneService<T, U, E> {
66+
/// Create a new `BoxCloneService`.
6767
pub fn new<S>(inner: S) -> Self
6868
where
6969
S: Service<T, Response = U, Error = E> + Clone + Send + 'static,
7070
S::Future: Send + 'static,
7171
{
7272
let inner = inner.map_future(|f| Box::pin(f) as _);
73-
CloneBoxService(Box::new(inner))
73+
BoxCloneService(Box::new(inner))
7474
}
7575

76-
/// Returns a [`Layer`] for wrapping a [`Service`] in a [`CloneBoxService`]
76+
/// Returns a [`Layer`] for wrapping a [`Service`] in a [`BoxCloneService`]
7777
/// middleware.
7878
///
7979
/// [`Layer`]: crate::Layer
@@ -86,7 +86,7 @@ impl<T, U, E> CloneBoxService<T, U, E> {
8686
}
8787
}
8888

89-
impl<T, U, E> Service<T> for CloneBoxService<T, U, E> {
89+
impl<T, U, E> Service<T> for BoxCloneService<T, U, E> {
9090
type Response = U;
9191
type Error = E;
9292
type Future = BoxFuture<'static, Result<U, E>>;
@@ -102,7 +102,7 @@ impl<T, U, E> Service<T> for CloneBoxService<T, U, E> {
102102
}
103103
}
104104

105-
impl<T, U, E> Clone for CloneBoxService<T, U, E> {
105+
impl<T, U, E> Clone for BoxCloneService<T, U, E> {
106106
fn clone(&self) -> Self {
107107
Self(self.0.clone_box())
108108
}
@@ -129,8 +129,8 @@ where
129129
}
130130
}
131131

132-
impl<T, U, E> fmt::Debug for CloneBoxService<T, U, E> {
132+
impl<T, U, E> fmt::Debug for BoxCloneService<T, U, E> {
133133
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
134-
fmt.debug_struct("CloneBoxService").finish()
134+
fmt.debug_struct("BoxCloneService").finish()
135135
}
136136
}

tower/src/util/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
mod and_then;
44
mod boxed;
5+
mod boxed_clone;
56
mod call_all;
6-
mod clone_boxed;
77
mod either;
88

99
mod future_service;
@@ -23,7 +23,7 @@ mod then;
2323
pub use self::{
2424
and_then::{AndThen, AndThenLayer},
2525
boxed::{BoxLayer, BoxService, UnsyncBoxService},
26-
clone_boxed::CloneBoxService,
26+
boxed_clone::BoxCloneService,
2727
either::Either,
2828
future_service::{future_service, FutureService},
2929
map_err::{MapErr, MapErrLayer},
@@ -958,7 +958,7 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
958958
///
959959
/// See [`BoxService`] for more details.
960960
///
961-
/// If `Self` implements the [`Clone`] trait, the [`clone_boxed`] method
961+
/// If `Self` implements the [`Clone`] trait, the [`boxed_clone`] method
962962
/// can be used instead, to produce a boxed service which will also
963963
/// implement [`Clone`].
964964
///
@@ -993,7 +993,7 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
993993
/// ```
994994
///
995995
/// [`Service`]: crate::Service
996-
/// [`clone_boxed`]: Self::clone_boxed
996+
/// [`boxed_clone`]: Self::boxed_clone
997997
fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
998998
where
999999
Self: Sized + Send + 'static,
@@ -1006,12 +1006,12 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
10061006
///
10071007
/// This is similar to the [`boxed`] method, but it requires that `Self` implement
10081008
/// [`Clone`], and the returned boxed service implements [`Clone`].
1009-
/// See [`CloneBoxService`] for more details.
1009+
/// See [`BoxCloneService`] for more details.
10101010
///
10111011
/// # Example
10121012
///
10131013
/// ```
1014-
/// use tower::{Service, ServiceExt, BoxError, service_fn, util::CloneBoxService};
1014+
/// use tower::{Service, ServiceExt, BoxError, service_fn, util::BoxCloneService};
10151015
/// #
10161016
/// # struct Request;
10171017
/// # struct Response;
@@ -1023,7 +1023,7 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
10231023
/// Ok::<_, BoxError>(Response::new())
10241024
/// });
10251025
///
1026-
/// let service: CloneBoxService<Request, Response, BoxError> = service
1026+
/// let service: BoxCloneService<Request, Response, BoxError> = service
10271027
/// .map_request(|req| {
10281028
/// println!("received request");
10291029
/// req
@@ -1032,7 +1032,7 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
10321032
/// println!("response produced");
10331033
/// res
10341034
/// })
1035-
/// .clone_boxed();
1035+
/// .boxed_clone();
10361036
///
10371037
/// // The boxed service can still be cloned.
10381038
/// service.clone();
@@ -1043,12 +1043,12 @@ pub trait ServiceExt<Request>: tower_service::Service<Request> {
10431043
///
10441044
/// [`Service`]: crate::Service
10451045
/// [`boxed`]: Self::boxed
1046-
fn clone_boxed(self) -> CloneBoxService<Request, Self::Response, Self::Error>
1046+
fn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error>
10471047
where
10481048
Self: Clone + Sized + Send + 'static,
10491049
Self::Future: Send + 'static,
10501050
{
1051-
CloneBoxService::new(self)
1051+
BoxCloneService::new(self)
10521052
}
10531053
}
10541054

0 commit comments

Comments
 (0)