mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-30 22:03:40 +01:00
223 lines
64 KiB
HTML
223 lines
64 KiB
HTML
<!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="API documentation for the Rust `Service` trait in crate `hyper`."><meta name="keywords" content="rust, rustlang, rust-lang, Service"><title>hyper::service::Service - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../hyper/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait Service</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Future">Future</a><a href="#associatedtype.Response">Response</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.call">call</a><a href="#tymethod.poll_ready">poll_ready</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-Service%3CRequest%3E-for-%26%27a%20mut%20S">&'a mut S</a><a href="#impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E">Box<S, Global></a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">hyper</a>::<wbr><a href="index.html">service</a></p><div id="sidebar-vars" data-name="Service" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">hyper</a>::<wbr><a href="index.html">service</a>::<wbr><a class="trait" href="">Service</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tower_service/lib.rs.html#234-272" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Service<Request> {
|
||
type <a href="#associatedtype.Response" class="type">Response</a>;
|
||
type <a href="#associatedtype.Error" class="type">Error</a>;
|
||
type <a href="#associatedtype.Future" class="type">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>;
|
||
pub 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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>>;
|
||
<div class="item-spacer"></div> pub fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, req: Request) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a>;
|
||
}</pre></div><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>
|
||
<h1 id="functional" class="section-header"><a href="#functional">Functional</a></h1>
|
||
<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>
|
||
<h1 id="server" class="section-header"><a href="#server">Server</a></h1>
|
||
<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">
|
||
<span class="kw">use</span> <span class="ident">http</span>::{<span class="ident">Request</span>, <span class="ident">Response</span>, <span class="ident">StatusCode</span>};
|
||
|
||
<span class="kw">struct</span> <span class="ident">HelloWorld</span>;
|
||
|
||
<span class="kw">impl</span> <span class="ident">Service</span><span class="op"><</span><span class="ident">Request</span><span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span><span class="op">></span><span class="op">></span> <span class="kw">for</span> <span class="ident">HelloWorld</span> {
|
||
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">Response</span><span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span><span class="op">></span>;
|
||
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">http</span>::<span class="ident">Error</span>;
|
||
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Pin</span><span class="op"><</span><span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Future</span><span class="op"><</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="self">Self</span>::<span class="ident">Response</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span><span class="op">></span><span class="op">></span>;
|
||
|
||
<span class="kw">fn</span> <span class="ident">poll_ready</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">cx</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>) <span class="op">-</span><span class="op">></span> <span class="ident">Poll</span><span class="op"><</span><span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="self">Self</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||
<span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="prelude-val">Ok</span>(()))
|
||
}
|
||
|
||
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">req</span>: <span class="ident">Request</span><span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span><span class="op">></span>) <span class="op">-</span><span class="op">></span> <span class="self">Self</span>::<span class="ident">Future</span> {
|
||
<span class="comment">// create the body</span>
|
||
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Vec</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span> <span class="op">=</span> <span class="string">"hello, world!\n"</span>
|
||
.<span class="ident">as_bytes</span>()
|
||
.<span class="ident">to_owned</span>();
|
||
<span class="comment">// Create the HTTP response</span>
|
||
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">Response</span>::<span class="ident">builder</span>()
|
||
.<span class="ident">status</span>(<span class="ident">StatusCode</span>::<span class="ident">OK</span>)
|
||
.<span class="ident">body</span>(<span class="ident">body</span>)
|
||
.<span class="ident">expect</span>(<span class="string">"Unable to create `http::Response`"</span>);
|
||
|
||
<span class="comment">// create a response in a future.</span>
|
||
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="kw">async</span> {
|
||
<span class="prelude-val">Ok</span>(<span class="ident">resp</span>)
|
||
};
|
||
|
||
<span class="comment">// Return the response as an immediate future</span>
|
||
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="ident">fut</span>)
|
||
}
|
||
}</pre></div>
|
||
<h1 id="client" class="section-header"><a href="#client">Client</a></h1>
|
||
<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='information'><div class='tooltip ignore'>ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore">
|
||
<span class="kw">let</span> <span class="ident">client</span> <span class="op">=</span> <span class="ident">redis</span>::<span class="ident">Client</span>::<span class="ident">new</span>()
|
||
.<span class="ident">connect</span>(<span class="string">"127.0.0.1:6379"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>())
|
||
.<span class="ident">unwrap</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">client</span>.<span class="ident">call</span>(<span class="ident">Cmd</span>::<span class="ident">set</span>(<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="macro">!</span>(<span class="string">"Redis response: {:?}"</span>, <span class="ident">resp</span>);</pre></div>
|
||
<h1 id="middleware--layer" class="section-header"><a href="#middleware--layer">Middleware / Layer</a></h1>
|
||
<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">
|
||
<span class="kw">use</span> <span class="ident">tower_service</span>::<span class="ident">Service</span>;
|
||
<span class="kw">use</span> <span class="ident">tower_layer</span>::<span class="ident">Layer</span>;
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">FutureExt</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">future</span>::<span class="ident">Future</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">task</span>::{<span class="ident">Context</span>, <span class="ident">Poll</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">time</span>::<span class="ident">Duration</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">pin</span>::<span class="ident">Pin</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||
|
||
<span class="comment">// Our timeout service, which wraps another service and</span>
|
||
<span class="comment">// adds a timeout to its response future.</span>
|
||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> {
|
||
<span class="ident">inner</span>: <span class="ident">T</span>,
|
||
<span class="ident">timeout</span>: <span class="ident">Duration</span>,
|
||
}
|
||
|
||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> {
|
||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">inner</span>: <span class="ident">T</span>, <span class="ident">timeout</span>: <span class="ident">Duration</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> {
|
||
<span class="ident">Timeout</span> {
|
||
<span class="ident">inner</span>,
|
||
<span class="ident">timeout</span>
|
||
}
|
||
}
|
||
}
|
||
|
||
<span class="comment">// The error returned if processing a request timed out</span>
|
||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>)]</span>
|
||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Expired</span>;
|
||
|
||
<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Display</span> <span class="kw">for</span> <span class="ident">Expired</span> {
|
||
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>) <span class="op">-</span><span class="op">></span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
|
||
<span class="macro">write</span><span class="macro">!</span>(<span class="ident">f</span>, <span class="string">"expired"</span>)
|
||
}
|
||
}
|
||
|
||
<span class="kw">impl</span> <span class="ident">Error</span> <span class="kw">for</span> <span class="ident">Expired</span> {}
|
||
|
||
<span class="comment">// We can implement `Service` for `Timeout<T>` if `T` is a `Service`</span>
|
||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span>, <span class="ident">Request</span><span class="op">></span> <span class="ident">Service</span><span class="op"><</span><span class="ident">Request</span><span class="op">></span> <span class="kw">for</span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">T</span><span class="op">></span>
|
||
<span class="kw">where</span>
|
||
<span class="ident">T</span>: <span class="ident">Service</span><span class="op"><</span><span class="ident">Request</span><span class="op">></span>,
|
||
<span class="ident">T</span>::<span class="ident">Future</span>: <span class="lifetime">'static</span>,
|
||
<span class="ident">T</span>::<span class="ident">Error</span>: <span class="ident">Into</span><span class="op"><</span><span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Error</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span><span class="op">></span><span class="op">></span> <span class="op">+</span> <span class="lifetime">'static</span>,
|
||
<span class="ident">T</span>::<span class="ident">Response</span>: <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> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">T</span>::<span class="ident">Response</span>;
|
||
<span class="comment">// Errors may be either `Expired` if the timeout expired, or the inner service's</span>
|
||
<span class="comment">// `Error` type. Therefore, we return a boxed `dyn Error + Send + Sync` trait object to erase</span>
|
||
<span class="comment">// the error's type.</span>
|
||
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Error</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span><span class="op">></span>;
|
||
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Pin</span><span class="op"><</span><span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Future</span><span class="op"><</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="self">Self</span>::<span class="ident">Response</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span><span class="op">></span><span class="op">></span>;
|
||
|
||
<span class="kw">fn</span> <span class="ident">poll_ready</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">cx</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>) <span class="op">-</span><span class="op">></span> <span class="ident">Poll</span><span class="op"><</span><span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="self">Self</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||
<span class="comment">// Our timeout service is ready if the inner service is ready.</span>
|
||
<span class="comment">// This is how backpressure can be propagated through a tree of nested services.</span>
|
||
<span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">poll_ready</span>(<span class="ident">cx</span>).<span class="ident">map_err</span>(<span class="ident">Into</span>::<span class="ident">into</span>)
|
||
}
|
||
|
||
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">req</span>: <span class="ident">Request</span>) <span class="op">-</span><span class="op">></span> <span class="self">Self</span>::<span class="ident">Future</span> {
|
||
<span class="comment">// Create a future that completes after `self.timeout`</span>
|
||
<span class="kw">let</span> <span class="ident">timeout</span> <span class="op">=</span> <span class="ident">tokio</span>::<span class="ident">time</span>::<span class="ident">sleep</span>(<span class="self">self</span>.<span class="ident">timeout</span>);
|
||
|
||
<span class="comment">// Call the inner service and get a future that resolves to the response</span>
|
||
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">call</span>(<span class="ident">req</span>);
|
||
|
||
<span class="comment">// Wrap those two futures in another future that completes when either one completes</span>
|
||
<span class="comment">//</span>
|
||
<span class="comment">// If the inner service is too slow the `sleep` future will complete first</span>
|
||
<span class="comment">// And an error will be returned and `fut` will be dropped and not polled again</span>
|
||
<span class="comment">//</span>
|
||
<span class="comment">// We have to box the errors so the types match</span>
|
||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="kw">async</span> <span class="kw">move</span> {
|
||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||
<span class="ident">res</span> <span class="op">=</span> <span class="ident">fut</span> <span class="op">=</span><span class="op">></span> {
|
||
<span class="ident">res</span>.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> <span class="ident">err</span>.<span class="ident">into</span>())
|
||
},
|
||
<span class="kw">_</span> <span class="op">=</span> <span class="ident">timeout</span> <span class="op">=</span><span class="op">></span> {
|
||
<span class="prelude-val">Err</span>(<span class="ident">Box</span>::<span class="ident">new</span>(<span class="ident">Expired</span>) <span class="kw">as</span> <span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Error</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span><span class="op">></span>)
|
||
},
|
||
}
|
||
};
|
||
|
||
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="ident">f</span>)
|
||
}
|
||
}
|
||
|
||
<span class="comment">// A layer for wrapping services in `Timeout`</span>
|
||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">TimeoutLayer</span>(<span class="ident">Duration</span>);
|
||
|
||
<span class="kw">impl</span> <span class="ident">TimeoutLayer</span> {
|
||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">delay</span>: <span class="ident">Duration</span>) <span class="op">-</span><span class="op">></span> <span class="self">Self</span> {
|
||
<span class="ident">TimeoutLayer</span>(<span class="ident">delay</span>)
|
||
}
|
||
}
|
||
|
||
<span class="kw">impl</span><span class="op"><</span><span class="ident">S</span><span class="op">></span> <span class="ident">Layer</span><span class="op"><</span><span class="ident">S</span><span class="op">></span> <span class="kw">for</span> <span class="ident">TimeoutLayer</span> {
|
||
<span class="kw">type</span> <span class="ident">Service</span> <span class="op">=</span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>;
|
||
|
||
<span class="kw">fn</span> <span class="ident">layer</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="ident">Timeout</span><span class="op"><</span><span class="ident">S</span><span class="op">></span> {
|
||
<span class="ident">Timeout</span>::<span class="ident">new</span>(<span class="ident">service</span>, <span class="self">self</span>.<span class="number">0</span>)
|
||
}
|
||
}</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>
|
||
<h1 id="backpressure" class="section-header"><a href="#backpressure">Backpressure</a></h1>
|
||
<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>
|
||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Response" class="method"><code>type <a href="#associatedtype.Response" class="type">Response</a></code><a class="srclink" href="../../src/tower_service/lib.rs.html#236" title="goto source code">[src]</a></h3><div class="docblock"><p>Responses given by the service.</p>
|
||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a></code><a class="srclink" href="../../src/tower_service/lib.rs.html#239" title="goto source code">[src]</a></h3><div class="docblock"><p>Errors produced by the service.</p>
|
||
</div><h3 id="associatedtype.Future" class="method"><code>type <a href="#associatedtype.Future" class="type">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></code><a class="srclink" href="../../src/tower_service/lib.rs.html#242" title="goto source code">[src]</a></h3><div class="docblock"><p>The future response value.</p>
|
||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.poll_ready" class="method"><code>pub 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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/tower_service/lib.rs.html#257" title="goto source code">[src]</a></h3><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>
|
||
</div><h3 id="tymethod.call" class="method"><code>pub fn <a href="#tymethod.call" class="fnname">call</a>(&mut self, req: Request) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/tower_service/lib.rs.html#271" title="goto source code">[src]</a></h3><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>
|
||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||
<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></div><span class="loading-content">Loading content...</span><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><h3 id="impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E" class="impl"><code class="in-band">impl<S, Request> <a class="trait" href="../../hyper/service/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="../../hyper/service/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></code><a href="#impl-Service%3CRequest%3E-for-Box%3CS%2C%20Global%3E" class="anchor"></a><a class="srclink" href="../../src/tower_service/lib.rs.html#291-306" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-1" class="type"><code>type <a href="#associatedtype.Response" class="type">Response</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a></code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a></code></h4><h4 id="associatedtype.Future-1" class="type"><code>type <a href="#associatedtype.Future" class="type">Future</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code></h4><h4 id="method.poll_ready" class="method hidden"><code>pub fn <a href="#method.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="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/tower_service/lib.rs.html#299" title="goto source code">[src]</a></h4><h4 id="method.call" class="method hidden"><code>pub fn <a href="#method.call" class="fnname">call</a>(&mut self, request: Request) -> <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/tower_service/lib.rs.html#303" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CRequest%3E-for-%26%27a%20mut%20S" class="impl"><code class="in-band">impl<'a, S, Request> <a class="trait" href="../../hyper/service/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 class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request> + 'a, </span></code><a href="#impl-Service%3CRequest%3E-for-%26%27a%20mut%20S" class="anchor"></a><a class="srclink" href="../../src/tower_service/lib.rs.html#274-289" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-2" class="type"><code>type <a href="#associatedtype.Response" class="type">Response</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a></code></h4><h4 id="associatedtype.Error-2" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a></code></h4><h4 id="associatedtype.Future-2" class="type"><code>type <a href="#associatedtype.Future" class="type">Future</a> = <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code></h4><h4 id="method.poll_ready-1" class="method hidden"><code>pub fn <a href="#method.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="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/tower_service/lib.rs.html#282" title="goto source code">[src]</a></h4><h4 id="method.call-1" class="method hidden"><code>pub fn <a href="#method.call" class="fnname">call</a>(&mut self, request: Request) -> <S as <a class="trait" href="../../hyper/service/trait.Service.html" title="trait hyper::service::Service">Service</a><Request>>::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/tower_service/lib.rs.html#286" title="goto source code">[src]</a></h4></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-Service%3CName%3E" class="impl"><code class="in-band">impl Service<<a class="struct" href="../../hyper/client/connect/dns/struct.Name.html" title="struct hyper::client::connect::dns::Name">Name</a>> for <a class="struct" href="../../hyper/client/connect/dns/struct.GaiResolver.html" title="struct hyper::client::connect::dns::GaiResolver">GaiResolver</a></code><a href="#impl-Service%3CName%3E" class="anchor"></a><a class="srclink" href="../../src/hyper/client/connect/dns.rs.html#110-129" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-3" class="type"><code>type <a href="#associatedtype.Response-3" class="type">Response</a> = <a class="struct" href="../../hyper/client/connect/dns/struct.GaiAddrs.html" title="struct hyper::client::connect::dns::GaiAddrs">GaiAddrs</a></code></h4><h4 id="associatedtype.Error-3" class="type"><code>type <a href="#associatedtype.Error-3" class="type">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></code></h4><h4 id="associatedtype.Future-3" class="type"><code>type <a href="#associatedtype.Future-3" class="type">Future</a> = <a class="struct" href="../../hyper/client/connect/dns/struct.GaiFuture.html" title="struct hyper::client::connect::dns::GaiFuture">GaiFuture</a></code></h4><h4 id="method.poll_ready-2" class="method hidden"><code>fn <a href="#method.poll_ready-2" 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>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/connect/dns.rs.html#115-117" title="goto source code">[src]</a></h4><h4 id="method.call-2" class="method hidden"><code>fn <a href="#method.call-2" class="fnname">call</a>(&mut self, name: <a class="struct" href="../../hyper/client/connect/dns/struct.Name.html" title="struct hyper::client::connect::dns::Name">Name</a>) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/connect/dns.rs.html#119-128" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CRequest%3CB%3E%3E" class="impl"><code class="in-band">impl<B> Service<<a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>> for <a class="struct" href="../../hyper/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="../../hyper/body/trait.HttpBody.html" title="trait hyper::body::HttpBody">HttpBody</a> + 'static, </span></code><a href="#impl-Service%3CRequest%3CB%3E%3E" class="anchor"></a><a class="srclink" href="../../src/hyper/client/conn.rs.html#306-321" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-4" class="type"><code>type <a href="#associatedtype.Response-4" class="type">Response</a> = <a class="struct" href="../../hyper/struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../../hyper/body/struct.Body.html" title="struct hyper::body::Body">Body</a>></code></h4><h4 id="associatedtype.Error-4" class="type"><code>type <a href="#associatedtype.Error-4" class="type">Error</a> = <a class="struct" href="../../hyper/struct.Error.html" title="struct hyper::Error">Error</a></code></h4><h4 id="associatedtype.Future-4" class="type"><code>type <a href="#associatedtype.Future-4" class="type">Future</a> = <a class="struct" href="../../hyper/client/conn/struct.ResponseFuture.html" title="struct hyper::client::conn::ResponseFuture">ResponseFuture</a></code></h4><h4 id="method.poll_ready-3" class="method hidden"><code>fn <a href="#method.poll_ready-3" 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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/conn.rs.html#314-316" title="goto source code">[src]</a></h4><h4 id="method.call-3" class="method hidden"><code>fn <a href="#method.call-3" class="fnname">call</a>(&mut self, req: <a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/conn.rs.html#318-320" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CRequest%3CB%3E%3E-1" class="impl"><code class="in-band">impl<C, B> Service<<a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>> for &<a class="struct" href="../../hyper/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="../../hyper/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="../../hyper/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="type" href="../../hyper/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="type" href="../../hyper/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/std/error/trait.Error.html" title="trait std::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></code><a href="#impl-Service%3CRequest%3CB%3E%3E-1" class="anchor"></a><a class="srclink" href="../../src/hyper/client/client.rs.html#517-535" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-5" class="type"><code>type <a href="#associatedtype.Response-5" class="type">Response</a> = <a class="struct" href="../../hyper/struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../../hyper/body/struct.Body.html" title="struct hyper::body::Body">Body</a>></code></h4><h4 id="associatedtype.Error-5" class="type"><code>type <a href="#associatedtype.Error-5" class="type">Error</a> = <a class="struct" href="../../hyper/struct.Error.html" title="struct hyper::Error">Error</a></code></h4><h4 id="associatedtype.Future-5" class="type"><code>type <a href="#associatedtype.Future-5" class="type">Future</a> = <a class="struct" href="../../hyper/client/struct.ResponseFuture.html" title="struct hyper::client::ResponseFuture">ResponseFuture</a></code></h4><h4 id="method.poll_ready-4" class="method hidden"><code>fn <a href="#method.poll_ready-4" class="fnname">poll_ready</a>(&mut self, _: &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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/client.rs.html#528-530" title="goto source code">[src]</a></h4><h4 id="method.call-4" class="method hidden"><code>fn <a href="#method.call-4" class="fnname">call</a>(&mut self, req: <a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/client.rs.html#532-534" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CRequest%3CB%3E%3E-2" class="impl"><code class="in-band">impl<C, B> Service<<a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>> for <a class="struct" href="../../hyper/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="../../hyper/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="../../hyper/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="type" href="../../hyper/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="type" href="../../hyper/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/std/error/trait.Error.html" title="trait std::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></code><a href="#impl-Service%3CRequest%3CB%3E%3E-2" class="anchor"></a><a class="srclink" href="../../src/hyper/client/client.rs.html#497-515" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-6" class="type"><code>type <a href="#associatedtype.Response-6" class="type">Response</a> = <a class="struct" href="../../hyper/struct.Response.html" title="struct hyper::Response">Response</a><<a class="struct" href="../../hyper/body/struct.Body.html" title="struct hyper::body::Body">Body</a>></code></h4><h4 id="associatedtype.Error-6" class="type"><code>type <a href="#associatedtype.Error-6" class="type">Error</a> = <a class="struct" href="../../hyper/struct.Error.html" title="struct hyper::Error">Error</a></code></h4><h4 id="associatedtype.Future-6" class="type"><code>type <a href="#associatedtype.Future-6" class="type">Future</a> = <a class="struct" href="../../hyper/client/struct.ResponseFuture.html" title="struct hyper::client::ResponseFuture">ResponseFuture</a></code></h4><h4 id="method.poll_ready-5" class="method hidden"><code>fn <a href="#method.poll_ready-5" class="fnname">poll_ready</a>(&mut self, _: &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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/client.rs.html#508-510" title="goto source code">[src]</a></h4><h4 id="method.call-5" class="method hidden"><code>fn <a href="#method.call-5" class="fnname">call</a>(&mut self, req: <a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a><B>) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/client.rs.html#512-514" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CT%3E" class="impl"><code class="in-band">impl<C, B, T> Service<T> for <a class="struct" href="../../hyper/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/std/error/trait.Error.html" title="trait std::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="../../hyper/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="type" href="../../hyper/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="type" href="../../hyper/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/std/error/trait.Error.html" title="trait std::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></code><a href="#impl-Service%3CT%3E" class="anchor"></a><a class="srclink" href="../../src/hyper/client/service.rs.html#40-87" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-7" class="type"><code>type <a href="#associatedtype.Response-7" class="type">Response</a> = <a class="struct" href="../../hyper/client/conn/struct.SendRequest.html" title="struct hyper::client::conn::SendRequest">SendRequest</a><B></code></h4><h4 id="associatedtype.Error-7" class="type"><code>type <a href="#associatedtype.Error-7" class="type">Error</a> = <a class="struct" href="../../hyper/struct.Error.html" title="struct hyper::Error">Error</a></code></h4><h4 id="associatedtype.Future-7" class="type"><code>type <a href="#associatedtype.Future-7" class="type">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><Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Response" title="type hyper::service::Service::Response">Response</a>, Self::<a class="type" href="../../hyper/service/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>></code></h4><h4 id="method.poll_ready-6" class="method hidden"><code>fn <a href="#method.poll_ready-6" 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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/service.rs.html#55-59" title="goto source code">[src]</a></h4><h4 id="method.call-6" class="method hidden"><code>fn <a href="#method.call-6" class="fnname">call</a>(&mut self, req: T) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/service.rs.html#61-86" title="goto source code">[src]</a></h4></div><h3 id="impl-Service%3CUri%3E" class="impl"><code class="in-band">impl<R> Service<<a class="struct" href="../../hyper/struct.Uri.html" title="struct hyper::Uri">Uri</a>> for <a class="struct" href="../../hyper/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></code><a href="#impl-Service%3CUri%3E" class="anchor"></a><a class="srclink" href="../../src/hyper/client/connect/http.rs.html#252-273" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response-8" class="type"><code>type <a href="#associatedtype.Response-8" class="type">Response</a> = <a class="struct" href="../../tokio/net/tcp/stream/struct.TcpStream.html" title="struct tokio::net::tcp::stream::TcpStream">TcpStream</a></code></h4><h4 id="associatedtype.Error-8" class="type"><code>type <a href="#associatedtype.Error-8" class="type">Error</a> = ConnectError</code></h4><h4 id="associatedtype.Future-8" class="type"><code>type <a href="#associatedtype.Future-8" class="type">Future</a> = HttpConnecting<R></code></h4><h4 id="method.poll_ready-7" class="method hidden"><code>fn <a href="#method.poll_ready-7" 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="type" href="../../hyper/service/trait.Service.html#associatedtype.Error" title="type hyper::service::Service::Error">Error</a>>></code><a class="srclink" href="../../src/hyper/client/connect/http.rs.html#261-264" title="goto source code">[src]</a></h4><h4 id="method.call-7" class="method hidden"><code>fn <a href="#method.call-7" class="fnname">call</a>(&mut self, dst: <a class="struct" href="../../hyper/struct.Uri.html" title="struct hyper::Uri">Uri</a>) -> Self::<a class="type" href="../../hyper/service/trait.Service.html#associatedtype.Future" title="type hyper::service::Service::Future">Future</a></code><a class="srclink" href="../../src/hyper/client/connect/http.rs.html#266-272" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/tower_service/trait.Service.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="hyper"></div>
|
||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |