File tree 2 files changed +34
-2
lines changed
2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,22 @@ use std::{
7
7
8
8
use super :: Oneshot ;
9
9
10
- /// A tower service converted into a hyper service.
10
+ /// A tower [`Service`][tower-svc] converted into a hyper [`Service`][hyper-svc].
11
+ ///
12
+ /// This wraps an inner tower service `S` in a [`hyper::service::Service`] implementation. See
13
+ /// the module-level documentation of [`service`][crate::service] for more information about using
14
+ /// [`tower`][tower] services and middleware with [`hyper`].
15
+ ///
16
+ /// [hyper-svc]: hyper::service::Service
17
+ /// [tower]: https://docs.rs/tower/latest/tower/
18
+ /// [tower-svc]: https://docs.rs/tower/latest/tower/trait.Service.html
11
19
#[ derive( Debug , Copy , Clone ) ]
12
20
pub struct TowerToHyperService < S > {
13
21
service : S ,
14
22
}
15
23
16
24
impl < S > TowerToHyperService < S > {
17
- /// Create a new `TowerToHyperService` from a tower service.
25
+ /// Create a new [ `TowerToHyperService`] from a tower service.
18
26
pub fn new ( tower_service : S ) -> Self {
19
27
Self {
20
28
service : tower_service,
39
47
40
48
pin_project ! {
41
49
/// Response future for [`TowerToHyperService`].
50
+ ///
51
+ /// This future is acquired by [`call`][hyper::service::Service::call]ing a
52
+ /// [`TowerToHyperService`].
42
53
pub struct TowerToHyperServiceFuture <S , R >
43
54
where
44
55
S : tower_service:: Service <R >,
Original file line number Diff line number Diff line change 1
1
//! Service utilities.
2
+ //!
3
+ //! [`hyper::service`] provides a [`Service`][hyper-svc] trait, representing an asynchronous
4
+ //! function from a `Request` to a `Response`. This provides an interface allowing middleware for
5
+ //! network application to be written in a modular and reusable way.
6
+ //!
7
+ //! This submodule provides an assortment of utilities for working with [`Service`][hyper-svc]s.
8
+ //! See the module-level documentation of [`hyper::service`] for more information.
9
+ //!
10
+ //! # Tower
11
+ //!
12
+ //! While [`hyper`] uses its own notion of a [`Service`][hyper-svc] internally, many other
13
+ //! libraries use a library such as [`tower`][tower] to provide the fundamental model of an
14
+ //! asynchronous function.
15
+ //!
16
+ //! The [`TowerToHyperService`] type provided by this submodule can be used to bridge these
17
+ //! ecosystems together. By wrapping a [`tower::Service`][tower-svc] in [`TowerToHyperService`],
18
+ //! it can be passed into [`hyper`] interfaces that expect a [`hyper::service::Service`].
19
+ //!
20
+ //! [hyper-svc]: hyper::service::Service
21
+ //! [tower]: https://docs.rs/tower/latest/tower/
22
+ //! [tower-svc]: https://docs.rs/tower/latest/tower/trait.Service.html
2
23
3
24
#[ cfg( feature = "service" ) ]
4
25
mod glue;
You can’t perform that action at this time.
0 commit comments