hyper_util/service/
mod.rs

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
23
24#[cfg(feature = "service")]
25mod glue;
26#[cfg(any(feature = "client-legacy", feature = "service"))]
27mod oneshot;
28
29#[cfg(feature = "service")]
30pub use self::glue::{TowerToHyperService, TowerToHyperServiceFuture};
31#[cfg(any(feature = "client-legacy", feature = "service"))]
32pub(crate) use self::oneshot::Oneshot;