48 lines
20 KiB
HTML
48 lines
20 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 `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">☰</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'>−</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><F, B, B1, Out>(<br> self, <br> service: B1, <br> f: F<br> ) -> AndThenApply<Self, B, F, Out><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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">&mut </a>B) -> Out,<br> Out: <a class="trait" href="../futures/future/trait.IntoFuture.html" title="trait futures::future::IntoFuture">IntoFuture</a>,<br> 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><Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>,<br> B1: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a><B></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.and_then' class='fnname'>and_then</a><F, B>(self, service: F) -> <a class="struct" href="../actix_service/struct.AndThen.html" title="struct actix_service::AndThen">AndThen</a><Self, B><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a><B>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><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>></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.from_err' class='fnname'>from_err</a><E>(self) -> <a class="struct" href="../actix_service/struct.FromErr.html" title="struct actix_service::FromErr">FromErr</a><Self, E><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.then' class='fnname'>then</a><B>(self, service: B) -> <a class="struct" href="../actix_service/struct.Then.html" title="struct actix_service::Then">Then</a><Self, B><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><Request = <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="../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>>, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.map' class='fnname'>map</a><F, R>(self, f: F) -> <a class="struct" href="../actix_service/struct.Map.html" title="struct actix_service::Map">Map</a><Self, F, R><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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>) -> R</span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.map_err' class='fnname'>map_err</a><F, E>(self, f: F) -> <a class="struct" href="../actix_service/struct.MapErr.html" title="struct actix_service::MapErr">MapErr</a><Self, F, E><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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>) -> 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><F, B, B1, Out>(<br> self, <br> service: B1, <br> f: F<br>) -> AndThenApply<Self, B, F, Out> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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">&mut </a>B) -> Out,<br> Out: <a class="trait" href="../futures/future/trait.IntoFuture.html" title="trait futures::future::IntoFuture">IntoFuture</a>,<br> 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><Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>,<br> B1: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a><B>, </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><F, B>(self, service: F) -> <a class="struct" href="../actix_service/struct.AndThen.html" title="struct actix_service::AndThen">AndThen</a><Self, B> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> F: <a class="trait" href="../actix_service/trait.IntoService.html" title="trait actix_service::IntoService">IntoService</a><B>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><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>>, </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><E>(self) -> <a class="struct" href="../actix_service/struct.FromErr.html" title="struct actix_service::FromErr">FromErr</a><Self, E> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>, </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><B>(self, service: B) -> <a class="struct" href="../actix_service/struct.Then.html" title="struct actix_service::Then">Then</a><Self, B> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> B: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><Request = <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="../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>>, Error = Self::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>>, </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><F, R>(self, f: F) -> <a class="struct" href="../actix_service/struct.Map.html" title="struct actix_service::Map">Map</a><Self, F, R> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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>) -> R, </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><F, E>(self, f: F) -> <a class="struct" href="../actix_service/struct.MapErr.html" title="struct actix_service::MapErr">MapErr</a><Self, F, E> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br> 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>) -> E, </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<T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> ServiceExt for T <span class="where fmt-newline">where<br> T: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a>, </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> |