blob: 872f64000aa459eb6ed4274dd2e793fc0f1e465d [file] [log] [blame]
<!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="Various utility types and functions that are generally used with Tower."><meta name="keywords" content="rust, rustlang, rust-lang, util"><title>tower::util - 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="../../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 mod"><!--[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">&#9776;</button><a class="sidebar-logo" href="../../tower/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="../../tower/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module util</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></section></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">Module <a href="../index.html">tower</a>::<wbr><a class="mod" href="#">util</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/util/mod.rs.html#1-1083">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Various utility types and functions that are generally used with Tower.</p>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="error/index.html" title="tower::util::error mod">error</a></div><div class="item-right docblock-short">Error types</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="future/index.html" title="tower::util::future mod">future</a></div><div class="item-right docblock-short">Future types</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.AndThen.html" title="tower::util::AndThen struct">AndThen</a></div><div class="item-right docblock-short">Service returned by the <a href="../trait.ServiceExt.html#method.and_then"><code>and_then</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.AndThenLayer.html" title="tower::util::AndThenLayer struct">AndThenLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces a <a href="struct.AndThen.html" title="AndThen"><code>AndThen</code></a> service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BoxCloneService.html" title="tower::util::BoxCloneService struct">BoxCloneService</a></div><div class="item-right docblock-short">A <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="Clone"><code>Clone</code></a> + <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="Send"><code>Send</code></a> boxed <a href="../trait.Service.html" title="Service"><code>Service</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BoxLayer.html" title="tower::util::BoxLayer struct">BoxLayer</a></div><div class="item-right docblock-short">A boxed <a href="../trait.Layer.html"><code>Layer</code></a> trait object.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BoxService.html" title="tower::util::BoxService struct">BoxService</a></div><div class="item-right docblock-short">A boxed <code>Service + Send</code> trait object.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CallAll.html" title="tower::util::CallAll struct">CallAll</a></div><div class="item-right docblock-short">This is a <a href="https://docs.rs/futures/latest/futures/stream/trait.Stream.html"><code>Stream</code></a> of responses resulting from calling the wrapped <a href="../trait.Service.html" title="Service"><code>Service</code></a> for each
request received on the wrapped <a href="https://docs.rs/futures/latest/futures/stream/trait.Stream.html"><code>Stream</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CallAllUnordered.html" title="tower::util::CallAllUnordered struct">CallAllUnordered</a></div><div class="item-right docblock-short">A stream of responses received from the inner service in received order.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.FutureService.html" title="tower::util::FutureService struct">FutureService</a></div><div class="item-right docblock-short">A type that implements <a href="../trait.Service.html" title="Service"><code>Service</code></a> for a <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="Future"><code>Future</code></a> that produces a <a href="../trait.Service.html" title="Service"><code>Service</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapErr.html" title="tower::util::MapErr struct">MapErr</a></div><div class="item-right docblock-short">Service returned by the <a href="../trait.ServiceExt.html#method.map_err"><code>map_err</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapErrLayer.html" title="tower::util::MapErrLayer struct">MapErrLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces <a href="struct.MapErr.html" title="MapErr"><code>MapErr</code></a> services.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapFuture.html" title="tower::util::MapFuture struct">MapFuture</a></div><div class="item-right docblock-short"><a href="../trait.Service.html" title="Service"><code>Service</code></a> returned by the <a href="../trait.ServiceExt.html#method.map_future"><code>map_future</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapFutureLayer.html" title="tower::util::MapFutureLayer struct">MapFutureLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces a <a href="struct.MapFuture.html" title="MapFuture"><code>MapFuture</code></a> service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapRequest.html" title="tower::util::MapRequest struct">MapRequest</a></div><div class="item-right docblock-short">Service returned by the <a href="../trait.ServiceExt.html#method.map_request"><code>MapRequest</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapRequestLayer.html" title="tower::util::MapRequestLayer struct">MapRequestLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces <a href="struct.MapRequest.html" title="MapRequest"><code>MapRequest</code></a> services.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapResponse.html" title="tower::util::MapResponse struct">MapResponse</a></div><div class="item-right docblock-short">Service returned by the <a href="../trait.ServiceExt.html#method.map_response"><code>map_response</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapResponseLayer.html" title="tower::util::MapResponseLayer struct">MapResponseLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces a <a href="struct.MapResponse.html" title="MapResponse"><code>MapResponse</code></a> service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapResult.html" title="tower::util::MapResult struct">MapResult</a></div><div class="item-right docblock-short">Service returned by the <a href="../trait.ServiceExt.html#method.map_result"><code>map_result</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapResultLayer.html" title="tower::util::MapResultLayer struct">MapResultLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces a <a href="struct.MapResult.html" title="MapResult"><code>MapResult</code></a> service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Oneshot.html" title="tower::util::Oneshot struct">Oneshot</a></div><div class="item-right docblock-short">A <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="Future"><code>Future</code></a> consuming a <a href="../trait.Service.html" title="Service"><code>Service</code></a> and request, waiting until the <a href="../trait.Service.html" title="Service"><code>Service</code></a>
is ready, and then calling <a href="../trait.Service.html#tymethod.call" title="Service::call"><code>Service::call</code></a> with the request, and
waiting for that <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="Future"><code>Future</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Optional.html" title="tower::util::Optional struct">Optional</a></div><div class="item-right docblock-short">Optionally forwards requests to an inner service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Ready.html" title="tower::util::Ready struct">Ready</a></div><div class="item-right docblock-short">A future that yields a mutable reference to the service when it is ready to accept a request.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadyOneshot.html" title="tower::util::ReadyOneshot struct">ReadyOneshot</a></div><div class="item-right docblock-short">A <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="Future"><code>Future</code></a> that yields the service when it is ready to accept a request.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ServiceFn.html" title="tower::util::ServiceFn struct">ServiceFn</a></div><div class="item-right docblock-short">A <a href="../trait.Service.html" title="Service"><code>Service</code></a> implemented by a closure.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Then.html" title="tower::util::Then struct">Then</a></div><div class="item-right docblock-short"><a href="../trait.Service.html" title="Service"><code>Service</code></a> returned by the <a href="../trait.ServiceExt.html#method.then"><code>then</code></a> combinator.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ThenLayer.html" title="tower::util::ThenLayer struct">ThenLayer</a></div><div class="item-right docblock-short">A <a href="../trait.Layer.html"><code>Layer</code></a> that produces a <a href="struct.Then.html" title="Then"><code>Then</code></a> service.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UnsyncBoxService.html" title="tower::util::UnsyncBoxService struct">UnsyncBoxService</a></div><div class="item-right docblock-short">A boxed <a href="../trait.Service.html" title="Service"><code>Service</code></a> trait object.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Either.html" title="tower::util::Either enum">Either</a></div><div class="item-right docblock-short">Combine two different service types into a single type.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.ServiceExt.html" title="tower::util::ServiceExt trait">ServiceExt</a></div><div class="item-right docblock-short">An extension trait for <code>Service</code>s that provides a variety of convenient
adapters</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.future_service.html" title="tower::util::future_service fn">future_service</a></div><div class="item-right docblock-short">Returns a new <a href="struct.FutureService.html" title="FutureService"><code>FutureService</code></a> for the given future.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.option_layer.html" title="tower::util::option_layer fn">option_layer</a></div><div class="item-right docblock-short">Convert an <code>Option&lt;Layer&gt;</code> into a <a href="../trait.Layer.html"><code>Layer</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.service_fn.html" title="tower::util::service_fn fn">service_fn</a></div><div class="item-right docblock-short">Returns a new <a href="struct.ServiceFn.html" title="ServiceFn"><code>ServiceFn</code></a> with the given closure.</div></div></div><h2 id="types" class="small-section-header"><a href="#types">Type Definitions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="type" href="type.ReadyAnd.html" title="tower::util::ReadyAnd type">ReadyAnd</a><span class="stab deprecated" title="">Deprecated</span></div><div class="item-right docblock-short">A future that yields a mutable reference to the service when it is ready to accept a request.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="tower" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>