| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="An asynchronous function from a `Request` to a `Response`."><meta name="keywords" content="rust, rustlang, rust-lang, Service"><title>Service in hyper::service - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../hyper/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../hyper/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Service</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Future">Future</a></li><li><a href="#associatedtype.Response">Response</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.call">call</a></li><li><a href="#tymethod.poll_ready">poll_ready</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Service%3CRequest%3E-for-%26%27a%20mut%20S">&'a mut S</a></li><li><a href="#impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E">Box<S, Global></a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In hyper::service</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">hyper</a>::<wbr><a href="index.html">service</a>::<wbr><a class="trait" href="#">Service</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/tower_service/lib.rs.html#311">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait Service<Request> { |
| type <a href="#associatedtype.Response" class="associatedtype">Response</a>; |
| type <a href="#associatedtype.Error" class="associatedtype">Error</a>; |
| type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a>, Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>>; |
| |
| fn <a href="#tymethod.poll_ready" class="fnname">poll_ready</a>(<br> &mut self,<br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>>; |
| <span class="item-spacer"></span> fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, req: Request) -> Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a>; |
| }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An asynchronous function from a <code>Request</code> to a <code>Response</code>.</p> |
| <p>The <code>Service</code> trait is a simplified interface making it easy to write |
| network applications in a modular and reusable way, decoupled from the |
| underlying protocol. It is one of Tower’s fundamental abstractions.</p> |
| <h2 id="functional"><a href="#functional">Functional</a></h2> |
| <p>A <code>Service</code> is a function of a <code>Request</code>. It immediately returns a |
| <code>Future</code> representing the eventual completion of processing the |
| request. The actual request processing may happen at any time in the |
| future, on any thread or executor. The processing may depend on calling |
| other services. At some point in the future, the processing will complete, |
| and the <code>Future</code> will resolve to a response or error.</p> |
| <p>At a high level, the <code>Service::call</code> function represents an RPC request. The |
| <code>Service</code> value can be a server or a client.</p> |
| <h2 id="server"><a href="#server">Server</a></h2> |
| <p>An RPC server <em>implements</em> the <code>Service</code> trait. Requests received by the |
| server over the network are deserialized and then passed as an argument to the |
| server value. The returned response is sent back over the network.</p> |
| <p>As an example, here is how an HTTP request is processed by a server:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>http::{Request, Response, StatusCode}; |
| |
| <span class="kw">struct </span>HelloWorld; |
| |
| <span class="kw">impl </span>Service<Request<Vec<u8>>> <span class="kw">for </span>HelloWorld { |
| <span class="kw">type </span>Response = Response<Vec<u8>>; |
| <span class="kw">type </span>Error = http::Error; |
| <span class="kw">type </span>Future = Pin<Box<<span class="kw">dyn </span>Future<Output = <span class="prelude-ty">Result</span><<span class="self">Self</span>::Response, <span class="self">Self</span>::Error>>>>; |
| |
| <span class="kw">fn </span>poll_ready(<span class="kw-2">&mut </span><span class="self">self</span>, cx: <span class="kw-2">&mut </span>Context<<span class="lifetime">'_</span>>) -> Poll<<span class="prelude-ty">Result</span><(), <span class="self">Self</span>::Error>> { |
| Poll::Ready(<span class="prelude-val">Ok</span>(())) |
| } |
| |
| <span class="kw">fn </span>call(<span class="kw-2">&mut </span><span class="self">self</span>, req: Request<Vec<u8>>) -> <span class="self">Self</span>::Future { |
| <span class="comment">// create the body |
| </span><span class="kw">let </span>body: Vec<u8> = <span class="string">"hello, world!\n" |
| </span>.as_bytes() |
| .to_owned(); |
| <span class="comment">// Create the HTTP response |
| </span><span class="kw">let </span>resp = Response::builder() |
| .status(StatusCode::OK) |
| .body(body) |
| .expect(<span class="string">"Unable to create `http::Response`"</span>); |
| |
| <span class="comment">// create a response in a future. |
| </span><span class="kw">let </span>fut = <span class="kw">async </span>{ |
| <span class="prelude-val">Ok</span>(resp) |
| }; |
| |
| <span class="comment">// Return the response as an immediate future |
| </span>Box::pin(fut) |
| } |
| }</code></pre></div> |
| <h2 id="client"><a href="#client">Client</a></h2> |
| <p>A client consumes a service by using a <code>Service</code> value. The client may |
| issue requests by invoking <code>call</code> and passing the request as an argument. |
| It then receives the response by waiting for the returned future.</p> |
| <p>As an example, here is how a Redis request would be issued:</p> |
| |
| <div class="example-wrap ignore"><div class='tooltip'>ⓘ</div><pre class="rust rust-example-rendered"><code><span class="kw">let </span>client = redis::Client::new() |
| .connect(<span class="string">"127.0.0.1:6379"</span>.parse().unwrap()) |
| .unwrap(); |
| |
| <span class="kw">let </span>resp = client.call(Cmd::set(<span class="string">"foo"</span>, <span class="string">"this is the value of foo"</span>)).<span class="kw">await</span><span class="question-mark">?</span>; |
| |
| <span class="comment">// Wait for the future to resolve |
| </span><span class="macro">println!</span>(<span class="string">"Redis response: {:?}"</span>, resp);</code></pre></div> |
| <h2 id="middleware--layer"><a href="#middleware--layer">Middleware / Layer</a></h2> |
| <p>More often than not, all the pieces needed for writing robust, scalable |
| network applications are the same no matter the underlying protocol. By |
| unifying the API for both clients and servers in a protocol agnostic way, |
| it is possible to write middleware that provide these pieces in a |
| reusable way.</p> |
| <p>Take timeouts as an example:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tower_service::Service; |
| <span class="kw">use </span>tower_layer::Layer; |
| <span class="kw">use </span>futures::FutureExt; |
| <span class="kw">use </span>std::future::Future; |
| <span class="kw">use </span>std::task::{Context, Poll}; |
| <span class="kw">use </span>std::time::Duration; |
| <span class="kw">use </span>std::pin::Pin; |
| <span class="kw">use </span>std::fmt; |
| <span class="kw">use </span>std::error::Error; |
| |
| <span class="comment">// Our timeout service, which wraps another service and |
| // adds a timeout to its response future. |
| </span><span class="kw">pub struct </span>Timeout<T> { |
| inner: T, |
| timeout: Duration, |
| } |
| |
| <span class="kw">impl</span><T> Timeout<T> { |
| <span class="kw">pub fn </span>new(inner: T, timeout: Duration) -> Timeout<T> { |
| Timeout { |
| inner, |
| timeout |
| } |
| } |
| } |
| |
| <span class="comment">// The error returned if processing a request timed out |
| </span><span class="attribute">#[derive(Debug)] |
| </span><span class="kw">pub struct </span>Expired; |
| |
| <span class="kw">impl </span>fmt::Display <span class="kw">for </span>Expired { |
| <span class="kw">fn </span>fmt(<span class="kw-2">&</span><span class="self">self</span>, f: <span class="kw-2">&mut </span>fmt::Formatter<<span class="lifetime">'_</span>>) -> fmt::Result { |
| <span class="macro">write!</span>(f, <span class="string">"expired"</span>) |
| } |
| } |
| |
| <span class="kw">impl </span>Error <span class="kw">for </span>Expired {} |
| |
| <span class="comment">// We can implement `Service` for `Timeout<T>` if `T` is a `Service` |
| </span><span class="kw">impl</span><T, Request> Service<Request> <span class="kw">for </span>Timeout<T> |
| <span class="kw">where |
| </span>T: Service<Request>, |
| T::Future: <span class="lifetime">'static</span>, |
| T::Error: Into<Box<<span class="kw">dyn </span>Error + Send + Sync>> + <span class="lifetime">'static</span>, |
| T::Response: <span class="lifetime">'static</span>, |
| { |
| <span class="comment">// `Timeout` doesn't modify the response type, so we use `T`'s response type |
| </span><span class="kw">type </span>Response = T::Response; |
| <span class="comment">// Errors may be either `Expired` if the timeout expired, or the inner service's |
| // `Error` type. Therefore, we return a boxed `dyn Error + Send + Sync` trait object to erase |
| // the error's type. |
| </span><span class="kw">type </span>Error = Box<<span class="kw">dyn </span>Error + Send + Sync>; |
| <span class="kw">type </span>Future = Pin<Box<<span class="kw">dyn </span>Future<Output = <span class="prelude-ty">Result</span><<span class="self">Self</span>::Response, <span class="self">Self</span>::Error>>>>; |
| |
| <span class="kw">fn </span>poll_ready(<span class="kw-2">&mut </span><span class="self">self</span>, cx: <span class="kw-2">&mut </span>Context<<span class="lifetime">'_</span>>) -> Poll<<span class="prelude-ty">Result</span><(), <span class="self">Self</span>::Error>> { |
| <span class="comment">// Our timeout service is ready if the inner service is ready. |
| // This is how backpressure can be propagated through a tree of nested services. |
| </span><span class="self">self</span>.inner.poll_ready(cx).map_err(Into::into) |
| } |
| |
| <span class="kw">fn </span>call(<span class="kw-2">&mut </span><span class="self">self</span>, req: Request) -> <span class="self">Self</span>::Future { |
| <span class="comment">// Create a future that completes after `self.timeout` |
| </span><span class="kw">let </span>timeout = tokio::time::sleep(<span class="self">self</span>.timeout); |
| |
| <span class="comment">// Call the inner service and get a future that resolves to the response |
| </span><span class="kw">let </span>fut = <span class="self">self</span>.inner.call(req); |
| |
| <span class="comment">// Wrap those two futures in another future that completes when either one completes |
| // |
| // If the inner service is too slow the `sleep` future will complete first |
| // And an error will be returned and `fut` will be dropped and not polled again |
| // |
| // We have to box the errors so the types match |
| </span><span class="kw">let </span>f = <span class="kw">async move </span>{ |
| <span class="macro">tokio::select! </span>{ |
| res = fut => { |
| res.map_err(|err| err.into()) |
| }, |
| <span class="kw">_ </span>= timeout => { |
| <span class="prelude-val">Err</span>(Box::new(Expired) <span class="kw">as </span>Box<<span class="kw">dyn </span>Error + Send + Sync>) |
| }, |
| } |
| }; |
| |
| Box::pin(f) |
| } |
| } |
| |
| <span class="comment">// A layer for wrapping services in `Timeout` |
| </span><span class="kw">pub struct </span>TimeoutLayer(Duration); |
| |
| <span class="kw">impl </span>TimeoutLayer { |
| <span class="kw">pub fn </span>new(delay: Duration) -> <span class="self">Self </span>{ |
| TimeoutLayer(delay) |
| } |
| } |
| |
| <span class="kw">impl</span><S> Layer<S> <span class="kw">for </span>TimeoutLayer { |
| <span class="kw">type </span>Service = Timeout<S>; |
| |
| <span class="kw">fn </span>layer(<span class="kw-2">&</span><span class="self">self</span>, service: S) -> Timeout<S> { |
| Timeout::new(service, <span class="self">self</span>.<span class="number">0</span>) |
| } |
| }</code></pre></div> |
| <p>The above timeout implementation is decoupled from the underlying protocol |
| and is also decoupled from client or server concerns. In other words, the |
| same timeout middleware could be used in either a client or a server.</p> |
| <h2 id="backpressure"><a href="#backpressure">Backpressure</a></h2> |
| <p>Calling a <code>Service</code> which is at capacity (i.e., it is temporarily unable to process a |
| request) should result in an error. The caller is responsible for ensuring |
| that the service is ready to receive the request before calling it.</p> |
| <p><code>Service</code> provides a mechanism by which the caller is able to coordinate |
| readiness. <code>Service::poll_ready</code> returns <code>Ready</code> if the service expects that |
| it is able to process a request.</p> |
| <h2 id="be-careful-when-cloning-inner-services"><a href="#be-careful-when-cloning-inner-services">Be careful when cloning inner services</a></h2> |
| <p>Services are permitted to panic if <code>call</code> is invoked without obtaining <code>Poll::Ready(Ok(()))</code> |
| from <code>poll_ready</code>. You should therefore be careful when cloning services for example to move |
| them into boxed futures. Even though the original service is ready, the clone might not be.</p> |
| <p>Therefore this kind of code is wrong and might panic:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Wrapper<S> { |
| inner: S, |
| } |
| |
| <span class="kw">impl</span><R, S> Service<R> <span class="kw">for </span>Wrapper<S> |
| <span class="kw">where |
| </span>S: Service<R> + Clone + <span class="lifetime">'static</span>, |
| R: <span class="lifetime">'static</span>, |
| { |
| <span class="kw">type </span>Response = S::Response; |
| <span class="kw">type </span>Error = S::Error; |
| <span class="kw">type </span>Future = Pin<Box<<span class="kw">dyn </span>Future<Output = <span class="prelude-ty">Result</span><<span class="self">Self</span>::Response, <span class="self">Self</span>::Error>>>>; |
| |
| <span class="kw">fn </span>poll_ready(<span class="kw-2">&mut </span><span class="self">self</span>, cx: <span class="kw-2">&mut </span>Context<<span class="lifetime">'_</span>>) -> Poll<<span class="prelude-ty">Result</span><(), <span class="self">Self</span>::Error>> { |
| Poll::Ready(<span class="prelude-val">Ok</span>(())) |
| } |
| |
| <span class="kw">fn </span>call(<span class="kw-2">&mut </span><span class="self">self</span>, req: R) -> <span class="self">Self</span>::Future { |
| <span class="kw">let </span><span class="kw-2">mut </span>inner = <span class="self">self</span>.inner.clone(); |
| Box::pin(<span class="kw">async move </span>{ |
| <span class="comment">// `inner` might not be ready since its a clone |
| </span>inner.call(req).<span class="kw">await |
| </span>}) |
| } |
| }</code></pre></div> |
| <p>You should instead use <a href="https://doc.rust-lang.org/nightly/core/mem/fn.replace.html" title="std::mem::replace"><code>std::mem::replace</code></a> to take the service that was ready:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Wrapper<S> { |
| inner: S, |
| } |
| |
| <span class="kw">impl</span><R, S> Service<R> <span class="kw">for </span>Wrapper<S> |
| <span class="kw">where |
| </span>S: Service<R> + Clone + <span class="lifetime">'static</span>, |
| R: <span class="lifetime">'static</span>, |
| { |
| <span class="kw">type </span>Response = S::Response; |
| <span class="kw">type </span>Error = S::Error; |
| <span class="kw">type </span>Future = Pin<Box<<span class="kw">dyn </span>Future<Output = <span class="prelude-ty">Result</span><<span class="self">Self</span>::Response, <span class="self">Self</span>::Error>>>>; |
| |
| <span class="kw">fn </span>poll_ready(<span class="kw-2">&mut </span><span class="self">self</span>, cx: <span class="kw-2">&mut </span>Context<<span class="lifetime">'_</span>>) -> Poll<<span class="prelude-ty">Result</span><(), <span class="self">Self</span>::Error>> { |
| Poll::Ready(<span class="prelude-val">Ok</span>(())) |
| } |
| |
| <span class="kw">fn </span>call(<span class="kw-2">&mut </span><span class="self">self</span>, req: R) -> <span class="self">Self</span>::Future { |
| <span class="kw">let </span>clone = <span class="self">self</span>.inner.clone(); |
| <span class="comment">// take the service that was ready |
| </span><span class="kw">let </span><span class="kw-2">mut </span>inner = std::mem::replace(<span class="kw-2">&mut </span><span class="self">self</span>.inner, clone); |
| Box::pin(<span class="kw">async move </span>{ |
| inner.call(req).<span class="kw">await |
| </span>}) |
| } |
| }</code></pre></div> |
| </div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Response" class="method has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#313">source</a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a></h4></section></summary><div class="docblock"><p>Responses given by the service.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Error" class="method has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#316">source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a></h4></section></summary><div class="docblock"><p>Errors produced by the service.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Future" class="method has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#319">source</a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a>, Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></h4></section></summary><div class="docblock"><p>The future response value.</p> |
| </div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.poll_ready" class="method has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#340">source</a><h4 class="code-header">fn <a href="#tymethod.poll_ready" class="fnname">poll_ready</a>(&mut self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></h4></section></summary><div class="docblock"><p>Returns <code>Poll::Ready(Ok(()))</code> when the service is able to process requests.</p> |
| <p>If the service is at capacity, then <code>Poll::Pending</code> is returned and the task |
| is notified when the service becomes ready again. This function is |
| expected to be called while on a task. Generally, this can be done with |
| a simple <code>futures::future::poll_fn</code> call.</p> |
| <p>If <code>Poll::Ready(Err(_))</code> is returned, the service is no longer able to service requests |
| and the caller should discard the service instance.</p> |
| <p>Once <code>poll_ready</code> returns <code>Poll::Ready(Ok(()))</code>, a request may be dispatched to the |
| service using <code>call</code>. Until a request is dispatched, repeated calls to |
| <code>poll_ready</code> must return either <code>Poll::Ready(Ok(()))</code> or <code>Poll::Ready(Err(_))</code>.</p> |
| <p>Note that <code>poll_ready</code> may reserve shared resources that are consumed in a subsequent |
| invocation of <code>call</code>. Thus, it is critical for implementations to not assume that <code>call</code> |
| will always be invoked and to ensure that such resources are released if the service is |
| dropped before <code>call</code> is invoked or the future returned by <code>call</code> is dropped before it |
| is polled.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.call" class="method has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#354">source</a><h4 class="code-header">fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, req: Request) -> Self::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></h4></section></summary><div class="docblock"><p>Process the request and return the response asynchronously.</p> |
| <p>This function is expected to be callable off task. As such, |
| implementations should take care to not call <code>poll_ready</code>.</p> |
| <p>Before dispatching a request, <code>poll_ready</code> must be called and return |
| <code>Poll::Ready(Ok(()))</code>.</p> |
| <h5 id="panics"><a href="#panics">Panics</a></h5> |
| <p>Implementations are permitted to panic if <code>call</code> is invoked without |
| obtaining <code>Poll::Ready(Ok(()))</code> from <code>poll_ready</code>.</p> |
| </div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#374">source</a><a href="#impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E" class="anchor"></a><h3 class="code-header">impl<S, Request> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><S, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>><span class="where fmt-newline">where<br> S: <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a></h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a></h4></section><section id="associatedtype.Future-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></h4></section><section id="method.poll_ready" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#382">source</a><a href="#method.poll_ready" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.poll_ready" class="fnname">poll_ready</a>(<br> &mut self,<br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></h4></section><section id="method.call" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#386">source</a><a href="#method.call" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, request: Request) -> <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CRequest%3E-for-%26%27a%20mut%20S" class="impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#357">source</a><a href="#impl-Service%3CRequest%3E-for-%26%27a%20mut%20S" class="anchor"></a><h3 class="code-header">impl<'a, S, Request> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>S<span class="where fmt-newline">where<br> S: 'a + <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a></h4></section><section id="associatedtype.Error-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a></h4></section><section id="associatedtype.Future-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></h4></section><section id="method.poll_ready-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#365">source</a><a href="#method.poll_ready-1" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.poll_ready" class="fnname">poll_ready</a>(<br> &mut self,<br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></h4></section><section id="method.call-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/tower_service/lib.rs.html#369">source</a><a href="#method.call-1" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, request: Request) -> <S as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CName%3E-for-GaiResolver" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/connect/dns.rs.html#111-130">source</a><a href="#impl-Service%3CName%3E-for-GaiResolver" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><<a class="struct" href="../client/connect/dns/struct.Name.html" title="struct hyper::client::connect::dns::Name">Name</a>> for <a class="struct" href="../client/connect/dns/struct.GaiResolver.html" title="struct hyper::client::connect::dns::GaiResolver">GaiResolver</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-3" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../client/connect/dns/struct.GaiAddrs.html" title="struct hyper::client::connect::dns::GaiAddrs">GaiAddrs</a></h4></section><section id="associatedtype.Error-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-3" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></h4></section><section id="associatedtype.Future-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-3" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <a class="struct" href="../client/connect/dns/struct.GaiFuture.html" title="struct hyper::client::connect::dns::GaiFuture">GaiFuture</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CRequest%3CB%3E%3E-for-SendRequest%3CB%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/conn.rs.html#376-391">source</a><a href="#impl-Service%3CRequest%3CB%3E%3E-for-SendRequest%3CB%3E" class="anchor"></a><h3 class="code-header">impl<B> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><<a class="struct" href="../struct.Request.html" title="struct hyper::Request">Request</a><B>> for <a class="struct" href="../client/conn/struct.SendRequest.html" title="struct hyper::client::conn::SendRequest">SendRequest</a><B><span class="where fmt-newline">where<br> B: <a class="trait" href="../body/trait.HttpBody.html" title="trait hyper::body::HttpBody">HttpBody</a> + 'static,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-4" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../body/struct.Body.html" title="struct hyper::body::Body">Body</a>></h4></section><section id="associatedtype.Error-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-4" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <a class="struct" href="../struct.Error.html" title="struct hyper::Error">Error</a></h4></section><section id="associatedtype.Future-4" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-4" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <a class="struct" href="../client/conn/struct.ResponseFuture.html" title="struct hyper::client::conn::ResponseFuture">ResponseFuture</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CRequest%3CB%3E%3E-for-%26Client%3CC%2C%20B%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/client.rs.html#556-574">source</a><a href="#impl-Service%3CRequest%3CB%3E%3E-for-%26Client%3CC%2C%20B%3E" class="anchor"></a><h3 class="code-header">impl<C, B> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><<a class="struct" href="../struct.Request.html" title="struct hyper::Request">Request</a><B>> for &<a class="struct" href="../client/struct.Client.html" title="struct hyper::client::Client">Client</a><C, B><span class="where fmt-newline">where<br> C: <a class="trait" href="../client/connect/trait.Connect.html" title="trait hyper::client::connect::Connect">Connect</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,<br> B: <a class="trait" href="../body/trait.HttpBody.html" title="trait hyper::body::HttpBody">HttpBody</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Data" title="type hyper::body::HttpBody::Data">Data</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Error" title="type hyper::body::HttpBody::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>>>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-5" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-5" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../body/struct.Body.html" title="struct hyper::body::Body">Body</a>></h4></section><section id="associatedtype.Error-5" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-5" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <a class="struct" href="../struct.Error.html" title="struct hyper::Error">Error</a></h4></section><section id="associatedtype.Future-5" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-5" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <a class="struct" href="../client/struct.ResponseFuture.html" title="struct hyper::client::ResponseFuture">ResponseFuture</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CRequest%3CB%3E%3E-for-Client%3CC%2C%20B%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/client.rs.html#536-554">source</a><a href="#impl-Service%3CRequest%3CB%3E%3E-for-Client%3CC%2C%20B%3E" class="anchor"></a><h3 class="code-header">impl<C, B> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><<a class="struct" href="../struct.Request.html" title="struct hyper::Request">Request</a><B>> for <a class="struct" href="../client/struct.Client.html" title="struct hyper::client::Client">Client</a><C, B><span class="where fmt-newline">where<br> C: <a class="trait" href="../client/connect/trait.Connect.html" title="trait hyper::client::connect::Connect">Connect</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,<br> B: <a class="trait" href="../body/trait.HttpBody.html" title="trait hyper::body::HttpBody">HttpBody</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Data" title="type hyper::body::HttpBody::Data">Data</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Error" title="type hyper::body::HttpBody::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>>>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-6" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-6" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../body/struct.Body.html" title="struct hyper::body::Body">Body</a>></h4></section><section id="associatedtype.Error-6" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-6" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <a class="struct" href="../struct.Error.html" title="struct hyper::Error">Error</a></h4></section><section id="associatedtype.Future-6" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-6" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <a class="struct" href="../client/struct.ResponseFuture.html" title="struct hyper::client::ResponseFuture">ResponseFuture</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CT%3E-for-Connect%3CC%2C%20B%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/service.rs.html#45-94">source</a><a href="#impl-Service%3CT%3E-for-Connect%3CC%2C%20B%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<C, B, T> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><T> for <a class="struct" href="../client/service/struct.Connect.html" title="struct hyper::client::service::Connect">Connect</a><C, B, T><span class="where fmt-newline">where<br> C: MakeConnection<T>,<br> C::Connection: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> C::Future: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> C::Error: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> B: <a class="trait" href="../body/trait.HttpBody.html" title="trait hyper::body::HttpBody">HttpBody</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Data" title="type hyper::body::HttpBody::Data">Data</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,<br> B::<a class="associatedtype" href="../body/trait.HttpBody.html#associatedtype.Error" title="type hyper::body::HttpBody::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>>>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-7" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-7" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../client/conn/struct.SendRequest.html" title="struct hyper::client::conn::SendRequest">SendRequest</a><B></h4></section><section id="associatedtype.Error-7" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-7" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = <a class="struct" href="../struct.Error.html" title="struct hyper::Error">Error</a></h4></section><section id="associatedtype.Future-7" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-7" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<<a class="struct" href="../client/service/struct.Connect.html" title="struct hyper::client::service::Connect">Connect</a><C, B, T> as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><T>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a>, <<a class="struct" href="../client/service/struct.Connect.html" title="struct hyper::client::service::Connect">Connect</a><C, B, T> as <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><T>>::<a class="associatedtype" href="trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>>></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Service%3CUri%3E-for-HttpConnector%3CR%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/hyper/client/connect/http.rs.html#254-275">source</a><a href="#impl-Service%3CUri%3E-for-HttpConnector%3CR%3E" class="anchor"></a><h3 class="code-header">impl<R> <a class="trait" href="trait.Service.html" title="trait hyper::service::Service">Service</a><<a class="struct" href="../struct.Uri.html" title="struct hyper::Uri">Uri</a>> for <a class="struct" href="../client/connect/struct.HttpConnector.html" title="struct hyper::client::connect::HttpConnector">HttpConnector</a><R><span class="where fmt-newline">where<br> R: Resolve + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,<br> R::Future: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Response-8" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Response-8" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Response" class="associatedtype">Response</a> = <a class="struct" href="../../tokio/net/tcp/stream/struct.TcpStream.html" title="struct tokio::net::tcp::stream::TcpStream">TcpStream</a></h4></section><section id="associatedtype.Error-8" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-8" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = ConnectError</h4></section><section id="associatedtype.Future-8" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Future-8" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Future" class="associatedtype">Future</a> = HttpConnecting<R></h4></section></div></details></div><script src="../../implementors/tower_service/trait.Service.js" data-ignore-extern-crates="alloc" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="hyper" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |