mirror of
https://github.com/tower-rs/tower.git
synced 2025-10-02 15:25:11 +00:00
util: Remove ServiceExt::ready
(#507)
This commit is contained in:
parent
3bdaae9284
commit
b7a7c280ee
@ -9,15 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Added `MakeService::into_service` and `MakeService::as_service` for
|
- Added `MakeService::into_service` and `MakeService::as_service` for
|
||||||
converting `MakeService`s into `Service`s.
|
converting `MakeService`s into `Service`s.
|
||||||
- Make `ServiceBuilder::service` take `self` by reference rather than by value.
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- All middleware `tower-*` crates were merged into `tower` and placed
|
- All middleware `tower-*` crates were merged into `tower` and placed
|
||||||
behind feature flags.
|
behind feature flags.
|
||||||
|
- Make `ServiceBuilder::service` take `self` by reference rather than by value.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
- Remove `ServiceExt::ready`.
|
||||||
|
|
||||||
# 0.3.1 (January 17, 2020)
|
# 0.3.1 (January 17, 2020)
|
||||||
|
|
||||||
- Allow opting out of tracing/log (#410).
|
- Allow opting out of tracing/log (#410).
|
||||||
|
@ -27,7 +27,7 @@ pub use self::{
|
|||||||
map_result::{MapResult, MapResultLayer},
|
map_result::{MapResult, MapResultLayer},
|
||||||
oneshot::Oneshot,
|
oneshot::Oneshot,
|
||||||
optional::Optional,
|
optional::Optional,
|
||||||
ready::{Ready, ReadyAnd, ReadyOneshot},
|
ready::{ReadyAnd, ReadyOneshot},
|
||||||
service_fn::{service_fn, ServiceFn},
|
service_fn::{service_fn, ServiceFn},
|
||||||
then::{Then, ThenLayer},
|
then::{Then, ThenLayer},
|
||||||
try_map_request::{TryMapRequest, TryMapRequestLayer},
|
try_map_request::{TryMapRequest, TryMapRequestLayer},
|
||||||
@ -55,16 +55,6 @@ pub mod future {
|
|||||||
/// An extension trait for `Service`s that provides a variety of convenient
|
/// An extension trait for `Service`s that provides a variety of convenient
|
||||||
/// adapters
|
/// adapters
|
||||||
pub trait ServiceExt<Request>: tower_service::Service<Request> {
|
pub trait ServiceExt<Request>: tower_service::Service<Request> {
|
||||||
/// Resolves when the service is ready to accept a request.
|
|
||||||
#[deprecated(since = "0.3.1", note = "prefer `ready_and` which yields the service")]
|
|
||||||
fn ready(&mut self) -> Ready<'_, Self, Request>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
#[allow(deprecated)]
|
|
||||||
Ready::new(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Yields a mutable reference to the service when it is ready to accept a request.
|
/// Yields a mutable reference to the service when it is ready to accept a request.
|
||||||
fn ready_and(&mut self) -> ReadyAnd<'_, Self, Request>
|
fn ready_and(&mut self) -> ReadyAnd<'_, Self, Request>
|
||||||
where
|
where
|
||||||
|
@ -97,45 +97,3 @@ where
|
|||||||
f.debug_tuple("ReadyAnd").field(&self.0).finish()
|
f.debug_tuple("ReadyAnd").field(&self.0).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==== deprecated `Ready` that is just `ReadyAnd` with a unit return type.
|
|
||||||
|
|
||||||
/// A future that resolves when a `Service` is ready to accept a request.
|
|
||||||
///
|
|
||||||
/// `Ready` values are produced by `ServiceExt::ready`.
|
|
||||||
pub struct Ready<'a, T, Request>(ReadyAnd<'a, T, Request>);
|
|
||||||
|
|
||||||
// Safety: This is safe for the same reason that the impl for ReadyOneshot is safe.
|
|
||||||
impl<'a, T, Request> Unpin for Ready<'a, T, Request> {}
|
|
||||||
|
|
||||||
impl<'a, T, Request> Ready<'a, T, Request>
|
|
||||||
where
|
|
||||||
T: Service<Request>,
|
|
||||||
{
|
|
||||||
#[allow(missing_docs)]
|
|
||||||
#[deprecated(since = "0.3.1", note = "prefer `ReadyAnd` which yields the service")]
|
|
||||||
pub fn new(service: &'a mut T) -> Self {
|
|
||||||
Self(ReadyAnd::new(service))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T, Request> Future for Ready<'a, T, Request>
|
|
||||||
where
|
|
||||||
T: Service<Request>,
|
|
||||||
{
|
|
||||||
type Output = Result<(), T::Error>;
|
|
||||||
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
||||||
let _ = ready!(Pin::new(&mut self.0).poll(cx));
|
|
||||||
Poll::Ready(Ok(()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T, Request> fmt::Debug for Ready<'a, T, Request>
|
|
||||||
where
|
|
||||||
T: fmt::Debug,
|
|
||||||
{
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
f.debug_tuple("Ready").field(&self.0).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user