Files
mercator_service/actix_service/trait.ServiceExt.html

48 lines
20 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 `ServiceExt` trait in crate `actix_service`."><meta name="keywords" content="rust, rustlang, rust-lang, ServiceExt"><title>actix_service::ServiceExt - 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="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><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">&#9776;</div><a href='../actix_service/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Trait ServiceExt</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.and_then">and_then</a><a href="#method.apply_fn">apply_fn</a><a href="#method.from_err">from_err</a><a href="#method.map">map</a><a href="#method.map_err">map_err</a><a href="#method.then">then</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>actix_service</a></p><script>window.sidebarCurrent = {name: 'ServiceExt', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></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><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='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/actix_service/lib.rs.html#81-172' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='index.html'>actix_service</a>::<wbr><a class="trait" href=''>ServiceExt</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait ServiceExt: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a> {
fn <a href='#method.apply_fn' class='fnname'>apply_fn</a>&lt;F, B, B1, Out&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;service: B1, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; AndThenApply&lt;Self, B, F, Out&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>B) -&gt; Out,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out: <a class="trait" href="../futures/future/trait.IntoFuture.html" title="trait futures::future::IntoFuture">IntoFuture</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out::<a class="type" href="../futures/future/trait.IntoFuture.html#associatedtype.Error" title="type futures::future::IntoFuture::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>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B1: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a>&lt;B&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.and_then' class='fnname'>and_then</a>&lt;F, B&gt;(self, service: F) -&gt; <a class="struct" href="../actix_service/struct.AndThen.html" title="struct actix_service::AndThen">AndThen</a>&lt;Self, B&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a>&lt;B&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Request = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.from_err' class='fnname'>from_err</a>&lt;E&gt;(self) -&gt; <a class="struct" href="../actix_service/struct.FromErr.html" title="struct actix_service::FromErr">FromErr</a>&lt;Self, E&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.then' class='fnname'>then</a>&lt;B&gt;(self, service: B) -&gt; <a class="struct" href="../actix_service/struct.Then.html" title="struct actix_service::Then">Then</a>&lt;Self, B&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Request = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.map' class='fnname'>map</a>&lt;F, R&gt;(self, f: F) -&gt; <a class="struct" href="../actix_service/struct.Map.html" title="struct actix_service::Map">Map</a>&lt;Self, F, R&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>) -&gt; R</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.map_err' class='fnname'>map_err</a>&lt;F, E&gt;(self, f: F) -&gt; <a class="struct" href="../actix_service/struct.MapErr.html" title="struct actix_service::MapErr">MapErr</a>&lt;Self, F, E&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>) -&gt; E</span>,
{ ... }
}</pre></div><div class='docblock'><p>An extension trait for <code>Service</code>s that provides a variety of convenient
adapters</p>
</div>
<h2 id='provided-methods' class='small-section-header'>Provided methods<a href='#provided-methods' class='anchor'></a></h2><div class='methods'><h3 id='method.apply_fn' class='method'><code id='apply_fn.v'>fn <a href='#method.apply_fn' class='fnname'>apply_fn</a>&lt;F, B, B1, Out&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;service: B1, <br>&nbsp;&nbsp;&nbsp;&nbsp;f: F<br>) -&gt; AndThenApply&lt;Self, B, F, Out&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>B) -&gt; Out,<br>&nbsp;&nbsp;&nbsp;&nbsp;Out: <a class="trait" href="../futures/future/trait.IntoFuture.html" title="trait futures::future::IntoFuture">IntoFuture</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Out::<a class="type" href="../futures/future/trait.IntoFuture.html#associatedtype.Error" title="type futures::future::IntoFuture::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>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;B1: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a>&lt;B&gt;,&nbsp;</span></code></h3><div class='docblock'><p>Apply function to specified service and use it as a next service in
chain.</p>
</div><h3 id='method.and_then' class='method'><code id='and_then.v'>fn <a href='#method.and_then' class='fnname'>and_then</a>&lt;F, B&gt;(self, service: F) -&gt; <a class="struct" href="../actix_service/struct.AndThen.html" title="struct actix_service::AndThen">AndThen</a>&lt;Self, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a>&lt;B&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Request = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,&nbsp;</span></code></h3><div class='docblock'><p>Call another service after call to this one has resolved successfully.</p>
<p>This function can be used to chain two services together and ensure that
the second service isn't called until call to the fist service have
finished. Result of the call to the first service is used as an
input parameter for the second service's call.</p>
<p>Note that this function consumes the receiving service and returns a
wrapped version of it.</p>
</div><h3 id='method.from_err' class='method'><code id='from_err.v'>fn <a href='#method.from_err' class='fnname'>from_err</a>&lt;E&gt;(self) -&gt; <a class="struct" href="../actix_service/struct.FromErr.html" title="struct actix_service::FromErr">FromErr</a>&lt;Self, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,&nbsp;</span></code></h3><div class='docblock'><p>Map this service's error to any error implementing <code>From</code> for
this service<code>s </code>Error`.</p>
<p>Note that this function consumes the receiving service and returns a
wrapped version of it.</p>
</div><h3 id='method.then' class='method'><code id='then.v'>fn <a href='#method.then' class='fnname'>then</a>&lt;B&gt;(self, service: B) -&gt; <a class="struct" href="../actix_service/struct.Then.html" title="struct actix_service::Then">Then</a>&lt;Self, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>&lt;Request = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>, Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>&gt;,&nbsp;</span></code></h3><div class='docblock'><p>Chain on a computation for when a call to the service finished,
passing the result of the call to the next service <code>B</code>.</p>
<p>Note that this function consumes the receiving service and returns a
wrapped version of it.</p>
</div><h3 id='method.map' class='method'><code id='map.v'>fn <a href='#method.map' class='fnname'>map</a>&lt;F, R&gt;(self, f: F) -&gt; <a class="struct" href="../actix_service/struct.Map.html" title="struct actix_service::Map">Map</a>&lt;Self, F, R&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a>) -&gt; R,&nbsp;</span></code></h3><div class='docblock'><p>Map this service's output to a different type, returning a new service
of the resulting type.</p>
<p>This function is similar to the <code>Option::map</code> or <code>Iterator::map</code> where
it will change the type of the underlying service.</p>
<p>Note that this function consumes the receiving service and returns a
wrapped version of it, similar to the existing <code>map</code> methods in the
standard library.</p>
</div><h3 id='method.map_err' class='method'><code id='map_err.v'>fn <a href='#method.map_err' class='fnname'>map_err</a>&lt;F, E&gt;(self, f: F) -&gt; <a class="struct" href="../actix_service/struct.MapErr.html" title="struct actix_service::MapErr">MapErr</a>&lt;Self, F, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>) -&gt; E,&nbsp;</span></code></h3><div class='docblock'><p>Map this service's error to a different error, returning a new service.</p>
<p>This function is similar to the <code>Result::map_err</code> where it will change
the error type of the underlying service. This is useful for example to
ensure that services have the same error type.</p>
<p>Note that this function consumes the receiving service and returns a
wrapped version of it.</p>
</div></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-ServiceExt' class='impl'><code class='in-band'>impl&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; ServiceExt for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>,&nbsp;</span></code><a href='#impl-ServiceExt' class='anchor'></a><a class='srclink' href='../src/actix_service/lib.rs.html#174' title='goto source code'>[src]</a></h3><div class='impl-items'></div></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../implementors/actix_service/trait.ServiceExt.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "actix_service";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>