1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 23:51:06 +01:00

Deploying to gh-pages from @ 8741cd32cc 🚀

This commit is contained in:
robjtede 2021-04-09 13:42:26 +00:00
parent c00153b487
commit 55e0870178
118 changed files with 1511 additions and 1511 deletions

View File

@ -33,14 +33,14 @@ included, and carry their own copyright notices and license terms:
Licensed under the SIL Open Font License, Version 1.1.
See SourceCodePro-LICENSE.txt.
* Source Serif Pro (SourceSerifPro-Regular.ttf.woff,
SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff):
* Source Serif 4 (SourceSerif4-Regular.ttf.woff, SourceSerif4-Bold.ttf.woff,
SourceSerif4-It.ttf.woff):
Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with
Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of
Adobe Systems Incorporated in the United States and/or other countries.
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name
'Source'. All Rights Reserved. Source is a trademark of Adobe in the United
States and/or other countries.
Licensed under the SIL Open Font License, Version 1.1.
See SourceSerifPro-LICENSE.txt.
See SourceSerif4-LICENSE.md.
This copyright file is intended to be distributed with rustdoc output.

BIN
SourceSerif4-Bold.ttf.woff Normal file

Binary file not shown.

BIN
SourceSerif4-It.ttf.woff Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
This Font Software is licensed under the SIL Open Font License, Version 1.1.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
<!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="Errors that can occur when processing CORS guarded requests."><meta name="keywords" content="rust, rustlang, rust-lang, CorsError"><title>actix_cors::CorsError - 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><script src="../crates.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc enum"><!--[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" role="button">&#9776;</div><a href='../actix_cors/index.html'><div class='logo-container'><img src='https://actix.rs/img/logo.png' alt='logo'></div></a><p class="location">Enum CorsError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.BadRequestHeaders">BadRequestHeaders</a><a href="#variant.BadRequestMethod">BadRequestMethod</a><a href="#variant.HeadersNotAllowed">HeadersNotAllowed</a><a href="#variant.MethodNotAllowed">MethodNotAllowed</a><a href="#variant.MissingOrigin">MissingOrigin</a><a href="#variant.MissingRequestMethod">MissingRequestMethod</a><a href="#variant.OriginNotAllowed">OriginNotAllowed</a><a href="#variant.WildcardOrigin">WildcardOrigin</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a><a href="#impl-ResponseError">ResponseError</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_cors</a></p><div id="sidebar-vars" data-name="CorsError" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_cors</a>::<wbr><a class="enum" href="">CorsError</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/error.rs.html#8-46" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum"><span class="docblock attributes top-attr">#[non_exhaustive]</span>pub enum CorsError {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_cors</a>::<wbr><a class="enum" href="">CorsError</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/error.rs.html#8-46" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum"><span class="docblock attributes top-attr">#[non_exhaustive]</span>pub enum CorsError {
WildcardOrigin,
MissingOrigin,
MissingRequestMethod,
@ -23,11 +23,11 @@
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, _derive_more_display_formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#99" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#127" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#139" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#149" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl ResponseError for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#48-56" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.status_code" class="method hidden"><code>fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../src/actix_cors/error.rs.html#49-51" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#6" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#106" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#134" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#146" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#156" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl ResponseError for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../src/actix_cors/error.rs.html#48-56" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.status_code" class="method hidden"><code>fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../src/actix_cors/error.rs.html#49-51" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div><h4 id="method.error_response" class="method hidden"><code>fn <a href="#method.error_response" class="fnname">error_response</a>(&amp;self) -&gt; HttpResponse</code><a class="srclink" href="../src/actix_cors/error.rs.html#53-55" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Create response for error <a href="#method.error_response">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="enum" href="../actix_cors/enum.CorsError.html" title="enum actix_cors::CorsError">CorsError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>

View File

@ -1,12 +1,12 @@
<!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="Cross-Origin Resource Sharing (CORS) controls for Actix Web."><meta name="keywords" content="rust, rustlang, rust-lang, actix_cors"><title>actix_cors - 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><script src="../crates.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[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" role="button">&#9776;</div><a href='../actix_cors/index.html'><div class='logo-container'><img src='https://actix.rs/img/logo.png' alt='logo'></div></a><p class="location">Crate actix_cors</p><div class="block version"><p>Version 0.6.0-beta.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_cors's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_cors" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_cors</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/lib.rs.html#1-60" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Cross-Origin Resource Sharing (CORS) controls for Actix Web.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_cors</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/lib.rs.html#1-60" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Cross-Origin Resource Sharing (CORS) controls for Actix Web.</p>
<p>This middleware can be applied to both applications and resources. Once built, a
<a href="../actix_cors/struct.Cors.html" title="Cors"><code>Cors</code></a> builder can be used as an argument for Actix Webs <code>App::wrap()</code>,
<code>Scope::wrap()</code>, or <code>Resource::wrap()</code> methods.</p>
<p>This CORS middleware automatically handles <code>OPTIONS</code> preflight requests.</p>
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_cors</span>::<span class="ident">Cors</span>;
<span class="kw">use</span> <span class="ident">actix_cors::Cors</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">get</span>, <span class="ident">http</span>, <span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">HttpRequest</span>, <span class="ident">HttpResponse</span>, <span class="ident">HttpServer</span>};
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/index.html&quot;</span>)]</span>
@ -14,20 +14,20 @@
<span class="string">&quot;&lt;p&gt;Hello World!&lt;/p&gt;&quot;</span>
}
<span class="attribute">#[<span class="ident">actix_web</span>::<span class="ident">main</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="ident">HttpServer</span>::<span class="ident">new</span>(<span class="op">|</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
<span class="attribute">#[<span class="ident">actix_web::main</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">std::io::Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="ident">HttpServer::new</span>(<span class="op">|</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">allowed_origin</span>(<span class="string">&quot;https://www.rust-lang.org/&quot;</span>)
.<span class="ident">allowed_origin_fn</span>(<span class="op">|</span><span class="ident">origin</span>, <span class="ident">_req_head</span><span class="op">|</span> {
<span class="ident">origin</span>.<span class="ident">as_bytes</span>().<span class="ident">ends_with</span>(<span class="string">b&quot;.rust-lang.org&quot;</span>)
})
.<span class="ident">allowed_methods</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;GET&quot;</span>, <span class="string">&quot;POST&quot;</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">http</span>::<span class="ident">header</span>::<span class="ident">AUTHORIZATION</span>, <span class="ident">http</span>::<span class="ident">header</span>::<span class="ident">ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">http</span>::<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>)
.<span class="ident">allowed_methods</span>(<span class="macro">vec!</span>[<span class="string">&quot;GET&quot;</span>, <span class="string">&quot;POST&quot;</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec!</span>[<span class="ident">http::header::AUTHORIZATION</span>, <span class="ident">http::header::ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">http::header::CONTENT_TYPE</span>)
.<span class="ident">max_age</span>(<span class="number">3600</span>);
<span class="ident">App</span>::<span class="ident">new</span>()
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">cors</span>)
.<span class="ident">service</span>(<span class="ident">index</span>)
})

View File

@ -1,5 +1,5 @@
<!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="Builder for CORS middleware."><meta name="keywords" content="rust, rustlang, rust-lang, Cors"><title>actix_cors::Cors - 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><script src="../crates.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[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" role="button">&#9776;</div><a href='../actix_cors/index.html'><div class='logo-container'><img src='https://actix.rs/img/logo.png' alt='logo'></div></a><p class="location">Struct Cors</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.allow_any_header">allow_any_header</a><a href="#method.allow_any_method">allow_any_method</a><a href="#method.allow_any_origin">allow_any_origin</a><a href="#method.allowed_header">allowed_header</a><a href="#method.allowed_headers">allowed_headers</a><a href="#method.allowed_methods">allowed_methods</a><a href="#method.allowed_origin">allowed_origin</a><a href="#method.allowed_origin_fn">allowed_origin_fn</a><a href="#method.disable_preflight">disable_preflight</a><a href="#method.disable_vary_header">disable_vary_header</a><a href="#method.expose_any_header">expose_any_header</a><a href="#method.expose_headers">expose_headers</a><a href="#method.max_age">max_age</a><a href="#method.permissive">permissive</a><a href="#method.send_wildcard">send_wildcard</a><a href="#method.supports_credentials">supports_credentials</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E">Transform&lt;S, ServiceRequest&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_cors</a></p><div id="sidebar-vars" data-name="Cors" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_cors</a>::<wbr><a class="struct" href="">Cors</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/builder.rs.html#72-75" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Cors { /* fields omitted */ }</pre></div><div class="docblock"><p>Builder for CORS middleware.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_cors</a>::<wbr><a class="struct" href="">Cors</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_cors/builder.rs.html#72-75" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Cors { /* fields omitted */ }</pre></div><div class="docblock"><p>Builder for CORS middleware.</p>
<p>To construct a CORS middleware, call <a href="../actix_cors/struct.Cors.html#method.default" title="Cors::default()"><code>Cors::default()</code></a> to create a blank, restrictive builder.
Then use any of the builder methods to customize CORS behavior.</p>
<p>The alternative <a href="../actix_cors/struct.Cors.html#method.permissive" title="Cors::permissive()"><code>Cors::permissive()</code></a> constructor is available for local development, allowing
@ -11,14 +11,14 @@ messages will outline what is wrong with the CORS configuration in the server lo
server will fail to start up or serve requests.</p>
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_cors</span>::<span class="ident">Cors</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>;
<span class="kw">use</span> <span class="ident">actix_cors::Cors</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>;
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">allowed_origin</span>(<span class="string">&quot;https://www.rust-lang.org&quot;</span>)
.<span class="ident">allowed_methods</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;GET&quot;</span>, <span class="string">&quot;POST&quot;</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">header</span>::<span class="ident">AUTHORIZATION</span>, <span class="ident">header</span>::<span class="ident">ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>)
.<span class="ident">allowed_methods</span>(<span class="macro">vec!</span>[<span class="string">&quot;GET&quot;</span>, <span class="string">&quot;POST&quot;</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec!</span>[<span class="ident">header::AUTHORIZATION</span>, <span class="ident">header::ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">header::CONTENT_TYPE</span>)
.<span class="ident">max_age</span>(<span class="number">3600</span>);
<span class="comment">// `cors` can now be used in `App::wrap`.</span></pre></div>
@ -45,7 +45,7 @@ allowed origins.</p>
<li>If supplied origin is not valid uri</li>
<li>If supplied origin is a wildcard (<code>*</code>). <a href="../actix_cors/struct.Cors.html#method.send_wildcard" title="Cors::send_wildcard"><code>Cors::send_wildcard</code></a> should be used instead.</li>
</ul>
</div><h4 id="method.allowed_origin_fn" class="method"><code>pub fn <a href="#method.allowed_origin_fn" class="fnname">allowed_origin_fn</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<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>(&amp;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>, &amp;RequestHead) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> + 'static,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#181-192" title="goto source code">[src]</a></h4><div class="docblock"><p>Determinate allowed origins by processing requests which didnt match any origins specified
</div><h4 id="method.allowed_origin_fn" class="method"><code>pub fn <a href="#method.allowed_origin_fn" class="fnname">allowed_origin_fn</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<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>(&amp;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>, &amp;RequestHead) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> + 'static,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#181-192" title="goto source code">[src]</a></h4><div class="docblock"><p>Determinate allowed origins by processing requests which didnt match any origins specified
in the <code>allowed_origin</code>.</p>
<p>The function will receive two parameters, the Origin header value, and the <code>RequestHead</code> of
each request, which can be used to determine whether to allow the request or not.</p>
@ -53,15 +53,15 @@ each request, which can be used to determine whether to allow the request or not
into the <code>Access-Control-Allow-Origin</code> response header.</p>
</div><h4 id="method.allow_any_method" class="method"><code>pub fn <a href="#method.allow_any_method" class="fnname">allow_any_method</a>(self) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a></code><a class="srclink" href="../src/actix_cors/builder.rs.html#197-203" title="goto source code">[src]</a></h4><div class="docblock"><p>Resets allowed methods list to all methods.</p>
<p>See <a href="../actix_cors/struct.Cors.html#method.allowed_methods" title="Cors::allowed_methods"><code>Cors::allowed_methods</code></a> for more info on allowed methods.</p>
</div><h4 id="method.allowed_methods" class="method"><code>pub fn <a href="#method.allowed_methods" class="fnname">allowed_methods</a>&lt;U, M&gt;(self, methods: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = M&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;M: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/method/struct.Method.html" title="struct http::method::Method">Method</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;M as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/method/struct.Method.html" title="struct http::method::Method">Method</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.3/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#213-235" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of methods which allowed origins can perform.</p>
</div><h4 id="method.allowed_methods" class="method"><code>pub fn <a href="#method.allowed_methods" class="fnname">allowed_methods</a>&lt;U, M&gt;(self, methods: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = M&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;M: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/method/struct.Method.html" title="struct http::method::Method">Method</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;M as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/method/struct.Method.html" title="struct http::method::Method">Method</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.4/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#213-235" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of methods which allowed origins can perform.</p>
<p>These will be sent in the <code>Access-Control-Allow-Methods</code> response header as specified in
the <a href="https://fetch.spec.whatwg.org/#http-cors-protocol">Fetch Standard CORS protocol</a>.</p>
<p>Defaults to <code>[GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]</code></p>
</div><h4 id="method.allow_any_header" class="method"><code>pub fn <a href="#method.allow_any_header" class="fnname">allow_any_header</a>(self) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a></code><a class="srclink" href="../src/actix_cors/builder.rs.html#240-246" title="goto source code">[src]</a></h4><div class="docblock"><p>Resets allowed request header list to a state where any header is accepted.</p>
<p>See <a href="../actix_cors/struct.Cors.html#method.allowed_headers" title="Cors::allowed_headers"><code>Cors::allowed_headers</code></a> for more info on allowed request headers.</p>
</div><h4 id="method.allowed_header" class="method"><code>pub fn <a href="#method.allowed_header" class="fnname">allowed_header</a>&lt;H&gt;(self, header: H) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.3/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#251-274" title="goto source code">[src]</a></h4><div class="docblock"><p>Add an allowed request header.</p>
</div><h4 id="method.allowed_header" class="method"><code>pub fn <a href="#method.allowed_header" class="fnname">allowed_header</a>&lt;H&gt;(self, header: H) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.4/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#251-274" title="goto source code">[src]</a></h4><div class="docblock"><p>Add an allowed request header.</p>
<p>See <a href="../actix_cors/struct.Cors.html#method.allowed_headers" title="Cors::allowed_headers"><code>Cors::allowed_headers</code></a> for more info on allowed request headers.</p>
</div><h4 id="method.allowed_headers" class="method"><code>pub fn <a href="#method.allowed_headers" class="fnname">allowed_headers</a>&lt;U, H&gt;(self, headers: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = H&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.3/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#286-314" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of request header field names which can be used when this resource is accessed by
</div><h4 id="method.allowed_headers" class="method"><code>pub fn <a href="#method.allowed_headers" class="fnname">allowed_headers</a>&lt;U, H&gt;(self, headers: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = H&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.4/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#286-314" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of request header field names which can be used when this resource is accessed by
allowed origins.</p>
<p>If <code>All</code> is set, whatever is requested by the client in <code>Access-Control-Request-Headers</code>
will be echoed back in the <code>Access-Control-Allow-Headers</code> header as specified in
@ -69,7 +69,7 @@ the <a href="https://fetch.spec.whatwg.org/#http-cors-protocol">Fetch Standard C
<p>Defaults to <code>All</code>.</p>
</div><h4 id="method.expose_any_header" class="method"><code>pub fn <a href="#method.expose_any_header" class="fnname">expose_any_header</a>(self) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a></code><a class="srclink" href="../src/actix_cors/builder.rs.html#319-325" title="goto source code">[src]</a></h4><div class="docblock"><p>Resets exposed response header list to a state where any header is accepted.</p>
<p>See <a href="../actix_cors/struct.Cors.html#method.expose_headers" title="Cors::expose_headers"><code>Cors::expose_headers</code></a> for more info on exposed response headers.</p>
</div><h4 id="method.expose_headers" class="method"><code>pub fn <a href="#method.expose_headers" class="fnname">expose_headers</a>&lt;U, H&gt;(self, headers: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = H&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.3/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#334-361" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of headers which are safe to expose to the API of a CORS API specification.
</div><h4 id="method.expose_headers" class="method"><code>pub fn <a href="#method.expose_headers" class="fnname">expose_headers</a>&lt;U, H&gt;(self, headers: U) -&gt; <a class="struct" href="../actix_cors/struct.Cors.html" title="struct actix_cors::Cors">Cors</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = H&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;H as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/name/struct.HeaderName.html" title="struct http::header::name::HeaderName">HeaderName</a>&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" title="type core::convert::TryInto::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;<a class="struct" href="https://docs.rs/http/0.2.4/http/error/struct.Error.html" title="struct http::error::Error">HttpError</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/actix_cors/builder.rs.html#334-361" title="goto source code">[src]</a></h4><div class="docblock"><p>Set a list of headers which are safe to expose to the API of a CORS API specification.
This corresponds to the <code>Access-Control-Expose-Headers</code> response header as specified in
the <a href="https://fetch.spec.whatwg.org/#http-cors-protocol">Fetch Standard CORS protocol</a>.</p>
<p>This defaults to an empty set.</p>

View File

@ -1,7 +1,7 @@
<!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="Opinionated request identity service for Actix Web apps."><meta name="keywords" content="rust, rustlang, rust-lang, actix_identity"><title>actix_identity - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate actix_identity</p><div class="block version"><p>Version 0.4.0-beta.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_identity's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_identity" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_identity</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#1-152" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Opinionated request identity service for Actix Web apps.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_identity</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#1-152" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Opinionated request identity service for Actix Web apps.</p>
<p><a href="../actix_identity/struct.IdentityService.html" title="IdentityService"><code>IdentityService</code></a> middleware can be used with different policies types to store
identity information.</p>
<p>A cookie based policy is provided. <a href="../actix_identity/struct.CookieIdentityPolicy.html" title="CookieIdentityPolicy"><code>CookieIdentityPolicy</code></a> uses cookies as identity storage.</p>
@ -15,7 +15,7 @@ identity information.</p>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span> {
<span class="comment">// access request identity</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">id</span>) <span class="op">=</span> <span class="ident">id</span>.<span class="ident">identity</span>() {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
<span class="macro">format!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
} <span class="kw">else</span> {
<span class="string">&quot;Welcome Anonymous!&quot;</span>.<span class="ident">to_owned</span>()
}
@ -24,24 +24,24 @@ identity information.</p>
<span class="attribute">#[<span class="ident">post</span>(<span class="string">&quot;/login&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">login</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">&quot;User1&quot;</span>.<span class="ident">to_owned</span>()); <span class="comment">// &lt;- remember identity</span>
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
}
<span class="attribute">#[<span class="ident">post</span>(<span class="string">&quot;/logout&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">logout</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="ident">id</span>.<span class="ident">forget</span>(); <span class="comment">// &lt;- remove identity</span>
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>()
<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>()
}
<span class="comment">// create cookie identity backend</span>
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">name</span>(<span class="string">&quot;auth-cookie&quot;</span>)
.<span class="ident">secure</span>(<span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
<span class="comment">// wrap policy into middleware identity middleware</span>
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(<span class="ident">policy</span>))
.<span class="ident">service</span>(<span class="macro">services</span><span class="macro">!</span>[<span class="ident">index</span>, <span class="ident">login</span>, <span class="ident">logout</span>]);</pre></div>
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">policy</span>))
.<span class="ident">service</span>(<span class="macro">services!</span>[<span class="ident">index</span>, <span class="ident">login</span>, <span class="ident">logout</span>]);</pre></div>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.CookieIdentityPolicy.html" title="actix_identity::CookieIdentityPolicy struct">CookieIdentityPolicy</a></td><td class="docblock-short"><p>Use cookies for request identity storage.</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Identity.html" title="actix_identity::Identity struct">Identity</a></td><td class="docblock-short"><p>The extractor type to obtain your identity from a request.</p>

View File

@ -1,23 +1,23 @@
<!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="Use cookies for request identity storage."><meta name="keywords" content="rust, rustlang, rust-lang, CookieIdentityPolicy"><title>actix_identity::CookieIdentityPolicy - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct CookieIdentityPolicy</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.domain">domain</a><a href="#method.http_only">http_only</a><a href="#method.login_deadline">login_deadline</a><a href="#method.max_age">max_age</a><a href="#method.max_age_secs">max_age_secs</a><a href="#method.name">name</a><a href="#method.new">new</a><a href="#method.path">path</a><a href="#method.same_site">same_site</a><a href="#method.secure">secure</a><a href="#method.visit_deadline">visit_deadline</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-IdentityPolicy">IdentityPolicy</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_identity</a></p><div id="sidebar-vars" data-name="CookieIdentityPolicy" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">CookieIdentityPolicy</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/cookie.rs.html#205" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct CookieIdentityPolicy(_);</pre></div><div class="docblock"><p>Use cookies for request identity storage.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">CookieIdentityPolicy</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/cookie.rs.html#205" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct CookieIdentityPolicy(_);</pre></div><div class="docblock"><p>Use cookies for request identity storage.</p>
<p><a href="mdn-cookies">See this page on MDN</a> for details on cookie attributes.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">App</span>;
<span class="kw">use</span> <span class="ident">actix_web::App</span>;
<span class="kw">use</span> <span class="ident">actix_identity</span>::{<span class="ident">CookieIdentityPolicy</span>, <span class="ident">IdentityService</span>};
<span class="comment">// create cookie identity backend</span>
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="string">&quot;actix_auth&quot;</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">secure</span>(<span class="bool-val">true</span>);
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
<span class="comment">// wrap policy into identity middleware</span>
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(<span class="ident">policy</span>));</pre></div>
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">policy</span>));</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_identity/struct.CookieIdentityPolicy.html" title="struct actix_identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_identity/cookie.rs.html#207-298" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="struct" href="../actix_identity/struct.CookieIdentityPolicy.html" title="struct actix_identity::CookieIdentityPolicy">CookieIdentityPolicy</a></code><a class="srclink" href="../src/actix_identity/cookie.rs.html#215-217" title="goto source code">[src]</a></h4><div class="docblock"><p>Create new <code>CookieIdentityPolicy</code> instance.</p>
<p>Key argument is the private key for issued cookies. If this value is changed, all issued
cookie identities are invalidated.</p>

View File

@ -1,17 +1,17 @@
<!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="The extractor type to obtain your identity from a request."><meta name="keywords" content="rust, rustlang, rust-lang, Identity"><title>actix_identity::Identity - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct Identity</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.forget">forget</a><a href="#method.identity">identity</a><a href="#method.remember">remember</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-FromRequest">FromRequest</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_identity</a></p><div id="sidebar-vars" data-name="Identity" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">Identity</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/identity.rs.html#45" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Identity(_);</pre></div><div class="docblock"><p>The extractor type to obtain your identity from a request.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">Identity</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/identity.rs.html#45" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Identity(_);</pre></div><div class="docblock"><p>The extractor type to obtain your identity from a request.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_identity</span>::<span class="ident">Identity</span>;
<span class="kw">use</span> <span class="ident">actix_identity::Identity</span>;
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">Responder</span> {
<span class="comment">// access request identity</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">id</span>) <span class="op">=</span> <span class="ident">id</span>.<span class="ident">identity</span>() {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
<span class="macro">format!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
} <span class="kw">else</span> {
<span class="string">&quot;Welcome Anonymous!&quot;</span>.<span class="ident">to_owned</span>()
}
@ -22,7 +22,7 @@
<span class="comment">// remember identity</span>
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">&quot;User1&quot;</span>.<span class="ident">to_owned</span>());
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
}
<span class="attribute">#[<span class="ident">post</span>(<span class="string">&quot;/logout&quot;</span>)]</span>
@ -30,7 +30,7 @@
<span class="comment">// remove identity</span>
<span class="ident">id</span>.<span class="ident">forget</span>();
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
}</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_identity/struct.Identity.html" title="struct actix_identity::Identity">Identity</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_identity/identity.rs.html#47-74" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.identity" class="method"><code>pub fn <a href="#method.identity" class="fnname">identity</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</code><a class="srclink" href="../src/actix_identity/identity.rs.html#50-52" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the claimed identity of the user associated request or <code>None</code> if no identity can be
found associated with the request.</p>
@ -41,13 +41,13 @@ found associated with the request.</p>
</div></div><h3 id="impl-FromRequest" class="impl"><code class="in-band">impl FromRequest for <a class="struct" href="../actix_identity/struct.Identity.html" title="struct actix_identity::Identity">Identity</a></code><a href="#impl-FromRequest" class="anchor"></a><a class="srclink" href="../src/actix_identity/identity.rs.html#92-101" title="goto source code">[src]</a></h3><div class="docblock"><p>Extractor implementation for Identity type.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_identity</span>::<span class="ident">Identity</span>;
<span class="kw">use</span> <span class="ident">actix_identity::Identity</span>;
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">Responder</span> {
<span class="comment">// access request identity</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">id</span>) <span class="op">=</span> <span class="ident">id</span>.<span class="ident">identity</span>() {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
<span class="macro">format!</span>(<span class="string">&quot;Welcome! {}&quot;</span>, <span class="ident">id</span>)
} <span class="kw">else</span> {
<span class="string">&quot;Welcome Anonymous!&quot;</span>.<span class="ident">to_owned</span>()
}

View File

@ -1,20 +1,20 @@
<!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="Request identity middleware"><meta name="keywords" content="rust, rustlang, rust-lang, IdentityService"><title>actix_identity::IdentityService - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct IdentityService</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.new">new</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E">Transform&lt;S, ServiceRequest&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_identity</a></p><div id="sidebar-vars" data-name="IdentityService" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">IdentityService</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/middleware.rs.html#26-28" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct IdentityService&lt;T&gt; { /* fields omitted */ }</pre></div><div class="docblock"><p>Request identity middleware</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_identity</a>::<wbr><a class="struct" href="">IdentityService</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/middleware.rs.html#26-28" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct IdentityService&lt;T&gt; { /* fields omitted */ }</pre></div><div class="docblock"><p>Request identity middleware</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">App</span>;
<span class="kw">use</span> <span class="ident">actix_web::App</span>;
<span class="kw">use</span> <span class="ident">actix_identity</span>::{<span class="ident">CookieIdentityPolicy</span>, <span class="ident">IdentityService</span>};
<span class="comment">// create cookie identity backend</span>
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="kw">let</span> <span class="ident">policy</span> <span class="op">=</span> <span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">name</span>(<span class="string">&quot;auth-cookie&quot;</span>)
.<span class="ident">secure</span>(<span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
<span class="comment">// wrap policy into identity middleware</span>
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(<span class="ident">policy</span>));</pre></div>
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">policy</span>));</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl&lt;T&gt; <a class="struct" href="../actix_identity/struct.IdentityService.html" title="struct actix_identity::IdentityService">IdentityService</a>&lt;T&gt;</code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_identity/middleware.rs.html#30-37" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(backend: T) -&gt; Self</code><a class="srclink" href="../src/actix_identity/middleware.rs.html#32-36" title="goto source code">[src]</a></h4><div class="docblock"><p>Create new identity service with specified backend.</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Transform%3CS%2C%20ServiceRequest%3E" class="impl"><code class="in-band">impl&lt;S, T, B&gt; Transform&lt;S, ServiceRequest&gt; for <a class="struct" href="../actix_identity/struct.IdentityService.html" title="struct actix_identity::IdentityService">IdentityService</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::Future: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../actix_identity/trait.IdentityPolicy.html" title="trait actix_identity::IdentityPolicy">IdentityPolicy</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: 'static,&nbsp;</span></code><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E" class="anchor"></a><a class="srclink" href="../src/actix_identity/middleware.rs.html#39-58" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Response" class="type"><code>type <a href="#associatedtype.Response" class="type">Response</a> = ServiceResponse&lt;B&gt;</code></h4><div class='docblock'><p>Responses produced by the service.</p>
</div><h4 id="associatedtype.Error" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = Error</code></h4><div class='docblock'><p>Errors produced by the service.</p>

View File

@ -1,7 +1,7 @@
<!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="Identity policy."><meta name="keywords" content="rust, rustlang, rust-lang, IdentityPolicy"><title>actix_identity::IdentityPolicy - 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><script src="../crates.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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait IdentityPolicy</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.Future">Future</a><a href="#associatedtype.ResponseFuture">ResponseFuture</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.from_request">from_request</a><a href="#tymethod.to_response">to_response</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">actix_identity</a></p><div id="sidebar-vars" data-name="IdentityPolicy" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_identity</a>::<wbr><a class="trait" href="">IdentityPolicy</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#65-82" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait IdentityPolicy: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'static {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="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">actix_identity</a>::<wbr><a class="trait" href="">IdentityPolicy</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#65-82" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait IdentityPolicy: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'static {
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>&lt;Output = Result&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;, Error&gt;&gt;;
type <a href="#associatedtype.ResponseFuture" class="type">ResponseFuture</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>&lt;Output = Result&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error&gt;&gt;;
fn <a href="#tymethod.from_request" class="fnname">from_request</a>(&amp;self, req: &amp;mut ServiceRequest) -&gt; Self::<a class="type" href="../actix_identity/trait.IdentityPolicy.html#associatedtype.Future" title="type actix_identity::IdentityPolicy::Future">Future</a>;

View File

@ -1,7 +1,7 @@
<!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="Helper trait that allows to get Identity."><meta name="keywords" content="rust, rustlang, rust-lang, RequestIdentity"><title>actix_identity::RequestIdentity - 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><script src="../crates.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" role="button">&#9776;</div><a href='../actix_identity/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait RequestIdentity</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.get_identity">get_identity</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">actix_identity</a></p><div id="sidebar-vars" data-name="RequestIdentity" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_identity</a>::<wbr><a class="trait" href="">RequestIdentity</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#88-90" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait RequestIdentity {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="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">actix_identity</a>::<wbr><a class="trait" href="">RequestIdentity</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_identity/lib.rs.html#88-90" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait RequestIdentity {
fn <a href="#tymethod.get_identity" class="fnname">get_identity</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;;
}</pre></div><div class="docblock"><p>Helper trait that allows to get Identity.</p>
<p>It could be used in middleware but identity policy must be set before any other middleware that

View File

@ -1,7 +1,7 @@
<!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 `ProtoBufPayloadError` enum in crate `actix_protobuf`."><meta name="keywords" content="rust, rustlang, rust-lang, ProtoBufPayloadError"><title>actix_protobuf::ProtoBufPayloadError - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum ProtoBufPayloadError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.ContentType">ContentType</a><a href="#variant.Deserialize">Deserialize</a><a href="#variant.Overflow">Overflow</a><a href="#variant.Payload">Payload</a><a href="#variant.Serialize">Serialize</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-From%3CDecodeError%3E">From&lt;DecodeError&gt;</a><a href="#impl-From%3CPayloadError%3E">From&lt;PayloadError&gt;</a><a href="#impl-ResponseError">ResponseError</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_protobuf</a></p><div id="sidebar-vars" data-name="ProtoBufPayloadError" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_protobuf</a>::<wbr><a class="enum" href="">ProtoBufPayloadError</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#24-40" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum ProtoBufPayloadError {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_protobuf</a>::<wbr><a class="enum" href="">ProtoBufPayloadError</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#24-40" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum ProtoBufPayloadError {
Overflow,
ContentType,
Serialize(<a class="struct" href="https://docs.rs/prost/0.7.0/prost/error/struct.EncodeError.html" title="struct prost::error::EncodeError">ProtoBufEncodeError</a>),
@ -19,7 +19,7 @@
</div></div><h3 id="impl-From%3CDecodeError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://docs.rs/prost/0.7.0/prost/error/struct.DecodeError.html" title="struct prost::error::DecodeError">DecodeError</a>&gt; for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-From%3CDecodeError%3E" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#57-61" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: <a class="struct" href="https://docs.rs/prost/0.7.0/prost/error/struct.DecodeError.html" title="struct prost::error::DecodeError">ProtoBufDecodeError</a>) -&gt; <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#58-60" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CPayloadError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;PayloadError&gt; for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-From%3CPayloadError%3E" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#51-55" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: PayloadError) -&gt; <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#52-54" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl ResponseError for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#42-49" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.error_response" class="method hidden"><code>fn <a href="#method.error_response" class="fnname">error_response</a>(&amp;self) -&gt; HttpResponse</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#43-48" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Create response for error <a href="#method.error_response">Read more</a></p>
</div><h4 id="method.status_code" class="method hidden"><code>pub fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div><h4 id="method.status_code" class="method hidden"><code>pub fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216-220" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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 `actix_protobuf` crate."><meta name="keywords" content="rust, rustlang, rust-lang, actix_protobuf"><title>actix_protobuf - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate actix_protobuf</p><div class="block version"><p>Version 0.6.0</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_protobuf's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_protobuf" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_protobuf</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#1-324" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_protobuf</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#1-324" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.ProtoBuf.html" title="actix_protobuf::ProtoBuf struct">ProtoBuf</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="struct" href="struct.ProtoBufConfig.html" title="actix_protobuf::ProtoBufConfig struct">ProtoBufConfig</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="struct" href="struct.ProtoBufMessage.html" title="actix_protobuf::ProtoBufMessage struct">ProtoBufMessage</a></td><td class="docblock-short"></td></tr></table><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
<table><tr class="module-item"><td><a class="enum" href="enum.ProtoBufPayloadError.html" title="actix_protobuf::ProtoBufPayloadError enum">ProtoBufPayloadError</a></td><td class="docblock-short"></td></tr></table><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2>
<table><tr class="module-item"><td><a class="trait" href="trait.ProtoBufResponseBuilder.html" title="actix_protobuf::ProtoBufResponseBuilder trait">ProtoBufResponseBuilder</a></td><td class="docblock-short"></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="actix_protobuf" data-search-js="../search-index.js"></div>

View File

@ -1,7 +1,7 @@
<!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 `ProtoBuf` struct in crate `actix_protobuf`."><meta name="keywords" content="rust, rustlang, rust-lang, ProtoBuf"><title>actix_protobuf::ProtoBuf - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct ProtoBuf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a><a href="#impl-DerefMut">DerefMut</a><a href="#impl-Display">Display</a><a href="#impl-FromRequest">FromRequest</a><a href="#impl-Responder">Responder</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_protobuf</a></p><div id="sidebar-vars" data-name="ProtoBuf" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBuf</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#63" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBuf&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt;(pub T);</pre></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,&nbsp;</span></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#79-86" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#83-85" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBuf</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#63" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBuf&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt;(pub T);</pre></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,&nbsp;</span></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#79-86" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#83-85" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Deref" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt;</code><a href="#impl-Deref" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#65-71" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Target" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" class="type">Target</a> = T</code></h4><div class='docblock'><p>The resulting type after dereferencing.</p>
</div><h4 id="method.deref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref" class="fnname">deref</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#68-70" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p>
</div></div><h3 id="impl-DerefMut" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html" title="trait core::ops::deref::DerefMut">DerefMut</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt;</code><a href="#impl-DerefMut" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#73-77" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.deref_mut" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html#tymethod.deref_mut" class="fnname">deref_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#74-76" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably dereferences the value.</p>
@ -13,7 +13,7 @@
</div><h4 id="method.extract" class="method hidden"><code>pub fn <a href="#method.extract" class="fnname">extract</a>(req: &amp;HttpRequest) -&gt; Self::Future</code></h4><div class='docblock hidden'><p>Create a Self from request head asynchronously. <a href="#method.extract">Read more</a></p>
</div><h4 id="method.configure" class="method hidden"><code>pub fn <a href="#method.configure" class="fnname">configure</a>&lt;F&gt;(f: F) -&gt; Self::Config <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::Config) -&gt; Self::Config,&nbsp;</span></code></h4><div class='docblock hidden'><p>Create and configure config instance.</p>
</div></div><h3 id="impl-Responder" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt; Responder for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt;</code><a href="#impl-Responder" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#139-151" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.respond_to" class="method hidden"><code>fn <a href="#method.respond_to" class="fnname">respond_to</a>(self, _: &amp;HttpRequest) -&gt; HttpResponse</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#140-150" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert self to <code>HttpResponse</code>.</p>
</div><h4 id="method.with_status" class="method hidden"><code>pub fn <a href="#method.with_status" class="fnname">with_status</a>(self, status: <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a>) -&gt; CustomResponder&lt;Self&gt;</code></h4><div class='docblock hidden'><p>Override a status code for a Responder. <a href="#method.with_status">Read more</a></p>
</div><h4 id="method.with_status" class="method hidden"><code>pub fn <a href="#method.with_status" class="fnname">with_status</a>(self, status: <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a>) -&gt; CustomResponder&lt;Self&gt;</code></h4><div class='docblock hidden'><p>Override a status code for a Responder. <a href="#method.with_status">Read more</a></p>
</div><h4 id="method.with_header" class="method hidden"><code>pub fn <a href="#method.with_header" class="fnname">with_header</a>&lt;H&gt;(self, header: H) -&gt; CustomResponder&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: IntoHeaderPair,&nbsp;</span></code></h4><div class='docblock hidden'><p>Insert header to the final response. <a href="#method.with_header">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a>,&nbsp;</span></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt;</code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt;</code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,&nbsp;</span></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>,&nbsp;</span></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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 `ProtoBufConfig` struct in crate `actix_protobuf`."><meta name="keywords" content="rust, rustlang, rust-lang, ProtoBufConfig"><title>actix_protobuf::ProtoBufConfig - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct ProtoBufConfig</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.limit">limit</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_protobuf</a></p><div id="sidebar-vars" data-name="ProtoBufConfig" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBufConfig</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#97-99" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBufConfig { /* fields omitted */ }</pre></div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#101-107" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.limit" class="method"><code>pub fn <a href="#method.limit" class="fnname">limit</a>(&amp;mut self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#103-106" title="goto source code">[src]</a></h4><div class="docblock"><p>Change max size of payload. By default max size is 256Kb</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBufConfig</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#97-99" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBufConfig { /* fields omitted */ }</pre></div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#101-107" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.limit" class="method"><code>pub fn <a href="#method.limit" class="fnname">limit</a>(&amp;mut self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#103-106" title="goto source code">[src]</a></h4><div class="docblock"><p>Change max size of payload. By default max size is 256Kb</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Default" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-Default" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#109-113" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.default" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default" class="fnname">default</a>() -&gt; Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#110-112" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufConfig.html" title="struct actix_protobuf::ProtoBufConfig">ProtoBufConfig</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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 `ProtoBufMessage` struct in crate `actix_protobuf`."><meta name="keywords" content="rust, rustlang, rust-lang, ProtoBufMessage"><title>actix_protobuf::ProtoBufMessage - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct ProtoBufMessage</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.limit">limit</a><a href="#method.new">new</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Future">Future</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-FutureExt">FutureExt</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-IntoFuture">IntoFuture</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryFuture">TryFuture</a><a href="#impl-TryFutureExt">TryFutureExt</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_protobuf</a></p><div id="sidebar-vars" data-name="ProtoBufMessage" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBufMessage</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#153-159" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBufMessage&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt; { /* fields omitted */ }</pre></div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt; <a class="struct" href="../actix_protobuf/struct.ProtoBufMessage.html" title="struct actix_protobuf::ProtoBufMessage">ProtoBufMessage</a>&lt;T&gt;</code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#161-197" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(req: &amp;HttpRequest, payload: &amp;mut Payload) -&gt; Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#163-190" title="goto source code">[src]</a></h4><div class="docblock"><p>Create <code>ProtoBufMessage</code> for request.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_protobuf</a>::<wbr><a class="struct" href="">ProtoBufMessage</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#153-159" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ProtoBufMessage&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt; { /* fields omitted */ }</pre></div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>&gt; <a class="struct" href="../actix_protobuf/struct.ProtoBufMessage.html" title="struct actix_protobuf::ProtoBufMessage">ProtoBufMessage</a>&lt;T&gt;</code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#161-197" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(req: &amp;HttpRequest, payload: &amp;mut Payload) -&gt; Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#163-190" title="goto source code">[src]</a></h4><div class="docblock"><p>Create <code>ProtoBufMessage</code> for request.</p>
</div><h4 id="method.limit" class="method"><code>pub fn <a href="#method.limit" class="fnname">limit</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#193-196" title="goto source code">[src]</a></h4><div class="docblock"><p>Change max size of payload. By default max size is 256Kb</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Future" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + 'static&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../actix_protobuf/struct.ProtoBufMessage.html" title="struct actix_protobuf::ProtoBufMessage">ProtoBufMessage</a>&lt;T&gt;</code><a href="#impl-Future" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#199-245" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, <a class="enum" href="../actix_protobuf/enum.ProtoBufPayloadError.html" title="enum actix_protobuf::ProtoBufPayloadError">ProtoBufPayloadError</a>&gt;</code></h4><div class='docblock'><p>The type of value produced on completion.</p>
</div><h4 id="method.poll" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#tymethod.poll" class="fnname">poll</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, task: &amp;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>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#202-244" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to resolve the future to a final value, registering

View File

@ -1,7 +1,7 @@
<!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 `ProtoBufResponseBuilder` trait in crate `actix_protobuf`."><meta name="keywords" content="rust, rustlang, rust-lang, ProtoBufResponseBuilder"><title>actix_protobuf::ProtoBufResponseBuilder - 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><script src="../crates.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" role="button">&#9776;</div><a href='../actix_protobuf/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait ProtoBufResponseBuilder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.protobuf">protobuf</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-ProtoBufResponseBuilder-for-HttpResponseBuilder">HttpResponseBuilder</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">actix_protobuf</a></p><div id="sidebar-vars" data-name="ProtoBufResponseBuilder" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_protobuf</a>::<wbr><a class="trait" href="">ProtoBufResponseBuilder</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#247-249" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait ProtoBufResponseBuilder {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="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">actix_protobuf</a>::<wbr><a class="trait" href="">ProtoBufResponseBuilder</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_protobuf/lib.rs.html#247-249" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait ProtoBufResponseBuilder {
fn <a href="#tymethod.protobuf" class="fnname">protobuf</a>&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt;(&amp;mut self, value: T) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;HttpResponse, Error&gt;;
}</pre></div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.protobuf" class="method"><code>fn <a href="#tymethod.protobuf" class="fnname">protobuf</a>&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt;(&amp;mut self, value: T) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;HttpResponse, Error&gt;</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#248" title="goto source code">[src]</a></h3></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-ProtoBufResponseBuilder-for-HttpResponseBuilder" class="impl"><code class="in-band">impl <a class="trait" href="../actix_protobuf/trait.ProtoBufResponseBuilder.html" title="trait actix_protobuf::ProtoBufResponseBuilder">ProtoBufResponseBuilder</a> for HttpResponseBuilder</code><a href="#impl-ProtoBufResponseBuilder-for-HttpResponseBuilder" class="anchor"></a><a class="srclink" href="../src/actix_protobuf/lib.rs.html#251-261" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.protobuf" class="method hidden"><code>fn <a href="#method.protobuf" class="fnname">protobuf</a>&lt;T:&nbsp;<a class="trait" href="https://docs.rs/prost/0.7.0/prost/message/trait.Message.html" title="trait prost::message::Message">Message</a>&gt;(&amp;mut self, value: T) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;HttpResponse, Error&gt;</code><a class="srclink" href="../src/actix_protobuf/lib.rs.html#252-260" 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"></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../implementors/actix_protobuf/trait.ProtoBufResponseBuilder.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="actix_protobuf" data-search-js="../search-index.js"></div>
<script src="../main.js"></script></body></html>

View File

@ -1,7 +1,7 @@
<!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="General purpose actix redis error"><meta name="keywords" content="rust, rustlang, rust-lang, Error"><title>actix_redis::Error - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum Error</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Disconnected">Disconnected</a><a href="#variant.NotConnected">NotConnected</a><a href="#variant.Redis">Redis</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a><a href="#impl-From%3CError%3E">From&lt;Error&gt;</a><a href="#impl-ResponseError">ResponseError</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="Error" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">Error</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/lib.rs.html#19-28" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum Error {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">Error</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/lib.rs.html#19-28" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum Error {
Redis(<a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>),
NotConnected,
Disconnected,
@ -13,11 +13,11 @@
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, _derive_more_display_formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#127" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#139" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#149" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#134" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#146" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#156" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-From%3CError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>&gt; for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-From%3CError%3E" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(original: <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>) -&gt; <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl ResponseError for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#31" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.status_code" class="method hidden"><code>pub fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl ResponseError for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#31" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.status_code" class="method hidden"><code>pub fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div><h4 id="method.error_response" class="method hidden"><code>pub fn <a href="#method.error_response" class="fnname">error_response</a>(&amp;self) -&gt; Response&lt;Body&gt;</code></h4><div class='docblock hidden'><p>Create response for error <a href="#method.error_response">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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 `RespError` enum in crate `actix_redis`."><meta name="keywords" content="rust, rustlang, rust-lang, RespError"><title>actix_redis::RespError - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum RespError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Connection">Connection</a><a href="#variant.IO">IO</a><a href="#variant.Internal">Internal</a><a href="#variant.RESP">RESP</a><a href="#variant.Remote">Remote</a><a href="#variant.Unexpected">Unexpected</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a><a href="#impl-From%3CError%3E">From&lt;Error&gt;</a><a href="#impl-From%3CTrySendError%3CT%3E%3E">From&lt;TrySendError&lt;T&gt;&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="RespError" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">RespError</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">&#x2212;</span>]</a></span></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum RespError {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">RespError</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum RespError {
Internal(<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>),
IO(<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>),
RESP(<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>,&nbsp;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>&gt;),
@ -21,15 +21,15 @@ chains of futures; but it occurring at runtime should be considered a catastroph
failure.</p>
<p>If any error is propagated this way that needs to be handled, then it should be made into
a proper option.</p>
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Debug" class="anchor"></a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Display" class="anchor"></a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Debug" class="anchor"></a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Display" class="anchor"></a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Error" class="anchor"></a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#127" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#139" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#149" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-From%3CError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt; for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-From%3CError%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#134" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#146" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#156" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-From%3CError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt; for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-From%3CError%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CError%3E-1" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>&gt; for <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a href="#impl-From%3CError%3E-1" class="anchor"></a><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(original: <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>) -&gt; <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a></code><a class="srclink" href="../src/actix_redis/lib.rs.html#18" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CTrySendError%3CT%3E%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;TrySendError&lt;T&gt;&gt; for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a href="#impl-From%3CTrySendError%3CT%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: TrySendError&lt;T&gt;) -&gt; <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CTrySendError%3CT%3E%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;TrySendError&lt;T&gt;&gt; for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a href="#impl-From%3CTrySendError%3CT%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(err: TrySendError&lt;T&gt;) -&gt; <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216-220" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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="A single RESP value, this owns the data that is read/to-be written to Redis."><meta name="keywords" content="rust, rustlang, rust-lang, RespValue"><title>actix_redis::RespValue - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum RespValue</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Array">Array</a><a href="#variant.BulkString">BulkString</a><a href="#variant.Error">Error</a><a href="#variant.Integer">Integer</a><a href="#variant.Nil">Nil</a><a href="#variant.SimpleString">SimpleString</a></div><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.append">append</a><a href="#method.push">push</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Eq">Eq</a><a href="#impl-From%3C%26%27a%20%5Bu8%5D%3E">From&lt;&amp;&#39;a [u8]&gt;</a><a href="#impl-From%3C%26%27a%20String%3E">From&lt;&amp;&#39;a String&gt;</a><a href="#impl-From%3C%26%27a%20str%3E">From&lt;&amp;&#39;a str&gt;</a><a href="#impl-From%3CArc%3Cstr%3E%3E">From&lt;Arc&lt;str&gt;&gt;</a><a href="#impl-From%3CString%3E">From&lt;String&gt;</a><a href="#impl-From%3CVec%3Cu8%2C%20Global%3E%3E">From&lt;Vec&lt;u8, Global&gt;&gt;</a><a href="#impl-From%3Cusize%3E">From&lt;usize&gt;</a><a href="#impl-FromResp">FromResp</a><a href="#impl-PartialEq%3CRespValue%3E">PartialEq&lt;RespValue&gt;</a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-Equivalent%3CK%3E">Equivalent&lt;K&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="RespValue" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">RespValue</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">&#x2212;</span>]</a></span></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum RespValue {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">RespValue</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum RespValue {
Nil,
Array(<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;),
BulkString(<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;),
@ -27,13 +27,13 @@ arguments, e.g. RPUSH</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-Clone" class="anchor"></a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-Debug" class="anchor"></a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-Eq" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-From%3C%26%27a%20%5Bu8%5D%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3C%26%27a%20%5Bu8%5D%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-2" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-Eq" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-From%3C%26%27a%20%5Bu8%5D%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3C%26%27a%20%5Bu8%5D%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-3" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3C%26%27a%20String%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3C%26%27a%20String%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-6" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: &amp;'a <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3C%26%27a%20str%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3C%26%27a%20str%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-3" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CArc%3Cstr%3E%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3CArc%3Cstr%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-5" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3C%26%27a%20str%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3C%26%27a%20str%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CArc%3Cstr%3E%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3CArc%3Cstr%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-2" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CString%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3CString%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-4" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CVec%3Cu8%2C%20Global%3E%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3CVec%3Cu8%2C%20Global%3E%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3Cusize%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3Cusize%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3Cusize%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-From%3Cusize%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from-5" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(from: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-FromResp" class="impl"><code class="in-band">impl FromResp for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-FromResp" class="anchor"></a></h3><div class="impl-items"><h4 id="method.from_resp_int" class="method hidden"><code>pub fn <a href="#method.from_resp_int" class="fnname">from_resp_int</a>(resp: <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>, <a class="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>&gt;</code></h4><h4 id="method.from_resp" class="method hidden"><code>pub fn <a href="#method.from_resp" class="fnname">from_resp</a>(resp: <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>) -&gt; <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="enum" href="../actix_redis/enum.RespError.html" title="enum actix_redis::RespError">Error</a>&gt;</code></h4><div class='docblock hidden'><p>Return a <code>Result</code> containing either <code>Self</code> or <code>Error</code>. Errors can occur due to either: a) the particular
<code>RespValue</code> being incompatible with the required type, or b) a remote Redis error occuring. <a href="#method.from_resp">Read more</a></p>
</div></div><h3 id="impl-PartialEq%3CRespValue%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>&gt; for <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a></code><a href="#impl-PartialEq%3CRespValue%3E" class="anchor"></a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&amp;self, other: &amp;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used

View File

@ -1,7 +1,7 @@
<!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="The `SameSite` cookie attribute."><meta name="keywords" content="rust, rustlang, rust-lang, SameSite"><title>actix_redis::SameSite - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum SameSite</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Lax">Lax</a><a href="#variant.None">None</a><a href="#variant.Strict">Strict</a></div><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.is_lax">is_lax</a><a href="#method.is_none">is_none</a><a href="#method.is_strict">is_strict</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Eq">Eq</a><a href="#impl-Hash">Hash</a><a href="#impl-PartialEq%3CSameSite%3E">PartialEq&lt;SameSite&gt;</a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-CallHasher">CallHasher</a><a href="#impl-Equivalent%3CK%3E">Equivalent&lt;K&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="SameSite" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">SameSite</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">&#x2212;</span>]</a></span><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#29-36" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum SameSite {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_redis</a>::<wbr><a class="enum" href="">SameSite</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#29-36" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum SameSite {
Strict,
Lax,
None,
@ -29,30 +29,30 @@ definition are subject to change.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="enum" href="../actix_redis/enum.SameSite.html" title="enum actix_redis::SameSite">SameSite</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#38-98" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.is_strict" class="method"><code>pub fn <a href="#method.is_strict" class="fnname">is_strict</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#52" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if <code>self</code> is <code>SameSite::Strict</code> and <code>false</code> otherwise.</p>
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">cookie</span>::<span class="ident">SameSite</span>;
<span class="kw">use</span> <span class="ident">cookie::SameSite</span>;
<span class="kw">let</span> <span class="ident">strict</span> <span class="op">=</span> <span class="ident">SameSite</span>::<span class="ident">Strict</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">strict</span>.<span class="ident">is_strict</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">strict</span>.<span class="ident">is_lax</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">strict</span>.<span class="ident">is_none</span>());</pre></div>
<span class="kw">let</span> <span class="ident">strict</span> <span class="op">=</span> <span class="ident">SameSite::Strict</span>;
<span class="macro">assert!</span>(<span class="ident">strict</span>.<span class="ident">is_strict</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">strict</span>.<span class="ident">is_lax</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">strict</span>.<span class="ident">is_none</span>());</pre></div>
</div><h4 id="method.is_lax" class="method"><code>pub fn <a href="#method.is_lax" class="fnname">is_lax</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#72" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if <code>self</code> is <code>SameSite::Lax</code> and <code>false</code> otherwise.</p>
<h1 id="example-1" class="section-header"><a href="#example-1">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">cookie</span>::<span class="ident">SameSite</span>;
<span class="kw">use</span> <span class="ident">cookie::SameSite</span>;
<span class="kw">let</span> <span class="ident">lax</span> <span class="op">=</span> <span class="ident">SameSite</span>::<span class="ident">Lax</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">lax</span>.<span class="ident">is_lax</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">lax</span>.<span class="ident">is_strict</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">lax</span>.<span class="ident">is_none</span>());</pre></div>
<span class="kw">let</span> <span class="ident">lax</span> <span class="op">=</span> <span class="ident">SameSite::Lax</span>;
<span class="macro">assert!</span>(<span class="ident">lax</span>.<span class="ident">is_lax</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">lax</span>.<span class="ident">is_strict</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">lax</span>.<span class="ident">is_none</span>());</pre></div>
</div><h4 id="method.is_none" class="method"><code>pub fn <a href="#method.is_none" class="fnname">is_none</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#92" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if <code>self</code> is <code>SameSite::None</code> and <code>false</code> otherwise.</p>
<h1 id="example-2" class="section-header"><a href="#example-2">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">cookie</span>::<span class="ident">SameSite</span>;
<span class="kw">use</span> <span class="ident">cookie::SameSite</span>;
<span class="kw">let</span> <span class="ident">none</span> <span class="op">=</span> <span class="ident">SameSite</span>::<span class="prelude-val">None</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">none</span>.<span class="ident">is_none</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">none</span>.<span class="ident">is_lax</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">none</span>.<span class="ident">is_strict</span>());</pre></div>
<span class="kw">let</span> <span class="ident">none</span> <span class="op">=</span> <span class="ident">SameSite::None</span>;
<span class="macro">assert!</span>(<span class="ident">none</span>.<span class="ident">is_none</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">none</span>.<span class="ident">is_lax</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">none</span>.<span class="ident">is_strict</span>());</pre></div>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="enum" href="../actix_redis/enum.SameSite.html" title="enum actix_redis::SameSite">SameSite</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#28" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; <a class="enum" href="../actix_redis/enum.SameSite.html" title="enum actix_redis::SameSite">SameSite</a></code><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#28" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id="impl-Copy" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="enum" href="../actix_redis/enum.SameSite.html" title="enum actix_redis::SameSite">SameSite</a></code><a href="#impl-Copy" class="anchor"></a><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#28" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../actix_redis/enum.SameSite.html" title="enum actix_redis::SameSite">SameSite</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#28" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</code><a class="srclink" href="https://docs.rs/cookie/0.14/src/cookie/draft.rs.html#28" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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="Redis integration for Actix and session store for Actix Web."><meta name="keywords" content="rust, rustlang, rust-lang, actix_redis"><title>actix_redis - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate actix_redis</p><div class="block version"><p>Version 0.10.0-beta.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_redis's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_redis" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_redis</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/lib.rs.html#1-35" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Redis integration for Actix and session store for Actix Web.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_redis</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/lib.rs.html#1-35" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Redis integration for Actix and session store for Actix Web.</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.Command.html" title="actix_redis::Command struct">Command</a></td><td class="docblock-short"><p>Command for send data to Redis</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.RedisActor.html" title="actix_redis::RedisActor struct">RedisActor</a></td><td class="docblock-short"><p>Redis communication actor</p>

View File

@ -1,7 +1,7 @@
<!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="Command for send data to Redis"><meta name="keywords" content="rust, rustlang, rust-lang, Command"><title>actix_redis::Command - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct Command</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Handler%3CCommand%3E">Handler&lt;Command&gt;</a><a href="#impl-Message">Message</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="Command" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">Command</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/redis.rs.html#21" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Command(pub <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>);</pre></div><div class="docblock"><p>Command for send data to Redis</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">Command</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/redis.rs.html#21" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Command(pub <a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>);</pre></div><div class="docblock"><p>Command for send data to Redis</p>
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../actix_redis/struct.Command.html" title="struct actix_redis::Command">Command</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/actix_redis/redis.rs.html#20" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/actix_redis/redis.rs.html#20" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Handler%3CCommand%3E" class="impl"><code class="in-band">impl Handler&lt;<a class="struct" href="../actix_redis/struct.Command.html" title="struct actix_redis::Command">Command</a>&gt; for <a class="struct" href="../actix_redis/struct.RedisActor.html" title="struct actix_redis::RedisActor">RedisActor</a></code><a href="#impl-Handler%3CCommand%3E" class="anchor"></a><a class="srclink" href="../src/actix_redis/redis.rs.html#127-141" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Result" class="type"><code>type <a href="#associatedtype.Result" class="type">Result</a> = ResponseFuture&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="../actix_redis/enum.RespValue.html" title="enum actix_redis::RespValue">RespValue</a>, <a class="enum" href="../actix_redis/enum.Error.html" title="enum actix_redis::Error">Error</a>&gt;&gt;</code></h4><div class='docblock'><p>The type of value that this handler will return. <a href="#associatedtype.Result">Read more</a></p>
</div><h4 id="method.handle" class="method hidden"><code>fn <a href="#method.handle" class="fnname">handle</a>(&amp;mut self, msg: <a class="struct" href="../actix_redis/struct.Command.html" title="struct actix_redis::Command">Command</a>, _: &amp;mut Self::Context) -&gt; Self::Result</code><a class="srclink" href="../src/actix_redis/redis.rs.html#130-140" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method is called for every message received by this actor.</p>

View File

@ -1,7 +1,7 @@
<!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="Redis communication actor"><meta name="keywords" content="rust, rustlang, rust-lang, RedisActor"><title>actix_redis::RedisActor - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct RedisActor</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.start">start</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Actor">Actor</a><a href="#impl-Handler%3CCommand%3E">Handler&lt;Command&gt;</a><a href="#impl-StreamHandler%3CResult%3CRespValue%2C%20Error%3E%3E">StreamHandler&lt;Result&lt;RespValue, Error&gt;&gt;</a><a href="#impl-Supervised">Supervised</a><a href="#impl-WriteHandler%3CError%3E">WriteHandler&lt;Error&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="RedisActor" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">RedisActor</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/redis.rs.html#28-34" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct RedisActor { /* fields omitted */ }</pre></div><div class="docblock"><p>Redis communication actor</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">RedisActor</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/redis.rs.html#28-34" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct RedisActor { /* fields omitted */ }</pre></div><div class="docblock"><p>Redis communication actor</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_redis/struct.RedisActor.html" title="struct actix_redis::RedisActor">RedisActor</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_redis/redis.rs.html#36-54" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.start" class="method"><code>pub fn <a href="#method.start" class="fnname">start</a>&lt;S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;&gt;(addr: S) -&gt; Addr&lt;<a class="struct" href="../actix_redis/struct.RedisActor.html" title="struct actix_redis::RedisActor">RedisActor</a>&gt;</code><a class="srclink" href="../src/actix_redis/redis.rs.html#38-53" title="goto source code">[src]</a></h4><div class="docblock"><p>Start new <code>Supervisor</code> with <code>RedisActor</code>.</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Actor" class="impl"><code class="in-band">impl Actor for <a class="struct" href="../actix_redis/struct.RedisActor.html" title="struct actix_redis::RedisActor">RedisActor</a></code><a href="#impl-Actor" class="anchor"></a><a class="srclink" href="../src/actix_redis/redis.rs.html#56-91" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Context" class="type"><code>type <a href="#associatedtype.Context" class="type">Context</a> = Context&lt;Self&gt;</code></h4><div class='docblock'><p>Actor execution context type</p>
</div><h4 id="method.started" class="method hidden"><code>fn <a href="#method.started" class="fnname">started</a>(&amp;mut self, ctx: &amp;mut Context&lt;Self&gt;)</code><a class="srclink" href="../src/actix_redis/redis.rs.html#59-90" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Called when an actor gets polled the first time.</p>

View File

@ -1,7 +1,7 @@
<!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="Use redis as session storage."><meta name="keywords" content="rust, rustlang, rust-lang, RedisSession"><title>actix_redis::RedisSession - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_redis/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct RedisSession</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.cache_keygen">cache_keygen</a><a href="#method.cookie_domain">cookie_domain</a><a href="#method.cookie_http_only">cookie_http_only</a><a href="#method.cookie_max_age">cookie_max_age</a><a href="#method.cookie_name">cookie_name</a><a href="#method.cookie_path">cookie_path</a><a href="#method.cookie_same_site">cookie_same_site</a><a href="#method.cookie_secure">cookie_secure</a><a href="#method.new">new</a><a href="#method.ttl">ttl</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E">Transform&lt;S, ServiceRequest&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_redis</a></p><div id="sidebar-vars" data-name="RedisSession" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">RedisSession</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/session.rs.html#25" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct RedisSession(_);</pre></div><div class="docblock"><p>Use redis as session storage.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_redis</a>::<wbr><a class="struct" href="">RedisSession</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_redis/session.rs.html#25" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct RedisSession(_);</pre></div><div class="docblock"><p>Use redis as session storage.</p>
<p>You need to pass an address of the redis server and random value to the
constructor of <code>RedisSession</code>. This is private key for cookie
session, When this value is changed, all session data is lost.</p>

View File

@ -1,7 +1,7 @@
<!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="Status of a [`Session`]."><meta name="keywords" content="rust, rustlang, rust-lang, SessionStatus"><title>actix_session::SessionStatus - 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><script src="../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../actix_session/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Enum SessionStatus</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Changed">Changed</a><a href="#variant.Purged">Purged</a><a href="#variant.Renewed">Renewed</a><a href="#variant.Unchanged">Unchanged</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-PartialEq%3CSessionStatus%3E">PartialEq&lt;SessionStatus&gt;</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_session</a></p><div id="sidebar-vars" data-name="SessionStatus" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_session</a>::<wbr><a class="enum" href="">SessionStatus</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#112-133" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum SessionStatus {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="index.html">actix_session</a>::<wbr><a class="enum" href="">SessionStatus</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#112-133" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum SessionStatus {
Changed,
Purged,
Renewed,

View File

@ -1,7 +1,7 @@
<!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="Sessions for Actix Web."><meta name="keywords" content="rust, rustlang, rust-lang, actix_session"><title>actix_session - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../actix_session/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate actix_session</p><div class="block version"><p>Version 0.5.0-beta.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_session's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_session" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_session</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#1-411" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Sessions for Actix Web.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_session</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#1-411" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Sessions for Actix Web.</p>
<p>Provides a general solution for session management. Session middleware could provide different
implementations which could be accessed via general session API.</p>
<p>This crate provides a general solution for session management and includes a cookie backend.
@ -17,7 +17,7 @@ modifying session data.</p>
<span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">session</span>: <span class="ident">Session</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>, <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="comment">// access session data</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">count</span>) <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>(<span class="string">&quot;counter&quot;</span>)<span class="question-mark">?</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;SESSION value: {}&quot;</span>, <span class="ident">count</span>);
<span class="macro">println!</span>(<span class="string">&quot;SESSION value: {}&quot;</span>, <span class="ident">count</span>);
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="ident">count</span> <span class="op">+</span> <span class="number">1</span>)<span class="question-mark">?</span>;
} <span class="kw">else</span> {
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">1</span>)<span class="question-mark">?</span>;
@ -26,13 +26,13 @@ modifying session data.</p>
<span class="prelude-val">Ok</span>(<span class="string">&quot;Welcome!&quot;</span>)
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">main</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="ident">HttpServer</span>::<span class="ident">new</span>(
<span class="op">|</span><span class="op">|</span> <span class="ident">App</span>::<span class="ident">new</span>()
<span class="attribute">#[<span class="ident">actix_rt::main</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">std::io::Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="ident">HttpServer::new</span>(
<span class="op">|</span><span class="op">|</span> <span class="ident">App::new</span>()
<span class="comment">// create cookie based session middleware</span>
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">default_service</span>(<span class="ident">web</span>::<span class="ident">to</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>())))
.<span class="ident">wrap</span>(<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">default_service</span>(<span class="ident">web::to</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">HttpResponse::Ok</span>())))
.<span class="ident">bind</span>((<span class="string">&quot;127.0.0.1&quot;</span>, <span class="number">8080</span>))<span class="question-mark">?</span>
.<span class="ident">run</span>()
.<span class="kw">await</span>

View File

@ -1,7 +1,7 @@
<!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="Use cookies for session storage."><meta name="keywords" content="rust, rustlang, rust-lang, CookieSession"><title>actix_session::CookieSession - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_session/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct CookieSession</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.domain">domain</a><a href="#method.expires_in">expires_in</a><a href="#method.expires_in_time">expires_in_time</a><a href="#method.http_only">http_only</a><a href="#method.lazy">lazy</a><a href="#method.max_age">max_age</a><a href="#method.max_age_time">max_age_time</a><a href="#method.name">name</a><a href="#method.path">path</a><a href="#method.private">private</a><a href="#method.same_site">same_site</a><a href="#method.secure">secure</a><a href="#method.signed">signed</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E">Transform&lt;S, ServiceRequest&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_session</a></p><div id="sidebar-vars" data-name="CookieSession" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_session</a>::<wbr><a class="struct" href="">CookieSession</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/cookie.rs.html#201" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct CookieSession(_);</pre></div><div class="docblock"><p>Use cookies for session storage.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_session</a>::<wbr><a class="struct" href="">CookieSession</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/cookie.rs.html#201" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct CookieSession(_);</pre></div><div class="docblock"><p>Use cookies for session storage.</p>
<p><code>CookieSession</code> creates sessions which are limited to storing
fewer than 4000 bytes of data (as the payload must fit into a single
cookie). An Internal Server Error is generated if the session contains more
@ -22,16 +22,16 @@ By default all cookies are percent encoded, but certain symbols may
cause troubles when reading cookie, if they are not properly percent encoded.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_session</span>::<span class="ident">CookieSession</span>;
<span class="kw">use</span> <span class="ident">actix_session::CookieSession</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">HttpResponse</span>, <span class="ident">HttpServer</span>};
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>().<span class="ident">wrap</span>(
<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>().<span class="ident">wrap</span>(
<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="string">&quot;actix_session&quot;</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">secure</span>(<span class="bool-val">true</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()));</pre></div>
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">HttpResponse::Ok</span>()));</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../actix_session/struct.CookieSession.html" title="struct actix_session::CookieSession">CookieSession</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/actix_session/cookie.rs.html#203-293" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.signed" class="method"><code>pub fn <a href="#method.signed" class="fnname">signed</a>(key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="struct" href="../actix_session/struct.CookieSession.html" title="struct actix_session::CookieSession">CookieSession</a></code><a class="srclink" href="../src/actix_session/cookie.rs.html#207-212" title="goto source code">[src]</a></h4><div class="docblock"><p>Construct new <em>signed</em> <code>CookieSession</code> instance.</p>
<p>Panics if key length is less than 32 bytes.</p>
</div><h4 id="method.private" class="method"><code>pub fn <a href="#method.private" class="fnname">private</a>(key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="struct" href="../actix_session/struct.CookieSession.html" title="struct actix_session::CookieSession">CookieSession</a></code><a class="srclink" href="../src/actix_session/cookie.rs.html#217-222" title="goto source code">[src]</a></h4><div class="docblock"><p>Construct new <em>private</em> <code>CookieSession</code> instance.</p>

View File

@ -1,13 +1,13 @@
<!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="The high-level interface you use to modify session data."><meta name="keywords" content="rust, rustlang, rust-lang, Session"><title>actix_session::Session - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../actix_session/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct Session</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.clear">clear</a><a href="#method.entries">entries</a><a href="#method.get">get</a><a href="#method.get_changes">get_changes</a><a href="#method.insert">insert</a><a href="#method.purge">purge</a><a href="#method.remove">remove</a><a href="#method.remove_as">remove_as</a><a href="#method.renew">renew</a><a href="#method.set_session">set_session</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-FromRequest">FromRequest</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">actix_session</a></p><div id="sidebar-vars" data-name="Session" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_session</a>::<wbr><a class="struct" href="">Session</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#84" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Session(_);</pre></div><div class="docblock"><p>The high-level interface you use to modify session data.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">actix_session</a>::<wbr><a class="struct" href="">Session</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#84" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Session(_);</pre></div><div class="docblock"><p>The high-level interface you use to modify session data.</p>
<p>Session object is obtained with <a href="../actix_session/trait.UserSession.html#tymethod.get_session" title="UserSession::get_session"><code>UserSession::get_session</code></a>. The <a href="../actix_session/trait.UserSession.html" title="UserSession"><code>UserSession</code></a> trait is
implemented for <code>HttpRequest</code>, <code>ServiceRequest</code>, and <code>RequestHead</code>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_session</span>::<span class="ident">Session</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="prelude-ty">Result</span>;
<span class="kw">use</span> <span class="ident">actix_session::Session</span>;
<span class="kw">use</span> <span class="ident">actix_web::Result</span>;
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">session</span>: <span class="ident">Session</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span><span class="op">&gt;</span> {
<span class="comment">// access session data</span>
@ -38,17 +38,17 @@ otherwise returns un-deserialized JSON string.</p>
already be JSON serialized.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="ident">Session</span>::<span class="ident">set_session</span>(
<span class="ident">Session::set_session</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>,
<span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;counter&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="number">0</span>).<span class="ident">unwrap</span>())],
<span class="macro">vec!</span>[(<span class="string">&quot;counter&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="number">0</span>).<span class="ident">unwrap</span>())],
);</pre></div>
</div><h4 id="method.get_changes" class="method"><code>pub fn <a href="#method.get_changes" class="fnname">get_changes</a>&lt;B&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;res: &amp;mut ServiceResponse&lt;B&gt;<br>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="enum" href="../actix_session/enum.SessionStatus.html" title="enum actix_session::SessionStatus">SessionStatus</a>, impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a>&lt;Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class="srclink" href="../src/actix_session/lib.rs.html#272-285" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns session status and iterator of key-value pairs of changes.</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-FromRequest" class="impl"><code class="in-band">impl FromRequest for <a class="struct" href="../actix_session/struct.Session.html" title="struct actix_session::Session">Session</a></code><a href="#impl-FromRequest" class="anchor"></a><a class="srclink" href="../src/actix_session/lib.rs.html#317-326" title="goto source code">[src]</a></h3><div class="docblock"><p>Extractor implementation for Session type.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_session</span>::<span class="ident">Session</span>;
<span class="kw">use</span> <span class="ident">actix_session::Session</span>;
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">session</span>: <span class="ident">Session</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="kw">impl</span> <span class="ident">Responder</span><span class="op">&gt;</span> {
@ -60,7 +60,7 @@ already be JSON serialized.</p>
}
<span class="kw">let</span> <span class="ident">count</span> <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>(<span class="string">&quot;counter&quot;</span>)<span class="question-mark">?</span>.<span class="ident">unwrap</span>();
<span class="prelude-val">Ok</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Counter: {}&quot;</span>, <span class="ident">count</span>))
<span class="prelude-val">Ok</span>(<span class="macro">format!</span>(<span class="string">&quot;Counter: {}&quot;</span>, <span class="ident">count</span>))
}</pre></div>
</div><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="#associatedtype.Error" class="type">Error</a> = Error</code></h4><div class='docblock'><p>The associated error which can be returned.</p>
</div><h4 id="associatedtype.Future" class="type"><code>type <a href="#associatedtype.Future" class="type">Future</a> = Ready&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../actix_session/struct.Session.html" title="struct actix_session::Session">Session</a>, Error&gt;&gt;</code></h4><div class='docblock'><p>Future that resolves to a Self.</p>

View File

@ -1,7 +1,7 @@
<!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="Extraction of a [`Session`] object."><meta name="keywords" content="rust, rustlang, rust-lang, UserSession"><title>actix_session::UserSession - 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><script src="../crates.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" role="button">&#9776;</div><a href='../actix_session/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait UserSession</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.get_session">get_session</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-UserSession-for-HttpRequest">HttpRequest</a><a href="#impl-UserSession-for-RequestHead">RequestHead</a><a href="#impl-UserSession-for-ServiceRequest">ServiceRequest</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">actix_session</a></p><div id="sidebar-vars" data-name="UserSession" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_session</a>::<wbr><a class="trait" href="">UserSession</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#87-90" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait UserSession {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="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">actix_session</a>::<wbr><a class="trait" href="">UserSession</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_session/lib.rs.html#87-90" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait UserSession {
fn <a href="#tymethod.get_session" class="fnname">get_session</a>(&amp;self) -&gt; <a class="struct" href="../actix_session/struct.Session.html" title="struct actix_session::Session">Session</a>;
}</pre></div><div class="docblock"><p>Extraction of a <a href="../actix_session/struct.Session.html" title="Session"><code>Session</code></a> object.</p>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.get_session" class="method"><code>fn <a href="#tymethod.get_session" class="fnname">get_session</a>(&amp;self) -&gt; <a class="struct" href="../actix_session/struct.Session.html" title="struct actix_session::Session">Session</a></code><a class="srclink" href="../src/actix_session/lib.rs.html#89" title="goto source code">[src]</a></h3><div class="docblock"><p>Extract the <a href="../actix_session/struct.Session.html" title="Session"><code>Session</code></a> object</p>

View File

@ -1,7 +1,7 @@
<!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="Extractor for the “Basic” HTTP Authentication Scheme"><meta name="keywords" content="rust, rustlang, rust-lang, basic"><title>actix_web_httpauth::extractors::basic - 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><script src="../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module basic</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a></p><div id="sidebar-vars" data-name="basic" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a class="mod" href="">basic</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#1-152" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Extractor for the “Basic” HTTP Authentication Scheme</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a class="mod" href="">basic</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#1-152" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Extractor for the “Basic” HTTP Authentication Scheme</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.BasicAuth.html" title="actix_web_httpauth::extractors::basic::BasicAuth struct">BasicAuth</a></td><td class="docblock-short"><p>Extractor for HTTP Basic auth.</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Config.html" title="actix_web_httpauth::extractors::basic::Config struct">Config</a></td><td class="docblock-short"><p><a href="./struct.BasicAuth.html"><code>BasicAuth</code></a> extractor configuration,

View File

@ -1,14 +1,14 @@
<!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="Extractor for HTTP Basic auth."><meta name="keywords" content="rust, rustlang, rust-lang, BasicAuth"><title>actix_web_httpauth::extractors::basic::BasicAuth - 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><script src="../../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct BasicAuth</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.password">password</a><a href="#method.user_id">user_id</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AuthExtractor">AuthExtractor</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-FromRequest">FromRequest</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a></p><div id="sidebar-vars" data-name="BasicAuth" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">BasicAuth</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#92" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BasicAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Basic auth.</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">BasicAuth</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#92" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BasicAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Basic auth.</p>
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="prelude-ty">Result</span>;
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">basic</span>::<span class="ident">BasicAuth</span>;
<span class="kw">use</span> <span class="ident">actix_web::Result</span>;
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::basic::BasicAuth</span>;
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BasicAuth</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span> {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
<span class="macro">format!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
}</pre></div>
<p>If authentication fails, this extractor fetches the <a href="./struct.Config.html"><code>Config</code></a> instance
from the <a href="https://docs.rs/actix-web/1.0.0-beta.5/actix_web/struct.App.html#method.data">app data</a> in order to properly form the <code>WWW-Authenticate</code>
@ -16,16 +16,16 @@ response header.</p>
<h2 id="example-1" class="section-header"><a href="#example-1">Example</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">web</span>, <span class="ident">App</span>};
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">basic</span>::{<span class="ident">BasicAuth</span>, <span class="ident">Config</span>};
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::basic</span>::{<span class="ident">BasicAuth</span>, <span class="ident">Config</span>};
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BasicAuth</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span> {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
<span class="macro">format!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
}
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">data</span>(<span class="ident">Config</span>::<span class="ident">default</span>().<span class="ident">realm</span>(<span class="string">&quot;Restricted area&quot;</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/index.html&quot;</span>).<span class="ident">route</span>(<span class="ident">web</span>::<span class="ident">get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
.<span class="ident">data</span>(<span class="ident">Config::default</span>().<span class="ident">realm</span>(<span class="string">&quot;Restricted area&quot;</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/index.html&quot;</span>).<span class="ident">route</span>(<span class="ident">web::get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
}</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../actix_web_httpauth/extractors/basic/struct.BasicAuth.html" title="struct actix_web_httpauth::extractors::basic::BasicAuth">BasicAuth</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#94-104" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.user_id" class="method"><code>pub fn <a href="#method.user_id" class="fnname">user_id</a>(&amp;self) -&gt; &amp;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#96-98" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns clients user-ID.</p>
</div><h4 id="method.password" class="method"><code>pub fn <a href="#method.password" class="fnname">password</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#101-103" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns clients password.</p>

View File

@ -1,7 +1,7 @@
<!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="`BasicAuth` extractor configuration, used for `WWW-Authenticate` header later."><meta name="keywords" content="rust, rustlang, rust-lang, Config"><title>actix_web_httpauth::extractors::basic::Config - 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><script src="../../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Config</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.realm">realm</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CBasic%3E">AsRef&lt;Basic&gt;</a><a href="#impl-AuthExtractorConfig">AuthExtractorConfig</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a></p><div id="sidebar-vars" data-name="Config" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">Config</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#23" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Config(_);</pre></div><div class="docblock"><p><a href="./struct.BasicAuth.html"><code>BasicAuth</code></a> extractor configuration,
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">Config</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#23" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Config(_);</pre></div><div class="docblock"><p><a href="./struct.BasicAuth.html"><code>BasicAuth</code></a> extractor configuration,
used for <a href="../../headers/www_authenticate/struct.WwwAuthenticate.html"><code>WWW-Authenticate</code></a> header later.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../actix_web_httpauth/extractors/basic/struct.Config.html" title="struct actix_web_httpauth::extractors::basic::Config">Config</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#25-37" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.realm" class="method"><code>pub fn <a href="#method.realm" class="fnname">realm</a>&lt;T&gt;(self, value: T) -&gt; <a class="struct" href="../../../actix_web_httpauth/extractors/basic/struct.Config.html" title="struct actix_web_httpauth::extractors::basic::Config">Config</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;,&nbsp;</span></code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#30-36" title="goto source code">[src]</a></h4><div class="docblock"><p>Set challenge <code>realm</code> attribute.</p>
<p>The “realm” attribute indicates the scope of protection in the manner

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!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="Extractor for the “Bearer” HTTP Authentication Scheme"><meta name="keywords" content="rust, rustlang, rust-lang, bearer"><title>actix_web_httpauth::extractors::bearer - 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><script src="../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module bearer</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a></p><div id="sidebar-vars" data-name="bearer" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a class="mod" href="">bearer</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#1-180" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Extractor for the “Bearer” HTTP Authentication Scheme</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a class="mod" href="">bearer</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#1-180" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Extractor for the “Bearer” HTTP Authentication Scheme</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.BearerAuth.html" title="actix_web_httpauth::extractors::bearer::BearerAuth struct">BearerAuth</a></td><td class="docblock-short"><p>Extractor for HTTP Bearer auth</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Config.html" title="actix_web_httpauth::extractors::bearer::Config struct">Config</a></td><td class="docblock-short"><p><a href="./struct/BearerAuth.html">BearerAuth</a> extractor configuration.</p>

View File

@ -1,13 +1,13 @@
<!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="Extractor for HTTP Bearer auth"><meta name="keywords" content="rust, rustlang, rust-lang, BearerAuth"><title>actix_web_httpauth::extractors::bearer::BearerAuth - 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><script src="../../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct BearerAuth</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.token">token</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AuthExtractor">AuthExtractor</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-FromRequest">FromRequest</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a></p><div id="sidebar-vars" data-name="BearerAuth" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">BearerAuth</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#96" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BearerAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Bearer auth</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">BearerAuth</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#96" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BearerAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Bearer auth</p>
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">bearer</span>::<span class="ident">BearerAuth</span>;
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::bearer::BearerAuth</span>;
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BearerAuth</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span> {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Hello, user with token {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">token</span>())
<span class="macro">format!</span>(<span class="string">&quot;Hello, user with token {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">token</span>())
}</pre></div>
<p>If authentication fails, this extractor fetches the <a href="../../../actix_web_httpauth/extractors/bearer/struct.Config.html" title="Config"><code>Config</code></a> instance
from the [app data] in order to properly form the <code>WWW-Authenticate</code>
@ -15,20 +15,20 @@ response header.</p>
<h2 id="example-1" class="section-header"><a href="#example-1">Example</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">web</span>, <span class="ident">App</span>};
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">bearer</span>::{<span class="ident">BearerAuth</span>, <span class="ident">Config</span>};
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::bearer</span>::{<span class="ident">BearerAuth</span>, <span class="ident">Config</span>};
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BearerAuth</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span> {
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">token</span>())
<span class="macro">format!</span>(<span class="string">&quot;Hello, {}!&quot;</span>, <span class="ident">auth</span>.<span class="ident">token</span>())
}
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
.<span class="ident">data</span>(
<span class="ident">Config</span>::<span class="ident">default</span>()
<span class="ident">Config::default</span>()
.<span class="ident">realm</span>(<span class="string">&quot;Restricted area&quot;</span>)
.<span class="ident">scope</span>(<span class="string">&quot;email photo&quot;</span>),
)
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/index.html&quot;</span>).<span class="ident">route</span>(<span class="ident">web</span>::<span class="ident">get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/index.html&quot;</span>).<span class="ident">route</span>(<span class="ident">web::get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
}</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../actix_web_httpauth/extractors/bearer/struct.BearerAuth.html" title="struct actix_web_httpauth::extractors::bearer::BearerAuth">BearerAuth</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#98-103" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.token" class="method"><code>pub fn <a href="#method.token" class="fnname">token</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#100-102" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns bearer token provided by client.</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AuthExtractor" class="impl"><code class="in-band">impl <a class="trait" href="../../../actix_web_httpauth/extractors/trait.AuthExtractor.html" title="trait actix_web_httpauth::extractors::AuthExtractor">AuthExtractor</a> for <a class="struct" href="../../../actix_web_httpauth/extractors/bearer/struct.BearerAuth.html" title="struct actix_web_httpauth::extractors::bearer::BearerAuth">BearerAuth</a></code><a href="#impl-AuthExtractor" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#129-147" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Future" class="type"><code>type <a href="../../../actix_web_httpauth/extractors/trait.AuthExtractor.html#associatedtype.Future" class="type">Future</a> = Ready&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, Self::<a class="type" href="../../../actix_web_httpauth/extractors/trait.AuthExtractor.html#associatedtype.Error" title="type actix_web_httpauth::extractors::AuthExtractor::Error">Error</a>&gt;&gt;</code></h4><div class='docblock'><p>Future that resolves into extracted credentials type.</p>

View File

@ -1,7 +1,7 @@
<!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="BearerAuth extractor configuration."><meta name="keywords" content="rust, rustlang, rust-lang, Config"><title>actix_web_httpauth::extractors::bearer::Config - 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><script src="../../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Config</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.realm">realm</a><a href="#method.scope">scope</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CBearer%3E">AsRef&lt;Bearer&gt;</a><a href="#impl-AuthExtractorConfig">AuthExtractorConfig</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a></p><div id="sidebar-vars" data-name="Config" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">Config</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#20" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Config(_);</pre></div><div class="docblock"><p><a href="./struct/BearerAuth.html">BearerAuth</a> extractor configuration.</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">Config</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#20" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Config(_);</pre></div><div class="docblock"><p><a href="./struct/BearerAuth.html">BearerAuth</a> extractor configuration.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../actix_web_httpauth/extractors/bearer/struct.Config.html" title="struct actix_web_httpauth::extractors::bearer::Config">Config</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#22-41" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.scope" class="method"><code>pub fn <a href="#method.scope" class="fnname">scope</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;&gt;(self, value: T) -&gt; <a class="struct" href="../../../actix_web_httpauth/extractors/bearer/struct.Config.html" title="struct actix_web_httpauth::extractors::bearer::Config">Config</a></code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/bearer.rs.html#28-31" title="goto source code">[src]</a></h4><div class="docblock"><p>Set challenge <code>scope</code> attribute.</p>
<p>The <code>&quot;scope&quot;</code> attribute is a space-delimited list of case-sensitive
scope values indicating the required scope of the access token for

View File

@ -1,7 +1,7 @@
<!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="Type-safe authentication information extractors"><meta name="keywords" content="rust, rustlang, rust-lang, extractors"><title>actix_web_httpauth::extractors - 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><script src="../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module extractors</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"><a href="../index.html">actix_web_httpauth</a></p><div id="sidebar-vars" data-name="extractors" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">extractors</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/mod.rs.html#1-33" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Type-safe authentication information extractors</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">extractors</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/mod.rs.html#1-33" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Type-safe authentication information extractors</p>
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
<table><tr class="module-item"><td><a class="mod" href="basic/index.html" title="actix_web_httpauth::extractors::basic mod">basic</a></td><td class="docblock-short"><p>Extractor for the “Basic” HTTP Authentication Scheme</p>
</td></tr><tr class="module-item"><td><a class="mod" href="bearer/index.html" title="actix_web_httpauth::extractors::bearer mod">bearer</a></td><td class="docblock-short"><p>Extractor for the “Bearer” HTTP Authentication Scheme</p>

View File

@ -1,7 +1,7 @@
<!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="Authentication error returned by authentication extractors."><meta name="keywords" content="rust, rustlang, rust-lang, AuthenticationError"><title>actix_web_httpauth::extractors::AuthenticationError - 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><script src="../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct AuthenticationError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.challenge_mut">challenge_mut</a><a href="#method.new">new</a><a href="#method.status_code_mut">status_code_mut</a><a href="#method.with_error">with_error</a><a href="#method.with_error_description">with_error_description</a><a href="#method.with_error_uri">with_error_uri</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-ResponseError">ResponseError</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a></p><div id="sidebar-vars" data-name="AuthenticationError" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="struct" href="">AuthenticationError</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#15-18" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct AuthenticationError&lt;C:&nbsp;<a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; { /* fields omitted */ }</pre></div><div class="docblock"><p>Authentication error returned by authentication extractors.</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="struct" href="">AuthenticationError</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#15-18" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct AuthenticationError&lt;C:&nbsp;<a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; { /* fields omitted */ }</pre></div><div class="docblock"><p>Authentication error returned by authentication extractors.</p>
<p>Different extractors may extend <code>AuthenticationError</code> implementation
in order to provide access to inner challenge fields.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;<a class="struct" href="../../actix_web_httpauth/headers/www_authenticate/bearer/struct.Bearer.html" title="struct actix_web_httpauth::headers::www_authenticate::bearer::Bearer">Bearer</a>&gt;</code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/bearer.rs.html#150-180" title="goto source code">[src]</a></h3><div class="docblock"><p>Extended error customization for HTTP <code>Bearer</code> auth.</p>
@ -14,18 +14,18 @@ Error.</p>
</div></div><h3 id="impl-1" class="impl"><code class="in-band">impl&lt;C:&nbsp;<a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#20-43" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(challenge: C) -&gt; <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#24-29" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new authentication error from the provided <code>challenge</code>.</p>
<p>By default returned error will resolve into the <code>HTTP 401</code> status code.</p>
</div><h4 id="method.challenge_mut" class="method"><code>pub fn <a href="#method.challenge_mut" class="fnname">challenge_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>C</code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#32-34" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns mutable reference to the inner challenge instance.</p>
</div><h4 id="method.status_code_mut" class="method"><code>pub fn <a href="#method.status_code_mut" class="fnname">status_code_mut</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#40-42" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns mutable reference to the inner status code.</p>
</div><h4 id="method.status_code_mut" class="method"><code>pub fn <a href="#method.status_code_mut" class="fnname">status_code_mut</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#40-42" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns mutable reference to the inner status code.</p>
<p>Can be used to override returned status code, but by default
this lib tries to stick to the RFC, so it might be unreasonable.</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl&lt;C:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#14" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#14" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl&lt;C:&nbsp;<a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#45-49" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#46-48" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl&lt;C:&nbsp;'static + <a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#51" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#99" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#127" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#139" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#149" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl&lt;C:&nbsp;'static + <a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#51" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#106" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#134" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#146" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#156" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;&lt;T as <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractorConfig.html" title="trait actix_web_httpauth::extractors::AuthExtractorConfig">AuthExtractorConfig</a>&gt;::<a class="type" href="../../actix_web_httpauth/extractors/trait.AuthExtractorConfig.html#associatedtype.Inner" title="type actix_web_httpauth::extractors::AuthExtractorConfig::Inner">Inner</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractorConfig.html" title="trait actix_web_httpauth::extractors::AuthExtractorConfig">AuthExtractorConfig</a>,&nbsp;</span></code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/config.rs.html#16-23" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(config: T) -&gt; Self</code><a class="srclink" href="../../src/actix_web_httpauth/extractors/config.rs.html#20-22" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-ResponseError" class="impl"><code class="in-band">impl&lt;C:&nbsp;'static + <a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>&gt; ResponseError for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-ResponseError" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#53-64" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.error_response" class="method hidden"><code>fn <a href="#method.error_response" class="fnname">error_response</a>(&amp;self) -&gt; HttpResponse</code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#54-59" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Create response for error <a href="#method.error_response">Read more</a></p>
</div><h4 id="method.status_code" class="method hidden"><code>fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.3/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#61-63" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div><h4 id="method.status_code" class="method hidden"><code>fn <a href="#method.status_code" class="fnname">status_code</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/http/0.2.4/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a></code><a class="srclink" href="../../src/actix_web_httpauth/extractors/errors.rs.html#61-63" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Responses status code <a href="#method.status_code">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;C: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a>,&nbsp;</span></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt;</code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;C: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,&nbsp;</span></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../actix_web_httpauth/extractors/struct.AuthenticationError.html" title="struct actix_web_httpauth::extractors::AuthenticationError">AuthenticationError</a>&lt;C&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;C: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>,&nbsp;</span></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216-220" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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="Trait implemented by types that can extract HTTP authentication scheme credentials from the request."><meta name="keywords" content="rust, rustlang, rust-lang, AuthExtractor"><title>actix_web_httpauth::extractors::AuthExtractor - 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><script src="../../crates.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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait AuthExtractor</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></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.from_service_request">from_service_request</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a></p><div id="sidebar-vars" data-name="AuthExtractor" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="trait" href="">AuthExtractor</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/mod.rs.html#24-33" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AuthExtractor: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="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">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="trait" href="">AuthExtractor</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/mod.rs.html#24-33" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AuthExtractor: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href="#associatedtype.Error" class="type">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;Error&gt;;
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>&lt;Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, Self::<a class="type" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html#associatedtype.Error" title="type actix_web_httpauth::extractors::AuthExtractor::Error">Error</a>&gt;&gt;;
fn <a href="#tymethod.from_service_request" class="fnname">from_service_request</a>(req: &amp;ServiceRequest) -&gt; Self::<a class="type" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html#associatedtype.Future" title="type actix_web_httpauth::extractors::AuthExtractor::Future">Future</a>;

View File

@ -1,7 +1,7 @@
<!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="Trait implemented for types that provides configuration for the authentication extractors."><meta name="keywords" content="rust, rustlang, rust-lang, AuthExtractorConfig"><title>actix_web_httpauth::extractors::AuthExtractorConfig - 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><script src="../../crates.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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait AuthExtractorConfig</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.Inner">Inner</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.into_inner">into_inner</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a></p><div id="sidebar-vars" data-name="AuthExtractorConfig" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="trait" href="">AuthExtractorConfig</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/config.rs.html#8-14" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AuthExtractorConfig {
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="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">actix_web_httpauth</a>::<wbr><a href="index.html">extractors</a>::<wbr><a class="trait" href="">AuthExtractorConfig</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/extractors/config.rs.html#8-14" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AuthExtractorConfig {
type <a href="#associatedtype.Inner" class="type">Inner</a>: <a class="trait" href="../../actix_web_httpauth/headers/www_authenticate/trait.Challenge.html" title="trait actix_web_httpauth::headers::www_authenticate::Challenge">Challenge</a>;
fn <a href="#tymethod.into_inner" class="fnname">into_inner</a>(self) -&gt; Self::<a class="type" href="../../actix_web_httpauth/extractors/trait.AuthExtractorConfig.html#associatedtype.Inner" title="type actix_web_httpauth::extractors::AuthExtractorConfig::Inner">Inner</a>;
}</pre></div><div class="docblock"><p>Trait implemented for types that provides configuration

View File

@ -1,11 +1,11 @@
<!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="Possible errors while parsing `Authorization` header."><meta name="keywords" content="rust, rustlang, rust-lang, ParseError"><title>actix_web_httpauth::headers::authorization::ParseError - 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><script src="../../../crates.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 enum"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Enum ParseError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Base64DecodeError">Base64DecodeError</a><a href="#variant.Invalid">Invalid</a><a href="#variant.MissingField">MissingField</a><a href="#variant.MissingScheme">MissingScheme</a><a href="#variant.ToStrError">ToStrError</a><a href="#variant.Utf8Error">Utf8Error</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a><a href="#impl-From%3CDecodeError%3E">From&lt;DecodeError&gt;</a><a href="#impl-From%3CToStrError%3E">From&lt;ToStrError&gt;</a><a href="#impl-From%3CUtf8Error%3E">From&lt;Utf8Error&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a></p><div id="sidebar-vars" data-name="ParseError" data-ty="enum" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a>::<wbr><a class="enum" href="">ParseError</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#13-26" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum ParseError {
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Enum <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a>::<wbr><a class="enum" href="">ParseError</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#13-26" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust enum">pub enum ParseError {
Invalid,
MissingScheme,
MissingField(&amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>),
ToStrError(<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>),
ToStrError(<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>),
Base64DecodeError(DecodeError),
Utf8Error(<a class="struct" href="https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>),
}</pre></div><div class="docblock"><p>Possible errors while parsing <code>Authorization</code> header.</p>
@ -16,17 +16,17 @@ your own <a href="./trait.Scheme.html">authentication scheme</a>.</p>
<div id="variant.Invalid" class="variant small-section-header"><a href="#variant.Invalid" class="anchor field"></a><code>Invalid</code></div><div class="docblock"><p>Header value is malformed</p>
</div><div id="variant.MissingScheme" class="variant small-section-header"><a href="#variant.MissingScheme" class="anchor field"></a><code>MissingScheme</code></div><div class="docblock"><p>Authentication scheme is missing</p>
</div><div id="variant.MissingField" class="variant small-section-header"><a href="#variant.MissingField" class="anchor field"></a><code>MissingField(&amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>)</code></div><div class="docblock"><p>Required authentication field is missing</p>
</div><div id="variant.ToStrError" class="variant small-section-header"><a href="#variant.ToStrError" class="anchor field"></a><code>ToStrError(<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>)</code></div><div class="docblock"><p>Unable to convert header into the str</p>
</div><div id="variant.ToStrError" class="variant small-section-header"><a href="#variant.ToStrError" class="anchor field"></a><code>ToStrError(<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>)</code></div><div class="docblock"><p>Unable to convert header into the str</p>
</div><div id="variant.Base64DecodeError" class="variant small-section-header"><a href="#variant.Base64DecodeError" class="anchor field"></a><code>Base64DecodeError(DecodeError)</code></div><div class="docblock"><p>Malformed base64 string</p>
</div><div id="variant.Utf8Error" class="variant small-section-header"><a href="#variant.Utf8Error" class="anchor field"></a><code>Utf8Error(<a class="struct" href="https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>)</code></div><div class="docblock"><p>Malformed UTF-8 string</p>
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#12" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#12" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#28-40" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#29-39" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#42-53" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#43-52" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#127" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#139" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#149" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div><h4 id="method.backtrace" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#134" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
</div><h4 id="method.description" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#146" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>&gt;</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#156" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
</div></div></div><h3 id="impl-From%3CDecodeError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;DecodeError&gt; for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-From%3CDecodeError%3E" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#60-64" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(e: DecodeError) -&gt; Self</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#61-63" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CToStrError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>&gt; for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-From%3CToStrError%3E" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#55-59" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(e: <a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>) -&gt; Self</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#56-58" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CToStrError%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>&gt; for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-From%3CToStrError%3E" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#55-59" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(e: <a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.ToStrError.html" title="struct http::header::value::ToStrError">ToStrError</a>) -&gt; Self</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#56-58" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-From%3CUtf8Error%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>&gt; for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-From%3CUtf8Error%3E" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#65-69" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(e: <a class="struct" href="https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>) -&gt; Self</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/errors.rs.html#66-68" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>

View File

@ -1,7 +1,7 @@
<!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="`Authorization` header and various auth schemes"><meta name="keywords" content="rust, rustlang, rust-lang, authorization"><title>actix_web_httpauth::headers::authorization - 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><script src="../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module authorization</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a></p><div id="sidebar-vars" data-name="authorization" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a class="mod" href="">authorization</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/mod.rs.html#1-11" title="goto source code">[src]</a></span></h1><div class="docblock"><p><code>Authorization</code> header and various auth schemes</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a class="mod" href="">authorization</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/mod.rs.html#1-11" title="goto source code">[src]</a></span></h1><div class="docblock"><p><code>Authorization</code> header and various auth schemes</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.Authorization.html" title="actix_web_httpauth::headers::authorization::Authorization struct">Authorization</a></td><td class="docblock-short"><p><code>Authorization</code> header, defined in <a href="https://tools.ietf.org/html/rfc7235#section-4.2">RFC 7235</a></p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Basic.html" title="actix_web_httpauth::headers::authorization::Basic struct">Basic</a></td><td class="docblock-short"><p>Credentials for <code>Basic</code> authentication scheme, defined in <a href="https://tools.ietf.org/html/rfc7617">RFC 7617</a></p>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
<!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="Authentication scheme for `Authorization` header."><meta name="keywords" content="rust, rustlang, rust-lang, Scheme"><title>actix_web_httpauth::headers::authorization::Scheme - 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><script src="../../../crates.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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Trait Scheme</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.parse">parse</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a></p><div id="sidebar-vars" data-name="Scheme" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a>::<wbr><a class="trait" href="">Scheme</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/mod.rs.html#12-15" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Scheme: IntoHeaderValue + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</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> {
fn <a href="#tymethod.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;;
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="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">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">authorization</a>::<wbr><a class="trait" href="">Scheme</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/mod.rs.html#12-15" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Scheme: IntoHeaderValue + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</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> {
fn <a href="#tymethod.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;;
}</pre></div><div class="docblock"><p>Authentication scheme for <a href="./struct.Authorization.html"><code>Authorization</code></a>
header.</p>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.parse" class="method"><code>fn <a href="#tymethod.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/mod.rs.html#14" title="goto source code">[src]</a></h3><div class="docblock"><p>Try to parse the authentication scheme from the <code>Authorization</code> header.</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-Scheme" class="impl"><code class="in-band">impl <a class="trait" href="../../../actix_web_httpauth/headers/authorization/trait.Scheme.html" title="trait actix_web_httpauth::headers::authorization::Scheme">Scheme</a> for <a class="struct" href="../../../actix_web_httpauth/headers/authorization/struct.Basic.html" title="struct actix_web_httpauth::headers::authorization::Basic">Basic</a></code><a href="#impl-Scheme" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/basic.rs.html#50-83" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.parse" class="method hidden"><code>fn <a href="#method.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/basic.rs.html#51-82" title="goto source code">[src]</a></h4></div><h3 id="impl-Scheme-1" class="impl"><code class="in-band">impl <a class="trait" href="../../../actix_web_httpauth/headers/authorization/trait.Scheme.html" title="trait actix_web_httpauth::headers::authorization::Scheme">Scheme</a> for <a class="struct" href="../../../actix_web_httpauth/headers/authorization/struct.Bearer.html" title="struct actix_web_httpauth::headers::authorization::Bearer">Bearer</a></code><a href="#impl-Scheme-1" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/bearer.rs.html#43-62" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.parse-1" class="method hidden"><code>fn <a href="#method.parse-1" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.3/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/bearer.rs.html#44-61" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../../implementors/actix_web_httpauth/headers/authorization/trait.Scheme.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="actix_web_httpauth" data-search-js="../../../search-index.js"></div>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.parse" class="method"><code>fn <a href="#tymethod.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/mod.rs.html#14" title="goto source code">[src]</a></h3><div class="docblock"><p>Try to parse the authentication scheme from the <code>Authorization</code> header.</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-Scheme" class="impl"><code class="in-band">impl <a class="trait" href="../../../actix_web_httpauth/headers/authorization/trait.Scheme.html" title="trait actix_web_httpauth::headers::authorization::Scheme">Scheme</a> for <a class="struct" href="../../../actix_web_httpauth/headers/authorization/struct.Basic.html" title="struct actix_web_httpauth::headers::authorization::Basic">Basic</a></code><a href="#impl-Scheme" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/basic.rs.html#50-83" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.parse" class="method hidden"><code>fn <a href="#method.parse" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/basic.rs.html#51-82" title="goto source code">[src]</a></h4></div><h3 id="impl-Scheme-1" class="impl"><code class="in-band">impl <a class="trait" href="../../../actix_web_httpauth/headers/authorization/trait.Scheme.html" title="trait actix_web_httpauth::headers::authorization::Scheme">Scheme</a> for <a class="struct" href="../../../actix_web_httpauth/headers/authorization/struct.Bearer.html" title="struct actix_web_httpauth::headers::authorization::Bearer">Bearer</a></code><a href="#impl-Scheme-1" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/bearer.rs.html#43-62" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.parse-1" class="method hidden"><code>fn <a href="#method.parse-1" class="fnname">parse</a>(header: &amp;<a class="struct" href="https://docs.rs/http/0.2.4/http/header/value/struct.HeaderValue.html" title="struct http::header::value::HeaderValue">HeaderValue</a>) -&gt; <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="enum" href="../../../actix_web_httpauth/headers/authorization/enum.ParseError.html" title="enum actix_web_httpauth::headers::authorization::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../../../src/actix_web_httpauth/headers/authorization/scheme/bearer.rs.html#44-61" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../../implementors/actix_web_httpauth/headers/authorization/trait.Scheme.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="actix_web_httpauth" data-search-js="../../../search-index.js"></div>
<script src="../../../main.js"></script></body></html>

View File

@ -1,7 +1,7 @@
<!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="Typed HTTP headers"><meta name="keywords" content="rust, rustlang, rust-lang, headers"><title>actix_web_httpauth::headers - 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><script src="../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module headers</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li></ul></div><p class="location"><a href="../index.html">actix_web_httpauth</a></p><div id="sidebar-vars" data-name="headers" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">headers</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/headers/mod.rs.html#1-4" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Typed HTTP headers</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">headers</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/headers/mod.rs.html#1-4" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Typed HTTP headers</p>
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
<table><tr class="module-item"><td><a class="mod" href="authorization/index.html" title="actix_web_httpauth::headers::authorization mod">authorization</a></td><td class="docblock-short"><p><code>Authorization</code> header and various auth schemes</p>
</td></tr><tr class="module-item"><td><a class="mod" href="www_authenticate/index.html" title="actix_web_httpauth::headers::www_authenticate mod">www_authenticate</a></td><td class="docblock-short"><p><code>WWW-Authenticate</code> header and various auth challenges</p>

View File

@ -1,7 +1,7 @@
<!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="Challenge for the “Basic” HTTP Authentication Scheme"><meta name="keywords" content="rust, rustlang, rust-lang, basic"><title>actix_web_httpauth::headers::www_authenticate::basic - 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><script src="../../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class="location">Module basic</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a></p><div id="sidebar-vars" data-name="basic" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a class="mod" href="">basic</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/basic.rs.html#1-140" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Challenge for the “Basic” HTTP Authentication Scheme</p>
<a id="settings-menu" href="../../../../settings.html"><img src="../../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a class="mod" href="">basic</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/basic.rs.html#1-140" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Challenge for the “Basic” HTTP Authentication Scheme</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.Basic.html" title="actix_web_httpauth::headers::www_authenticate::basic::Basic struct">Basic</a></td><td class="docblock-short"><p>Challenge for <a href="../struct.WwwAuthenticate.html"><code>WWW-Authenticate</code></a> header with HTTP Basic auth scheme,
described in <a href="https://tools.ietf.org/html/rfc7617">RFC 7617</a></p>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!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="Challenge for the “Bearer” HTTP Authentication Scheme"><meta name="keywords" content="rust, rustlang, rust-lang, bearer"><title>actix_web_httpauth::headers::www_authenticate::bearer - 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><script src="../../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class="location">Module bearer</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class="location"><a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a></p><div id="sidebar-vars" data-name="bearer" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a class="mod" href="">bearer</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/mod.rs.html#1-12" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Challenge for the “Bearer” HTTP Authentication Scheme</p>
<a id="settings-menu" href="../../../../settings.html"><img src="../../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a class="mod" href="">bearer</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/mod.rs.html#1-12" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Challenge for the “Bearer” HTTP Authentication Scheme</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.Bearer.html" title="actix_web_httpauth::headers::www_authenticate::bearer::Bearer struct">Bearer</a></td><td class="docblock-short"><p>Challenge for <a href="../struct.WwwAuthenticate.html"><code>WWW-Authenticate</code></a> header with HTTP Bearer auth scheme,
described in <a href="https://tools.ietf.org/html/rfc6750#section-3">RFC 6750</a></p>

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!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="Builder for the `Bearer` challenge."><meta name="keywords" content="rust, rustlang, rust-lang, BearerBuilder"><title>actix_web_httpauth::headers::www_authenticate::bearer::BearerBuilder - 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><script src="../../../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct BearerBuilder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.error">error</a><a href="#method.error_description">error_description</a><a href="#method.error_uri">error_uri</a><a href="#method.finish">finish</a><a href="#method.realm">realm</a><a href="#method.scope">scope</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a href="index.html">bearer</a></p><div id="sidebar-vars" data-name="BearerBuilder" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">BearerBuilder</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/builder.rs.html#12" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BearerBuilder(_);</pre></div><div class="docblock"><p>Builder for the <a href="struct.Bearer.html"><code>Bearer</code></a> challenge.</p>
<a id="settings-menu" href="../../../../settings.html"><img src="../../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../../index.html">actix_web_httpauth</a>::<wbr><a href="../../index.html">headers</a>::<wbr><a href="../index.html">www_authenticate</a>::<wbr><a href="index.html">bearer</a>::<wbr><a class="struct" href="">BearerBuilder</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/builder.rs.html#12" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BearerBuilder(_);</pre></div><div class="docblock"><p>Builder for the <a href="struct.Bearer.html"><code>Bearer</code></a> challenge.</p>
<p>It is up to implementor to fill all required fields,
neither this <code>Builder</code> or <a href="struct.Bearer.html"><code>Bearer</code></a> does not provide any validation.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../../actix_web_httpauth/headers/www_authenticate/bearer/struct.BearerBuilder.html" title="struct actix_web_httpauth::headers::www_authenticate::bearer::BearerBuilder">BearerBuilder</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/builder.rs.html#14-63" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.scope" class="method"><code>pub fn <a href="#method.scope" class="fnname">scope</a>&lt;T&gt;(self, value: T) -&gt; Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;,&nbsp;</span></code><a class="srclink" href="../../../../src/actix_web_httpauth/headers/www_authenticate/challenge/bearer/builder.rs.html#16-22" title="goto source code">[src]</a></h4><div class="docblock"><p>Provides the <code>scope</code> attribute, as defined in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC6749, Section 3.3</a></p>

View File

@ -1,7 +1,7 @@
<!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="`WWW-Authenticate` header and various auth challenges"><meta name="keywords" content="rust, rustlang, rust-lang, www_authenticate"><title>actix_web_httpauth::headers::www_authenticate - 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><script src="../../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module www_authenticate</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a></p><div id="sidebar-vars" data-name="www_authenticate" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a class="mod" href="">www_authenticate</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/www_authenticate/mod.rs.html#1-9" title="goto source code">[src]</a></span></h1><div class="docblock"><p><code>WWW-Authenticate</code> header and various auth challenges</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a class="mod" href="">www_authenticate</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/www_authenticate/mod.rs.html#1-9" title="goto source code">[src]</a></span></h1><div class="docblock"><p><code>WWW-Authenticate</code> header and various auth challenges</p>
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
<table><tr class="module-item"><td><a class="mod" href="basic/index.html" title="actix_web_httpauth::headers::www_authenticate::basic mod">basic</a></td><td class="docblock-short"><p>Challenge for the “Basic” HTTP Authentication Scheme</p>
</td></tr><tr class="module-item"><td><a class="mod" href="bearer/index.html" title="actix_web_httpauth::headers::www_authenticate::bearer mod">bearer</a></td><td class="docblock-short"><p>Challenge for the “Bearer” HTTP Authentication Scheme</p>

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!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="Authentication challenge for `WWW-Authenticate` header."><meta name="keywords" content="rust, rustlang, rust-lang, Challenge"><title>actix_web_httpauth::headers::www_authenticate::Challenge - 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><script src="../../../crates.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" role="button">&#9776;</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Trait Challenge</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.to_bytes">to_bytes</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">www_authenticate</a></p><div id="sidebar-vars" data-name="Challenge" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="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">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">www_authenticate</a>::<wbr><a class="trait" href="">Challenge</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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/www_authenticate/challenge/mod.rs.html#10-13" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Challenge: IntoHeaderValue + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</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> {
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="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">actix_web_httpauth</a>::<wbr><a href="../index.html">headers</a>::<wbr><a href="index.html">www_authenticate</a>::<wbr><a class="trait" href="">Challenge</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/headers/www_authenticate/challenge/mod.rs.html#10-13" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Challenge: IntoHeaderValue + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</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> {
fn <a href="#tymethod.to_bytes" class="fnname">to_bytes</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/bytes/1.0.1/bytes/bytes/struct.Bytes.html" title="struct bytes::bytes::Bytes">Bytes</a>;
}</pre></div><div class="docblock"><p>Authentication challenge for <code>WWW-Authenticate</code> header.</p>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.to_bytes" class="method"><code>fn <a href="#tymethod.to_bytes" class="fnname">to_bytes</a>(&amp;self) -&gt; <a class="struct" href="https://docs.rs/bytes/1.0.1/bytes/bytes/struct.Bytes.html" title="struct bytes::bytes::Bytes">Bytes</a></code><a class="srclink" href="../../../src/actix_web_httpauth/headers/www_authenticate/challenge/mod.rs.html#12" title="goto source code">[src]</a></h3><div class="docblock"><p>Converts the challenge into a bytes suitable for HTTP transmission.</p>

View File

@ -1,7 +1,7 @@
<!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="HTTP authentication schemes for actix-web."><meta name="keywords" content="rust, rustlang, rust-lang, actix_web_httpauth"><title>actix_web_httpauth - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate actix_web_httpauth</p><div class="block version"><p>Version 0.6.0-beta.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all actix_web_httpauth's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="actix_web_httpauth" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_web_httpauth</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_web_httpauth/lib.rs.html#1-24" title="goto source code">[src]</a></span></h1><div class="docblock"><p>HTTP authentication schemes for <a href="https://actix.rs">actix-web</a>.</p>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">actix_web_httpauth</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/actix_web_httpauth/lib.rs.html#1-24" title="goto source code">[src]</a></span></h1><div class="docblock"><p>HTTP authentication schemes for <a href="https://actix.rs">actix-web</a>.</p>
<p>Provides:</p>
<ul>
<li>Typed <a href="../actix_web_httpauth/headers/authorization/struct.Authorization.html">Authorization</a> and <a href="../actix_web_httpauth/headers/www_authenticate/struct.WwwAuthenticate.html">WWW-Authenticate</a> headers</li>

View File

@ -1,7 +1,7 @@
<!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="HTTP Authentication middleware."><meta name="keywords" content="rust, rustlang, rust-lang, middleware"><title>actix_web_httpauth::middleware - 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><script src="../../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module middleware</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../index.html">actix_web_httpauth</a></p><div id="sidebar-vars" data-name="middleware" data-ty="mod" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">middleware</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#1-302" title="goto source code">[src]</a></span></h1><div class="docblock"><p>HTTP Authentication middleware.</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">actix_web_httpauth</a>::<wbr><a class="mod" href="">middleware</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#1-302" title="goto source code">[src]</a></span></h1><div class="docblock"><p>HTTP Authentication middleware.</p>
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.HttpAuthentication.html" title="actix_web_httpauth::middleware::HttpAuthentication struct">HttpAuthentication</a></td><td class="docblock-short"><p>Middleware for checking HTTP authentication.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-search-js="../../search-index.js"></div>

View File

@ -1,7 +1,7 @@
<!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="Middleware for checking HTTP authentication."><meta name="keywords" content="rust, rustlang, rust-lang, HttpAuthentication"><title>actix_web_httpauth::middleware::HttpAuthentication - 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><script src="../../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct HttpAuthentication</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.basic">basic</a><a href="#method.bearer">bearer</a><a href="#method.with_fn">with_fn</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Transform%3CS%2C%20ServiceRequest%3E">Transform&lt;S, ServiceRequest&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">middleware</a></p><div id="sidebar-vars" data-name="HttpAuthentication" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">middleware</a>::<wbr><a class="struct" href="">HttpAuthentication</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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#25-31" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct HttpAuthentication&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html" title="trait actix_web_httpauth::extractors::AuthExtractor">AuthExtractor</a>,&nbsp;</span> { /* fields omitted */ }</pre></div><div class="docblock"><p>Middleware for checking HTTP authentication.</p>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../index.html">actix_web_httpauth</a>::<wbr><a href="index.html">middleware</a>::<wbr><a class="struct" href="">HttpAuthentication</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#25-31" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct HttpAuthentication&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html" title="trait actix_web_httpauth::extractors::AuthExtractor">AuthExtractor</a>,&nbsp;</span> { /* fields omitted */ }</pre></div><div class="docblock"><p>Middleware for checking HTTP authentication.</p>
<p>If there is no <code>Authorization</code> header in the request, this middleware returns an error
immediately, without calling the <code>F</code> callback.</p>
<p>Otherwise, it will pass both the request and the parsed credentials into it. In case of
@ -22,7 +22,7 @@ validation callback <code>F</code>.</p>
<span class="prelude-val">Ok</span>(<span class="ident">req</span>)
}
<span class="kw">let</span> <span class="ident">middleware</span> <span class="op">=</span> <span class="ident">HttpAuthentication</span>::<span class="ident">basic</span>(<span class="ident">validator</span>);</pre></div>
<span class="kw">let</span> <span class="ident">middleware</span> <span class="op">=</span> <span class="ident">HttpAuthentication::basic</span>(<span class="ident">validator</span>);</pre></div>
</div></div><h3 id="impl-2" class="impl"><code class="in-band">impl&lt;F, O&gt; <a class="struct" href="../../actix_web_httpauth/middleware/struct.HttpAuthentication.html" title="struct actix_web_httpauth::middleware::HttpAuthentication">HttpAuthentication</a>&lt;<a class="struct" href="../../actix_web_httpauth/extractors/bearer/struct.BearerAuth.html" title="struct actix_web_httpauth::extractors::bearer::BearerAuth">BearerAuth</a>, F&gt; <span class="where fmt-newline">where<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>(ServiceRequest, <a class="struct" href="../../actix_web_httpauth/extractors/bearer/struct.BearerAuth.html" title="struct actix_web_httpauth::extractors::bearer::BearerAuth">BearerAuth</a>) -&gt; O,<br>&nbsp;&nbsp;&nbsp;&nbsp;O: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;ServiceRequest, Error&gt;&gt;,&nbsp;</span></code><a href="#impl-2" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#81-114" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bearer" class="method"><code>pub fn <a href="#method.bearer" class="fnname">bearer</a>(process_fn: F) -&gt; Self</code><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#111-113" title="goto source code">[src]</a></h4><div class="docblock"><p>Construct <code>HttpAuthentication</code> middleware for the HTTP “Bearer” authentication scheme.</p>
<h1 id="example-1" class="section-header"><a href="#example-1">Example</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
@ -32,14 +32,14 @@ validation callback <code>F</code>.</p>
} <span class="kw">else</span> {
<span class="kw">let</span> <span class="ident">config</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">data</span><span class="op">|</span> <span class="ident">data</span>.<span class="ident">clone</span>())
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default</span>::<span class="ident">default</span>)
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>)
.<span class="ident">scope</span>(<span class="string">&quot;urn:example:channel=HBO&amp;urn:example:rating=G,PG-13&quot;</span>);
<span class="prelude-val">Err</span>(<span class="ident">AuthenticationError</span>::<span class="ident">from</span>(<span class="ident">config</span>).<span class="ident">into</span>())
<span class="prelude-val">Err</span>(<span class="ident">AuthenticationError::from</span>(<span class="ident">config</span>).<span class="ident">into</span>())
}
}
<span class="kw">let</span> <span class="ident">middleware</span> <span class="op">=</span> <span class="ident">HttpAuthentication</span>::<span class="ident">bearer</span>(<span class="ident">validator</span>);</pre></div>
<span class="kw">let</span> <span class="ident">middleware</span> <span class="op">=</span> <span class="ident">HttpAuthentication::bearer</span>(<span class="ident">validator</span>);</pre></div>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, F:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../actix_web_httpauth/middleware/struct.HttpAuthentication.html" title="struct actix_web_httpauth::middleware::HttpAuthentication">HttpAuthentication</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html" title="trait actix_web_httpauth::extractors::AuthExtractor">AuthExtractor</a>,&nbsp;</span></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#24" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; <a class="struct" href="../../actix_web_httpauth/middleware/struct.HttpAuthentication.html" title="struct actix_web_httpauth::middleware::HttpAuthentication">HttpAuthentication</a>&lt;T, F&gt;</code><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#24" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, F:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../actix_web_httpauth/middleware/struct.HttpAuthentication.html" title="struct actix_web_httpauth::middleware::HttpAuthentication">HttpAuthentication</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../actix_web_httpauth/extractors/trait.AuthExtractor.html" title="trait actix_web_httpauth::extractors::AuthExtractor">AuthExtractor</a>,&nbsp;</span></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#24" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/actix_web_httpauth/middleware.rs.html#24" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
(function() {var implementors = {};
implementors["actix_protobuf"] = [{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;PayloadError&gt; for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>","synthetic":false,"types":["actix_protobuf::ProtoBufPayloadError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"struct\" href=\"https://docs.rs/prost/0.7.0/prost/error/struct.DecodeError.html\" title=\"struct prost::error::DecodeError\">DecodeError</a>&gt; for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>","synthetic":false,"types":["actix_protobuf::ProtoBufPayloadError"]}];
implementors["actix_redis"] = [{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"enum\" href=\"actix_redis/enum.RespError.html\" title=\"enum actix_redis::RespError\">Error</a>&gt; for <a class=\"enum\" href=\"actix_redis/enum.Error.html\" title=\"enum actix_redis::Error\">Error</a>","synthetic":false,"types":["actix_redis::Error"]}];
implementors["actix_web_httpauth"] = [{"text":"impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;T&gt; for <a class=\"struct\" href=\"actix_web_httpauth/extractors/struct.AuthenticationError.html\" title=\"struct actix_web_httpauth::extractors::AuthenticationError\">AuthenticationError</a>&lt;&lt;T as <a class=\"trait\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html\" title=\"trait actix_web_httpauth::extractors::AuthExtractorConfig\">AuthExtractorConfig</a>&gt;::<a class=\"type\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html#associatedtype.Inner\" title=\"type actix_web_httpauth::extractors::AuthExtractorConfig::Inner\">Inner</a>&gt; <span class=\"where fmt-newline\">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class=\"trait\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html\" title=\"trait actix_web_httpauth::extractors::AuthExtractorConfig\">AuthExtractorConfig</a>,&nbsp;</span>","synthetic":false,"types":["actix_web_httpauth::extractors::errors::AuthenticationError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"struct\" href=\"https://docs.rs/http/0.2.3/http/header/value/struct.ToStrError.html\" title=\"struct http::header::value::ToStrError\">ToStrError</a>&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;DecodeError&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"struct\" href=\"https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html\" title=\"struct core::str::error::Utf8Error\">Utf8Error</a>&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl&lt;S&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;S&gt; for <a class=\"struct\" href=\"actix_web_httpauth/headers/authorization/struct.Authorization.html\" title=\"struct actix_web_httpauth::headers::authorization::Authorization\">Authorization</a>&lt;S&gt; <span class=\"where fmt-newline\">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class=\"trait\" href=\"actix_web_httpauth/headers/authorization/trait.Scheme.html\" title=\"trait actix_web_httpauth::headers::authorization::Scheme\">Scheme</a>,&nbsp;</span>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::header::Authorization"]}];
implementors["actix_web_httpauth"] = [{"text":"impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;T&gt; for <a class=\"struct\" href=\"actix_web_httpauth/extractors/struct.AuthenticationError.html\" title=\"struct actix_web_httpauth::extractors::AuthenticationError\">AuthenticationError</a>&lt;&lt;T as <a class=\"trait\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html\" title=\"trait actix_web_httpauth::extractors::AuthExtractorConfig\">AuthExtractorConfig</a>&gt;::<a class=\"type\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html#associatedtype.Inner\" title=\"type actix_web_httpauth::extractors::AuthExtractorConfig::Inner\">Inner</a>&gt; <span class=\"where fmt-newline\">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class=\"trait\" href=\"actix_web_httpauth/extractors/trait.AuthExtractorConfig.html\" title=\"trait actix_web_httpauth::extractors::AuthExtractorConfig\">AuthExtractorConfig</a>,&nbsp;</span>","synthetic":false,"types":["actix_web_httpauth::extractors::errors::AuthenticationError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"struct\" href=\"https://docs.rs/http/0.2.4/http/header/value/struct.ToStrError.html\" title=\"struct http::header::value::ToStrError\">ToStrError</a>&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;DecodeError&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;<a class=\"struct\" href=\"https://doc.rust-lang.org/nightly/core/str/error/struct.Utf8Error.html\" title=\"struct core::str::error::Utf8Error\">Utf8Error</a>&gt; for <a class=\"enum\" href=\"actix_web_httpauth/headers/authorization/enum.ParseError.html\" title=\"enum actix_web_httpauth::headers::authorization::ParseError\">ParseError</a>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::errors::ParseError"]},{"text":"impl&lt;S&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a>&lt;S&gt; for <a class=\"struct\" href=\"actix_web_httpauth/headers/authorization/struct.Authorization.html\" title=\"struct actix_web_httpauth::headers::authorization::Authorization\">Authorization</a>&lt;S&gt; <span class=\"where fmt-newline\">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class=\"trait\" href=\"actix_web_httpauth/headers/authorization/trait.Scheme.html\" title=\"trait actix_web_httpauth::headers::authorization::Scheme\">Scheme</a>,&nbsp;</span>","synthetic":false,"types":["actix_web_httpauth::headers::authorization::header::Authorization"]}];
if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
#main>h2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;}#main>h2+div,#main>h3+div{display:block;}#main>h2+h3{display:flex;}#main .impl-items .hidden{display:block !important;}#main .impl-items h4.hidden{display:flex !important;}#main .attributes{margin-left:0 !important;}
#main>h2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;}#main>h2+div,#main>h3+div{display:block;}#main>h2+h3{display:flex;}#main .impl-items .hidden{display:block !important;}#main .impl-items h4.hidden{display:flex !important;}#main .attributes{margin-left:0 !important;}#copy-path{display:none;}

View File

@ -1,5 +1,5 @@
<!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 `index` fn in crate `prost_example`."><meta name="keywords" content="rust, rustlang, rust-lang, index"><title>prost_example::index - 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><script src="../crates.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 fn"><!--[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" role="button">&#9776;</div><a href='../prost_example/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">prost_example</a></p><div id="sidebar-vars" data-name="index" data-ty="fn" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="index.html">prost_example</a>::<wbr><a class="fn" href="">index</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#14-17" title="goto source code">[src]</a></span></h1><pre class="rust fn">pub(crate) async fn index(msg: <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;<a class="struct" href="../prost_example/struct.MyObj.html" title="struct prost_example::MyObj">MyObj</a>&gt;) -&gt; Result&lt;HttpResponse&gt;</pre></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="prost_example" data-search-js="../search-index.js"></div>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="index.html">prost_example</a>::<wbr><a class="fn" href="">index</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#14-17" title="goto source code">[src]</a></span></h1><pre class="rust fn">pub(crate) async fn index(msg: <a class="struct" href="../actix_protobuf/struct.ProtoBuf.html" title="struct actix_protobuf::ProtoBuf">ProtoBuf</a>&lt;<a class="struct" href="../prost_example/struct.MyObj.html" title="struct prost_example::MyObj">MyObj</a>&gt;) -&gt; Result&lt;HttpResponse&gt;</pre></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="prost_example" data-search-js="../search-index.js"></div>
<script src="../main.js"></script></body></html>

View File

@ -1,5 +1,5 @@
<!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 `main` fn in crate `prost_example`."><meta name="keywords" content="rust, rustlang, rust-lang, main"><title>prost_example::main - 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><script src="../crates.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 fn"><!--[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" role="button">&#9776;</div><a href='../prost_example/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">prost_example</a></p><div id="sidebar-vars" data-name="main" data-ty="fn" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="index.html">prost_example</a>::<wbr><a class="fn" href="">main</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#19" title="goto source code">[src]</a></span></h1><pre class="rust fn">pub(crate) fn main() -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</pre></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="prost_example" data-search-js="../search-index.js"></div>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Function <a href="index.html">prost_example</a>::<wbr><a class="fn" href="">main</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#19" title="goto source code">[src]</a></span></h1><pre class="rust fn">pub(crate) fn main() -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</pre></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="prost_example" data-search-js="../search-index.js"></div>
<script src="../main.js"></script></body></html>

View File

@ -1,7 +1,7 @@
<!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 `prost_example` crate."><meta name="keywords" content="rust, rustlang, rust-lang, prost_example"><title>prost_example - 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><script src="../crates.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 mod"><!--[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" role="button">&#9776;</div><a href='../prost_example/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate prost_example</p><div class="block version"><p>Version 0.5.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all prost_example's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#functions">Functions</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="prost_example" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">prost_example</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#1-33" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">prost_example</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#1-33" title="goto source code">[src]</a></span></h1><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
<table><tr class="module-item"><td><a class="struct" href="struct.MyObj.html" title="prost_example::MyObj struct">MyObj</a></td><td class="docblock-short"></td></tr></table><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
<table><tr class="module-item"><td><a class="fn" href="fn.index.html" title="prost_example::index fn">index</a></td><td class="docblock-short"></td></tr><tr class="module-item"><td><a class="fn" href="fn.main.html" title="prost_example::main fn">main</a></td><td class="docblock-short"></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="prost_example" data-search-js="../search-index.js"></div>
<script src="../main.js"></script></body></html>

View File

@ -1,7 +1,7 @@
<!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 `MyObj` struct in crate `prost_example`."><meta name="keywords" content="rust, rustlang, rust-lang, MyObj"><title>prost_example::MyObj - 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><script src="../crates.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 struct"><!--[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" role="button">&#9776;</div><a href='../prost_example/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct MyObj</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#fields">Fields</a><div class="sidebar-links"><a href="#structfield.name">name</a><a href="#structfield.number">number</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-Message">Message</a><a href="#impl-PartialEq%3CMyObj%3E">PartialEq&lt;MyObj&gt;</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-Same%3CT%3E">Same&lt;T&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a><a href="#impl-VZip%3CV%3E">VZip&lt;V&gt;</a></div></div><p class="location"><a href="index.html">prost_example</a></p><div id="sidebar-vars" data-name="MyObj" data-ty="struct" 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" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">prost_example</a>::<wbr><a class="struct" href="">MyObj</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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#6-12" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct MyObj {
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">prost_example</a>::<wbr><a class="struct" href="">MyObj</a><button id="copy-path" onclick="copy_path(this)"></button></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">&#x2212;</span>]</a></span><a class="srclink" href="../src/prost_example/main.rs.html#6-12" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct MyObj {
pub number: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>,
pub name: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>,
}</pre></div><h2 id="fields" class="fields small-section-header">

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!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="Settings of Rustdoc"><meta name="keywords" content="rust, rustlang, rust-lang"><title>Rustdoc settings</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 ><link rel="stylesheet" type="text/css" href="./settings.css" ><script id="default-settings"></script><script src="./storage.js"></script><script src="./crates.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 mod"><!--[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" role="button">&#9776;</div><a href='./prost_example/index.html'><div class='logo-container rust-logo'><img src='./rust-logo.png' alt='logo'></div></a><p class="location">Settings</p><div class="sidebar-elems"></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="./brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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>
<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 mod"><!--[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" role="button">&#9776;</div><a href='./actix_redis/index.html'><div class='logo-container rust-logo'><img src='./rust-logo.png' alt='logo'></div></a><p class="location">Settings</p><div class="sidebar-elems"></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="./brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><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" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Rustdoc settings</span></h1><div class="settings"><div class="setting-line"><div class="title">Theme preferences</div><div class="sub-settings"><div class="setting-line"><label class="toggle"><input type="checkbox" id="use-system-theme" checked><span class="slider"></span></label><div>Use system theme</div></div><div class="setting-line"><div>Preferred dark theme</div><label class="select-wrapper"><select id="preferred-dark-theme" autocomplete="off"><option value="light" >light</option><option value="dark" selected>dark</option><option value="ayu" >ayu</option></select><img src="./down-arrow.svg" alt="Select item"></label></div><div class="setting-line"><div>Preferred light theme</div><label class="select-wrapper"><select id="preferred-light-theme" autocomplete="off"><option value="light" selected>light</option><option value="dark" >dark</option><option value="ayu" >ayu</option></select><img src="./down-arrow.svg" alt="Select item"></label></div></div>
</div><div class="setting-line"><div class="title">Auto-hide item declarations</div><div class="sub-settings"><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-struct" checked><span class="slider"></span></label><div>Auto-hide structs declaration</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-enum" ><span class="slider"></span></label><div>Auto-hide enums declaration</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-union" checked><span class="slider"></span></label><div>Auto-hide unions declaration</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-trait" checked><span class="slider"></span></label><div>Auto-hide traits declaration</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-macro" ><span class="slider"></span></label><div>Auto-hide macros declaration</div></div></div>
</div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-attributes" checked><span class="slider"></span></label><div>Auto-hide item attributes.</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-method-docs" ><span class="slider"></span></label><div>Auto-hide item methods' documentation</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-trait-implementations" checked><span class="slider"></span></label><div>Auto-hide trait implementation documentation</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-collapse-implementors" checked><span class="slider"></span></label><div>Auto-hide implementors of a trait</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="go-to-only-result" ><span class="slider"></span></label><div>Directly go to item in search if there is only one result</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="line-numbers" ><span class="slider"></span></label><div>Show line numbers on code examples</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="disable-shortcuts" ><span class="slider"></span></label><div>Disable keyboard shortcuts</div></div></div><script src="./settings.js"></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="./" data-current-crate="prost_example" data-search-js="./search-index.js"></div>
</div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-attributes" checked><span class="slider"></span></label><div>Auto-hide item attributes.</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-method-docs" ><span class="slider"></span></label><div>Auto-hide item methods' documentation</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-hide-trait-implementations" checked><span class="slider"></span></label><div>Auto-hide trait implementation documentation</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="auto-collapse-implementors" checked><span class="slider"></span></label><div>Auto-hide implementors of a trait</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="go-to-only-result" ><span class="slider"></span></label><div>Directly go to item in search if there is only one result</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="line-numbers" ><span class="slider"></span></label><div>Show line numbers on code examples</div></div><div class="setting-line"><label class="toggle"><input type="checkbox" id="disable-shortcuts" ><span class="slider"></span></label><div>Disable keyboard shortcuts</div></div></div><script src="./settings.js"></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="./" data-current-crate="actix_redis" data-search-js="./search-index.js"></div>
<script src="./main.js"></script></body></html>

View File

@ -68,14 +68,14 @@
<span class="doccomment">/// Default as `AllOrSome::All`.</span>
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">AllOrSome</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">default</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span>
<span class="ident">AllOrSome::All</span>
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">AllOrSome</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="doccomment">/// Returns whether this is an `All` variant.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">is_all</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">bool</span> {
<span class="macro">matches</span><span class="macro">!</span>(<span class="self">self</span>, <span class="ident">AllOrSome</span>::<span class="ident">All</span>)
<span class="macro">matches!</span>(<span class="self">self</span>, <span class="ident">AllOrSome::All</span>)
}
<span class="doccomment">/// Returns whether this is a `Some` variant.</span>
@ -87,16 +87,16 @@
<span class="doccomment">/// Provides a shared reference to `T` if variant is `Some`.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">as_ref</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">t</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">t</span>),
<span class="ident">AllOrSome::All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">AllOrSome::Some</span>(<span class="kw-2">ref</span> <span class="ident">t</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">t</span>),
}
}
<span class="doccomment">/// Provides a mutable reference to `T` if variant is `Some`.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">as_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">t</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">t</span>),
<span class="ident">AllOrSome::All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">AllOrSome::Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">t</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">t</span>),
}
}
}
@ -104,11 +104,11 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">tests</span>() {
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">AllOrSome</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span>::<span class="ident">All</span>.<span class="ident">is_all</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">AllOrSome</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span>::<span class="ident">All</span>.<span class="ident">is_some</span>());
<span class="macro">assert!</span>(<span class="ident">AllOrSome</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span><span class="ident">::All</span>.<span class="ident">is_all</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">AllOrSome</span>::<span class="op">&lt;</span>()<span class="op">&gt;</span><span class="ident">::All</span>.<span class="ident">is_some</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(()).<span class="ident">is_all</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(()).<span class="ident">is_some</span>());
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">AllOrSome::Some</span>(()).<span class="ident">is_all</span>());
<span class="macro">assert!</span>(<span class="ident">AllOrSome::Some</span>(()).<span class="ident">is_some</span>());
}
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-search-js="../../search-index.js"></div>

View File

@ -626,18 +626,18 @@
<span id="625">625</span>
<span id="626">626</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections</span>::<span class="ident">HashSet</span>, <span class="ident">convert</span>::<span class="ident">TryInto</span>, <span class="ident">iter</span>::<span class="ident">FromIterator</span>, <span class="ident">rc</span>::<span class="ident">Rc</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections::HashSet</span>, <span class="ident">convert::TryInto</span>, <span class="ident">iter::FromIterator</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">RequestHead</span>, <span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>, <span class="ident">Transform</span>},
<span class="ident">error</span>::{<span class="ident">Error</span>, <span class="prelude-ty">Result</span>},
<span class="ident">http</span>::{<span class="self">self</span>, <span class="ident">header</span>::<span class="ident">HeaderName</span>, <span class="ident">Error</span> <span class="kw">as</span> <span class="ident">HttpError</span>, <span class="ident">HeaderValue</span>, <span class="ident">Method</span>, <span class="ident">Uri</span>},
<span class="ident">http</span>::{<span class="self">self</span>, <span class="ident">header::HeaderName</span>, <span class="ident">Error</span> <span class="kw">as</span> <span class="ident">HttpError</span>, <span class="ident">HeaderValue</span>, <span class="ident">Method</span>, <span class="ident">Uri</span>},
<span class="ident">Either</span>,
};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="self">self</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">error</span>;
<span class="kw">use</span> <span class="ident">once_cell</span>::<span class="ident">sync</span>::<span class="ident">Lazy</span>;
<span class="kw">use</span> <span class="ident">tinyvec</span>::<span class="ident">tiny_vec</span>;
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="self">self</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">log::error</span>;
<span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
<span class="kw">use</span> <span class="ident">tinyvec::tiny_vec</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AllOrSome</span>, <span class="ident">CorsError</span>, <span class="ident">CorsMiddleware</span>, <span class="ident">Inner</span>, <span class="ident">OriginFn</span>};
@ -645,26 +645,26 @@
<span class="doccomment">/// Additionally, always causes first error (if any) to be reported during initialization.</span>
<span class="kw">fn</span> <span class="ident">cors</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span><span class="op">&gt;</span>(
<span class="ident">inner</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">Inner</span><span class="op">&gt;</span>,
<span class="ident">err</span>: <span class="kw-2">&amp;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http</span>::<span class="ident">Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">err</span>: <span class="kw-2">&amp;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http::Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Inner</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">err</span>.<span class="ident">is_some</span>() {
<span class="kw">return</span> <span class="prelude-val">None</span>;
}
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="ident">inner</span>)
<span class="ident">Rc::get_mut</span>(<span class="ident">inner</span>)
}
<span class="kw">static</span> <span class="ident">ALL_METHODS_SET</span>: <span class="ident">Lazy</span><span class="op">&lt;</span><span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Lazy</span>::<span class="ident">new</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">HashSet</span>::<span class="ident">from_iter</span>(<span class="macro">vec</span><span class="macro">!</span>[
<span class="ident">Method</span>::<span class="ident">GET</span>,
<span class="ident">Method</span>::<span class="ident">POST</span>,
<span class="ident">Method</span>::<span class="ident">PUT</span>,
<span class="ident">Method</span>::<span class="ident">DELETE</span>,
<span class="ident">Method</span>::<span class="ident">HEAD</span>,
<span class="ident">Method</span>::<span class="ident">OPTIONS</span>,
<span class="ident">Method</span>::<span class="ident">CONNECT</span>,
<span class="ident">Method</span>::<span class="ident">PATCH</span>,
<span class="ident">Method</span>::<span class="ident">TRACE</span>,
<span class="kw">static</span> <span class="ident">ALL_METHODS_SET</span>: <span class="ident">Lazy</span><span class="op">&lt;</span><span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Lazy::new</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">HashSet::from_iter</span>(<span class="macro">vec!</span>[
<span class="ident">Method::GET</span>,
<span class="ident">Method::POST</span>,
<span class="ident">Method::PUT</span>,
<span class="ident">Method::DELETE</span>,
<span class="ident">Method::HEAD</span>,
<span class="ident">Method::OPTIONS</span>,
<span class="ident">Method::CONNECT</span>,
<span class="ident">Method::PATCH</span>,
<span class="ident">Method::TRACE</span>,
])
});
@ -699,7 +699,7 @@
<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">Cors</span> {
<span class="ident">inner</span>: <span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">Inner</span><span class="op">&gt;</span>,
<span class="ident">error</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http</span>::<span class="ident">Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">error</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http::Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
}
<span class="kw">impl</span> <span class="ident">Cors</span> {
@ -709,16 +709,16 @@
<span class="doccomment">/// Max age 1 hour. Does not send wildcard.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">permissive</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Inner</span> {
<span class="ident">allowed_origins</span>: <span class="ident">AllOrSome</span>::<span class="ident">All</span>,
<span class="ident">allowed_origins_fns</span>: <span class="macro">tiny_vec</span><span class="macro">!</span>[],
<span class="ident">allowed_origins</span>: <span class="ident">AllOrSome::All</span>,
<span class="ident">allowed_origins_fns</span>: <span class="macro">tiny_vec!</span>[],
<span class="ident">allowed_methods</span>: <span class="ident">ALL_METHODS_SET</span>.<span class="ident">clone</span>(),
<span class="ident">allowed_methods_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">allowed_headers</span>: <span class="ident">AllOrSome</span>::<span class="ident">All</span>,
<span class="ident">allowed_headers</span>: <span class="ident">AllOrSome::All</span>,
<span class="ident">allowed_headers_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">expose_headers</span>: <span class="ident">AllOrSome</span>::<span class="ident">All</span>,
<span class="ident">expose_headers</span>: <span class="ident">AllOrSome::All</span>,
<span class="ident">expose_headers_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">max_age</span>: <span class="prelude-val">Some</span>(<span class="number">3600</span>),
<span class="ident">preflight</span>: <span class="bool-val">true</span>,
@ -728,7 +728,7 @@
};
<span class="ident">Cors</span> {
<span class="ident">inner</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">inner</span>),
<span class="ident">inner</span>: <span class="ident">Rc::new</span>(<span class="ident">inner</span>),
<span class="ident">error</span>: <span class="prelude-val">None</span>,
}
}
@ -738,7 +738,7 @@
<span class="doccomment">/// See [`Cors::allowed_origin`] for more info on allowed origins.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">allow_any_origin</span>(<span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="ident">cors</span>.<span class="ident">allowed_origins</span> <span class="op">=</span> <span class="ident">AllOrSome</span>::<span class="ident">All</span>;
<span class="ident">cors</span>.<span class="ident">allowed_origins</span> <span class="op">=</span> <span class="ident">AllOrSome::All</span>;
}
<span class="self">self</span>
@ -770,16 +770,16 @@
<span class="doccomment">/// [Fetch Standard]: https://fetch.spec.whatwg.org/#origin-header</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">allowed_origin</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">origin</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="kw">match</span> <span class="ident">TryInto</span>::<span class="op">&lt;</span><span class="ident">Uri</span><span class="op">&gt;</span>::<span class="ident">try_into</span>(<span class="ident">origin</span>) {
<span class="kw">match</span> <span class="ident">TryInto</span>::<span class="op">&lt;</span><span class="ident">Uri</span><span class="op">&gt;</span><span class="ident">::try_into</span>(<span class="ident">origin</span>) {
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) <span class="kw">if</span> <span class="ident">origin</span> <span class="op">=</span><span class="op">=</span> <span class="string">&quot;*&quot;</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;Wildcard in `allowed_origin` is not allowed. Use `send_wildcard`.&quot;</span>);
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Right</span>(<span class="ident">CorsError</span>::<span class="ident">WildcardOrigin</span>));
<span class="macro">error!</span>(<span class="string">&quot;Wildcard in `allowed_origin` is not allowed. Use `send_wildcard`.&quot;</span>);
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Right</span>(<span class="ident">CorsError::WildcardOrigin</span>));
}
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">cors</span>.<span class="ident">allowed_origins</span>.<span class="ident">is_all</span>() {
<span class="ident">cors</span>.<span class="ident">allowed_origins</span> <span class="op">=</span>
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>));
<span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">origins</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">allowed_origins</span>.<span class="ident">as_mut</span>() {
@ -790,7 +790,7 @@
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
}
}
}
@ -812,7 +812,7 @@
{
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="ident">cors</span>.<span class="ident">allowed_origins_fns</span>.<span class="ident">push</span>(<span class="ident">OriginFn</span> {
<span class="ident">boxed_fn</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">f</span>),
<span class="ident">boxed_fn</span>: <span class="ident">Rc::new</span>(<span class="ident">f</span>),
});
}
@ -842,7 +842,7 @@
<span class="kw">where</span>
<span class="ident">U</span>: <span class="ident">IntoIterator</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">M</span><span class="op">&gt;</span>,
<span class="ident">M</span>: <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">M</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span><span class="op">&gt;</span>::<span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">M</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="ident">::Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
{
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="kw">for</span> <span class="ident">m</span> <span class="kw">in</span> <span class="ident">methods</span> {
@ -852,7 +852,7 @@
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="kw">break</span>;
}
}
@ -867,7 +867,7 @@
<span class="doccomment">/// See [`Cors::allowed_headers`] for more info on allowed request headers.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">allow_any_header</span>(<span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="ident">cors</span>.<span class="ident">allowed_headers</span> <span class="op">=</span> <span class="ident">AllOrSome</span>::<span class="ident">All</span>;
<span class="ident">cors</span>.<span class="ident">allowed_headers</span> <span class="op">=</span> <span class="ident">AllOrSome::All</span>;
}
<span class="self">self</span>
@ -879,22 +879,22 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">allowed_header</span><span class="op">&lt;</span><span class="ident">H</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">header</span>: <span class="ident">H</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span>
<span class="kw">where</span>
<span class="ident">H</span>: <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span>::<span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="ident">::Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
{
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="kw">match</span> <span class="ident">header</span>.<span class="ident">try_into</span>() {
<span class="prelude-val">Ok</span>(<span class="ident">method</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span>.<span class="ident">is_all</span>() {
<span class="ident">cors</span>.<span class="ident">allowed_headers</span> <span class="op">=</span>
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>));
<span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome::Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span> {
<span class="ident">headers</span>.<span class="ident">insert</span>(<span class="ident">method</span>);
}
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>.<span class="ident">into</span>())),
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Left</span>(<span class="ident">err</span>.<span class="ident">into</span>())),
}
}
@ -915,7 +915,7 @@
<span class="kw">where</span>
<span class="ident">U</span>: <span class="ident">IntoIterator</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">H</span><span class="op">&gt;</span>,
<span class="ident">H</span>: <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span>::<span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="ident">::Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
{
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="kw">for</span> <span class="ident">h</span> <span class="kw">in</span> <span class="ident">headers</span> {
@ -923,15 +923,15 @@
<span class="prelude-val">Ok</span>(<span class="ident">method</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span>.<span class="ident">is_all</span>() {
<span class="ident">cors</span>.<span class="ident">allowed_headers</span> <span class="op">=</span>
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>));
<span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome::Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">allowed_headers</span> {
<span class="ident">headers</span>.<span class="ident">insert</span>(<span class="ident">method</span>);
}
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="kw">break</span>;
}
}
@ -946,7 +946,7 @@
<span class="doccomment">/// See [`Cors::expose_headers`] for more info on exposed response headers.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">expose_any_header</span>(<span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="ident">cors</span>.<span class="ident">expose_headers</span> <span class="op">=</span> <span class="ident">AllOrSome</span>::<span class="ident">All</span>;
<span class="ident">cors</span>.<span class="ident">expose_headers</span> <span class="op">=</span> <span class="ident">AllOrSome::All</span>;
}
<span class="self">self</span>
@ -963,7 +963,7 @@
<span class="kw">where</span>
<span class="ident">U</span>: <span class="ident">IntoIterator</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">H</span><span class="op">&gt;</span>,
<span class="ident">H</span>: <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span>::<span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
<span class="op">&lt;</span><span class="ident">H</span> <span class="kw">as</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="ident">::Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">HttpError</span><span class="op">&gt;</span>,
{
<span class="kw">for</span> <span class="ident">h</span> <span class="kw">in</span> <span class="ident">headers</span> {
<span class="kw">match</span> <span class="ident">h</span>.<span class="ident">try_into</span>() {
@ -971,15 +971,15 @@
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cors</span>) <span class="op">=</span> <span class="ident">cors</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">inner</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">error</span>) {
<span class="kw">if</span> <span class="ident">cors</span>.<span class="ident">expose_headers</span>.<span class="ident">is_all</span>() {
<span class="ident">cors</span>.<span class="ident">expose_headers</span> <span class="op">=</span>
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>));
<span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">expose_headers</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AllOrSome::Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">expose_headers</span> {
<span class="ident">headers</span>.<span class="ident">insert</span>(<span class="ident">header</span>);
}
}
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="self">self</span>.<span class="ident">error</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">Either::Left</span>(<span class="ident">err</span>.<span class="ident">into</span>()));
<span class="kw">break</span>;
}
}
@ -1085,16 +1085,16 @@
<span class="doccomment">/// not supported. No max age (will use browser&#39;s default).</span>
<span class="kw">fn</span> <span class="ident">default</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cors</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Inner</span> {
<span class="ident">allowed_origins</span>: <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>)),
<span class="ident">allowed_origins_fns</span>: <span class="macro">tiny_vec</span><span class="macro">!</span>[],
<span class="ident">allowed_origins</span>: <span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>)),
<span class="ident">allowed_origins_fns</span>: <span class="macro">tiny_vec!</span>[],
<span class="ident">allowed_methods</span>: <span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>),
<span class="ident">allowed_methods</span>: <span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>),
<span class="ident">allowed_methods_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">allowed_headers</span>: <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>)),
<span class="ident">allowed_headers</span>: <span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>)),
<span class="ident">allowed_headers_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">expose_headers</span>: <span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>)),
<span class="ident">expose_headers</span>: <span class="ident">AllOrSome::Some</span>(<span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>)),
<span class="ident">expose_headers_baked</span>: <span class="prelude-val">None</span>,
<span class="ident">max_age</span>: <span class="prelude-val">None</span>,
@ -1105,7 +1105,7 @@
};
<span class="ident">Cors</span> {
<span class="ident">inner</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">inner</span>),
<span class="ident">inner</span>: <span class="ident">Rc::new</span>(<span class="ident">inner</span>),
<span class="ident">error</span>: <span class="prelude-val">None</span>,
}
}
@ -1114,41 +1114,41 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Transform</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Cors</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">InitError</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Transform</span> <span class="op">=</span> <span class="ident">CorsMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Transform</span>, <span class="self">Self</span>::<span class="ident">InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Transform</span>, <span class="self">Self</span><span class="ident">::InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">err</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">error</span> {
<span class="kw">match</span> <span class="ident">err</span> {
<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>),
<span class="ident">Either</span>::<span class="ident">Right</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>),
<span class="ident">Either::Left</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">error!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>),
<span class="ident">Either::Right</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="macro">error!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">err</span>),
}
<span class="kw">return</span> <span class="ident">future</span>::<span class="ident">err</span>(());
<span class="kw">return</span> <span class="ident">future::err</span>(());
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">supports_credentials</span>
<span class="op">&amp;&amp;</span> <span class="ident">inner</span>.<span class="ident">send_wildcard</span>
<span class="op">&amp;&amp;</span> <span class="ident">inner</span>.<span class="ident">allowed_origins</span>.<span class="ident">is_all</span>()
{
<span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;Illegal combination of CORS options: credentials can not be supported when all \
<span class="macro">error!</span>(<span class="string">&quot;Illegal combination of CORS options: credentials can not be supported when all \
origins are allowed and `send_wildcard` is enabled.&quot;</span>);
<span class="kw">return</span> <span class="ident">future</span>::<span class="ident">err</span>(());
<span class="kw">return</span> <span class="ident">future::err</span>(());
}
<span class="comment">// bake allowed headers value if Some and not empty</span>
<span class="kw">match</span> <span class="ident">inner</span>.<span class="ident">allowed_headers</span>.<span class="ident">as_ref</span>() {
<span class="prelude-val">Some</span>(<span class="ident">header_set</span>) <span class="kw">if</span> <span class="op">!</span><span class="ident">header_set</span>.<span class="ident">is_empty</span>() <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">allowed_headers_str</span> <span class="op">=</span> <span class="ident">intersperse_header_values</span>(<span class="ident">header_set</span>);
<span class="ident">Rc</span>::<span class="ident">make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">allowed_headers_baked</span> <span class="op">=</span>
<span class="ident">Rc::make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">allowed_headers_baked</span> <span class="op">=</span>
<span class="prelude-val">Some</span>(<span class="ident">allowed_headers_str</span>);
}
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> {}
@ -1157,19 +1157,19 @@
<span class="comment">// bake allowed methods value if not empty</span>
<span class="kw">if</span> <span class="op">!</span><span class="ident">inner</span>.<span class="ident">allowed_methods</span>.<span class="ident">is_empty</span>() {
<span class="kw">let</span> <span class="ident">allowed_methods_str</span> <span class="op">=</span> <span class="ident">intersperse_header_values</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>.<span class="ident">allowed_methods</span>);
<span class="ident">Rc</span>::<span class="ident">make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">allowed_methods_baked</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">allowed_methods_str</span>);
<span class="ident">Rc::make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">allowed_methods_baked</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">allowed_methods_str</span>);
}
<span class="comment">// bake exposed headers value if Some and not empty</span>
<span class="kw">match</span> <span class="ident">inner</span>.<span class="ident">expose_headers</span>.<span class="ident">as_ref</span>() {
<span class="prelude-val">Some</span>(<span class="ident">header_set</span>) <span class="kw">if</span> <span class="op">!</span><span class="ident">header_set</span>.<span class="ident">is_empty</span>() <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">expose_headers_str</span> <span class="op">=</span> <span class="ident">intersperse_header_values</span>(<span class="ident">header_set</span>);
<span class="ident">Rc</span>::<span class="ident">make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">expose_headers_baked</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">expose_headers_str</span>);
<span class="ident">Rc::make_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">inner</span>).<span class="ident">expose_headers_baked</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">expose_headers_str</span>);
}
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> {}
}
<span class="ident">future</span>::<span class="ident">ok</span>(<span class="ident">CorsMiddleware</span> { <span class="ident">service</span>, <span class="ident">inner</span> })
<span class="ident">future::ok</span>(<span class="ident">CorsMiddleware</span> { <span class="ident">service</span>, <span class="ident">inner</span> })
}
}
@ -1180,7 +1180,7 @@
{
<span class="ident">val_set</span>
.<span class="ident">iter</span>()
.<span class="ident">fold</span>(<span class="ident">String</span>::<span class="ident">with_capacity</span>(<span class="number">32</span>), <span class="op">|</span><span class="kw-2">mut</span> <span class="ident">acc</span>, <span class="ident">val</span><span class="op">|</span> {
.<span class="ident">fold</span>(<span class="ident">String::with_capacity</span>(<span class="number">32</span>), <span class="op">|</span><span class="kw-2">mut</span> <span class="ident">acc</span>, <span class="ident">val</span><span class="op">|</span> {
<span class="ident">acc</span>.<span class="ident">push_str</span>(<span class="string">&quot;, &quot;</span>);
<span class="ident">acc</span>.<span class="ident">push_str</span>(<span class="ident">val</span>.<span class="ident">as_ref</span>());
<span class="ident">acc</span>
@ -1194,10 +1194,10 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">test</span> {
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">convert</span>::{<span class="ident">Infallible</span>, <span class="ident">TryInto</span>};
<span class="kw">use</span> <span class="ident">std::convert</span>::{<span class="ident">Infallible</span>, <span class="ident">TryInto</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::<span class="ident">Transform</span>,
<span class="ident">dev::Transform</span>,
<span class="ident">http</span>::{<span class="ident">HeaderName</span>, <span class="ident">StatusCode</span>},
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
};
@ -1209,47 +1209,47 @@
<span class="comment">// using the permissive defaults (all origins allowed) and adding send_wildcard</span>
<span class="comment">// and supports_credentials should error on construction</span>
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Cors</span>::<span class="ident">permissive</span>()
<span class="macro">assert!</span>(<span class="ident">Cors::permissive</span>()
.<span class="ident">supports_credentials</span>()
.<span class="ident">send_wildcard</span>()
.<span class="ident">new_transform</span>(<span class="ident">test</span>::<span class="ident">ok_service</span>())
.<span class="ident">new_transform</span>(<span class="ident">test::ok_service</span>())
.<span class="ident">into_inner</span>()
.<span class="ident">is_err</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">restrictive_defaults</span>() {
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
.<span class="ident">new_transform</span>(<span class="ident">test</span>::<span class="ident">ok_service</span>())
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">new_transform</span>(<span class="ident">test::ok_service</span>())
.<span class="kw">await</span>
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>()
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>()
.<span class="ident">insert_header</span>((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">BAD_REQUEST</span>);
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::BAD_REQUEST</span>);
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">allowed_header_try_from</span>() {
<span class="kw">let</span> <span class="ident">_cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>().<span class="ident">allowed_header</span>(<span class="string">&quot;Content-Type&quot;</span>);
<span class="kw">let</span> <span class="ident">_cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>().<span class="ident">allowed_header</span>(<span class="string">&quot;Content-Type&quot;</span>);
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">allowed_header_try_into</span>() {
<span class="kw">struct</span> <span class="ident">ContentType</span>;
<span class="kw">impl</span> <span class="ident">TryInto</span><span class="op">&lt;</span><span class="ident">HeaderName</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ContentType</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Infallible</span>;
<span class="kw">fn</span> <span class="ident">try_into</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">HeaderName</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span> {
<span class="prelude-val">Ok</span>(<span class="ident">HeaderName</span>::<span class="ident">from_static</span>(<span class="string">&quot;content-type&quot;</span>))
<span class="kw">fn</span> <span class="ident">try_into</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">HeaderName</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span> {
<span class="prelude-val">Ok</span>(<span class="ident">HeaderName::from_static</span>(<span class="string">&quot;content-type&quot;</span>))
}
}
<span class="kw">let</span> <span class="ident">_cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>().<span class="ident">allowed_header</span>(<span class="ident">ContentType</span>);
<span class="kw">let</span> <span class="ident">_cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>().<span class="ident">allowed_header</span>(<span class="ident">ContentType</span>);
}
}
</pre></div>

View File

@ -56,7 +56,7 @@
<span id="55">55</span>
<span id="56">56</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">http</span>::<span class="ident">StatusCode</span>, <span class="ident">HttpResponse</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">http::StatusCode</span>, <span class="ident">HttpResponse</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">derive_more</span>::{<span class="ident">Display</span>, <span class="ident">Error</span>};
@ -105,11 +105,11 @@
<span class="kw">impl</span> <span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">CorsError</span> {
<span class="kw">fn</span> <span class="ident">status_code</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">StatusCode</span> {
<span class="ident">StatusCode</span>::<span class="ident">BAD_REQUEST</span>
<span class="ident">StatusCode::BAD_REQUEST</span>
}
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="ident">HttpResponse</span>::<span class="ident">with_body</span>(<span class="ident">StatusCode</span>::<span class="ident">BAD_REQUEST</span>, <span class="self">self</span>.<span class="ident">to_string</span>().<span class="ident">into</span>())
<span class="ident">HttpResponse::with_body</span>(<span class="ident">StatusCode::BAD_REQUEST</span>, <span class="self">self</span>.<span class="ident">to_string</span>().<span class="ident">into</span>())
}
}
</pre></div>

View File

@ -338,18 +338,18 @@
<span id="337">337</span>
<span id="338">338</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections</span>::<span class="ident">HashSet</span>, <span class="ident">convert</span>::<span class="ident">TryFrom</span>, <span class="ident">convert</span>::<span class="ident">TryInto</span>, <span class="ident">fmt</span>, <span class="ident">rc</span>::<span class="ident">Rc</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections::HashSet</span>, <span class="ident">convert::TryFrom</span>, <span class="ident">convert::TryInto</span>, <span class="ident">fmt</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::<span class="ident">RequestHead</span>,
<span class="ident">error</span>::<span class="prelude-ty">Result</span>,
<span class="ident">dev::RequestHead</span>,
<span class="ident">error::Result</span>,
<span class="ident">http</span>::{
<span class="ident">header</span>::{<span class="self">self</span>, <span class="ident">HeaderName</span>, <span class="ident">HeaderValue</span>},
<span class="ident">Method</span>,
},
};
<span class="kw">use</span> <span class="ident">once_cell</span>::<span class="ident">sync</span>::<span class="ident">Lazy</span>;
<span class="kw">use</span> <span class="ident">tinyvec</span>::<span class="ident">TinyVec</span>;
<span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
<span class="kw">use</span> <span class="ident">tinyvec::TinyVec</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AllOrSome</span>, <span class="ident">CorsError</span>};
@ -361,13 +361,13 @@
<span class="kw">impl</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">OriginFn</span> {
<span class="doccomment">/// Dummy default for use in tiny_vec. Do not use.</span>
<span class="kw">fn</span> <span class="ident">default</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="kw">let</span> <span class="ident">boxed_fn</span>: <span class="ident">Rc</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw">_</span>, <span class="kw-2">&amp;</span><span class="kw">_</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">_origin</span>, <span class="ident">_req_head</span><span class="op">|</span> <span class="bool-val">false</span>);
<span class="kw">let</span> <span class="ident">boxed_fn</span>: <span class="ident">Rc</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="kw">_</span>, <span class="kw-2">&amp;</span><span class="kw">_</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Rc::new</span>(<span class="op">|</span><span class="ident">_origin</span>, <span class="ident">_req_head</span><span class="op">|</span> <span class="bool-val">false</span>);
<span class="self">Self</span> { <span class="ident">boxed_fn</span> }
}
}
<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">OriginFn</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
<span class="kw">impl</span> <span class="ident">fmt::Debug</span> <span class="kw">for</span> <span class="ident">OriginFn</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt::Result</span> {
<span class="ident">f</span>.<span class="ident">write_str</span>(<span class="string">&quot;origin_fn&quot;</span>)
}
}
@ -376,7 +376,7 @@
<span class="kw">fn</span> <span class="ident">header_value_try_into_method</span>(<span class="ident">hdr</span>: <span class="kw-2">&amp;</span><span class="ident">HeaderValue</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Method</span><span class="op">&gt;</span> {
<span class="ident">hdr</span>.<span class="ident">to_str</span>()
.<span class="ident">ok</span>()
.<span class="ident">and_then</span>(<span class="op">|</span><span class="ident">meth</span><span class="op">|</span> <span class="ident">Method</span>::<span class="ident">try_from</span>(<span class="ident">meth</span>).<span class="ident">ok</span>())
.<span class="ident">and_then</span>(<span class="op">|</span><span class="ident">meth</span><span class="op">|</span> <span class="ident">Method::try_from</span>(<span class="ident">meth</span>).<span class="ident">ok</span>())
}
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
@ -401,21 +401,21 @@
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="ident">vary_header</span>: <span class="ident">bool</span>,
}
<span class="kw">static</span> <span class="ident">EMPTY_ORIGIN_SET</span>: <span class="ident">Lazy</span><span class="op">&lt;</span><span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">HeaderValue</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Lazy</span>::<span class="ident">new</span>(<span class="ident">HashSet</span>::<span class="ident">new</span>);
<span class="kw">static</span> <span class="ident">EMPTY_ORIGIN_SET</span>: <span class="ident">Lazy</span><span class="op">&lt;</span><span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">HeaderValue</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Lazy::new</span>(<span class="ident">HashSet::new</span>);
<span class="kw">impl</span> <span class="ident">Inner</span> {
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn</span> <span class="ident">validate_origin</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">RequestHead</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">CorsError</span><span class="op">&gt;</span> {
<span class="comment">// return early if all origins are allowed or get ref to allowed origins set</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">mutable_key_type</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::mutable_key_type</span>)]</span>
<span class="kw">let</span> <span class="ident">allowed_origins</span> <span class="op">=</span> <span class="kw">match</span> <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">allowed_origins</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span> <span class="kw">if</span> <span class="self">self</span>.<span class="ident">allowed_origins_fns</span>.<span class="ident">is_empty</span>() <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Ok</span>(()),
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">allowed_origins</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">allowed_origins</span>,
<span class="ident">AllOrSome::All</span> <span class="kw">if</span> <span class="self">self</span>.<span class="ident">allowed_origins_fns</span>.<span class="ident">is_empty</span>() <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Ok</span>(()),
<span class="ident">AllOrSome::Some</span>(<span class="ident">allowed_origins</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">allowed_origins</span>,
<span class="comment">// only function origin validators are defined</span>
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="kw-2">&amp;</span><span class="ident">EMPTY_ORIGIN_SET</span>,
};
<span class="comment">// get origin header and try to parse as string</span>
<span class="kw">match</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ORIGIN</span>) {
<span class="kw">match</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::ORIGIN</span>) {
<span class="comment">// origin header exists and is a string</span>
<span class="prelude-val">Some</span>(<span class="ident">origin</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">allowed_origins</span>.<span class="ident">contains</span>(<span class="ident">origin</span>)
@ -423,14 +423,14 @@
{
<span class="prelude-val">Ok</span>(())
} <span class="kw">else</span> {
<span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">OriginNotAllowed</span>)
<span class="prelude-val">Err</span>(<span class="ident">CorsError::OriginNotAllowed</span>)
}
}
<span class="comment">// origin header is missing</span>
<span class="comment">// note: with our implementation, the origin header is required for OPTIONS request or</span>
<span class="comment">// else this would be unreachable</span>
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">MissingOrigin</span>),
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::MissingOrigin</span>),
}
}
@ -446,19 +446,19 @@
<span class="kw-2">&amp;</span><span class="self">self</span>,
<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">RequestHead</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">HeaderValue</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">origin</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ORIGIN</span>);
<span class="kw">let</span> <span class="ident">origin</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::ORIGIN</span>);
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">allowed_origins</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">AllOrSome::All</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">send_wildcard</span> {
<span class="prelude-val">Some</span>(<span class="ident">HeaderValue</span>::<span class="ident">from_static</span>(<span class="string">&quot;*&quot;</span>))
<span class="prelude-val">Some</span>(<span class="ident">HeaderValue::from_static</span>(<span class="string">&quot;*&quot;</span>))
} <span class="kw">else</span> {
<span class="comment">// see note below about why `.cloned()` is correct</span>
<span class="ident">origin</span>.<span class="ident">cloned</span>()
}
}
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">AllOrSome::Some</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="comment">// since origin (if it exists) is known to be allowed if this method is called</span>
<span class="comment">// then cloning the option is all that is required to be used as an echoed back</span>
<span class="comment">// header value (or omitted if None)</span>
@ -476,7 +476,7 @@
<span class="comment">// extract access control header and try to parse as method</span>
<span class="kw">let</span> <span class="ident">request_method</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_METHOD</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_REQUEST_METHOD</span>)
.<span class="ident">map</span>(<span class="ident">header_value_try_into_method</span>);
<span class="kw">match</span> <span class="ident">request_method</span> {
@ -484,13 +484,13 @@
<span class="prelude-val">Some</span>(<span class="prelude-val">Some</span>(<span class="ident">method</span>)) <span class="kw">if</span> <span class="self">self</span>.<span class="ident">allowed_methods</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">method</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(()),
<span class="comment">// method valid but not allowed</span>
<span class="prelude-val">Some</span>(<span class="prelude-val">Some</span>(<span class="kw">_</span>)) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">MethodNotAllowed</span>),
<span class="prelude-val">Some</span>(<span class="prelude-val">Some</span>(<span class="kw">_</span>)) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::MethodNotAllowed</span>),
<span class="comment">// method invalid</span>
<span class="prelude-val">Some</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">BadRequestMethod</span>),
<span class="prelude-val">Some</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::BadRequestMethod</span>),
<span class="comment">// method missing</span>
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">MissingRequestMethod</span>),
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::MissingRequestMethod</span>),
}
}
@ -499,17 +499,17 @@
<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">RequestHead</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">CorsError</span><span class="op">&gt;</span> {
<span class="comment">// return early if all headers are allowed or get ref to allowed origins set</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">mutable_key_type</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::mutable_key_type</span>)]</span>
<span class="kw">let</span> <span class="ident">allowed_headers</span> <span class="op">=</span> <span class="kw">match</span> <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">allowed_headers</span> {
<span class="ident">AllOrSome</span>::<span class="ident">All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Ok</span>(()),
<span class="ident">AllOrSome</span>::<span class="prelude-val">Some</span>(<span class="ident">allowed_headers</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">allowed_headers</span>,
<span class="ident">AllOrSome::All</span> <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Ok</span>(()),
<span class="ident">AllOrSome::Some</span>(<span class="ident">allowed_headers</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">allowed_headers</span>,
};
<span class="comment">// extract access control header as string</span>
<span class="comment">// header format should be comma separated header names</span>
<span class="kw">let</span> <span class="ident">request_headers</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">hdr</span><span class="op">|</span> <span class="ident">hdr</span>.<span class="ident">to_str</span>());
<span class="kw">match</span> <span class="ident">request_headers</span> {
@ -517,32 +517,32 @@
<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(<span class="ident">headers</span>)) <span class="op">=</span><span class="op">&gt;</span> {
<span class="comment">// the set is ephemeral we take care not to mutate the</span>
<span class="comment">// inserted keys so this lint exception is acceptable</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">mutable_key_type</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">request_headers</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">8</span>);
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::mutable_key_type</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">request_headers</span> <span class="op">=</span> <span class="ident">HashSet::with_capacity</span>(<span class="number">8</span>);
<span class="comment">// try to convert each header name in the comma-separated list</span>
<span class="kw">for</span> <span class="ident">hdr</span> <span class="kw">in</span> <span class="ident">headers</span>.<span class="ident">split</span>(<span class="string">&#39;,&#39;</span>) {
<span class="kw">match</span> <span class="ident">hdr</span>.<span class="ident">trim</span>().<span class="ident">try_into</span>() {
<span class="prelude-val">Ok</span>(<span class="ident">hdr</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">request_headers</span>.<span class="ident">insert</span>(<span class="ident">hdr</span>),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">BadRequestHeaders</span>),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::BadRequestHeaders</span>),
};
}
<span class="comment">// header list must contain 1 or more header name</span>
<span class="kw">if</span> <span class="ident">request_headers</span>.<span class="ident">is_empty</span>() {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">BadRequestHeaders</span>);
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::BadRequestHeaders</span>);
}
<span class="comment">// request header list must be a subset of allowed headers</span>
<span class="kw">if</span> <span class="op">!</span><span class="ident">request_headers</span>.<span class="ident">is_subset</span>(<span class="ident">allowed_headers</span>) {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">HeadersNotAllowed</span>);
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::HeadersNotAllowed</span>);
}
<span class="prelude-val">Ok</span>(())
}
<span class="comment">// header list is not a string</span>
<span class="prelude-val">Some</span>(<span class="prelude-val">Err</span>(<span class="kw">_</span>)) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError</span>::<span class="ident">BadRequestHeaders</span>),
<span class="prelude-val">Some</span>(<span class="prelude-val">Err</span>(<span class="kw">_</span>)) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">CorsError::BadRequestHeaders</span>),
<span class="comment">// header list missing</span>
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(()),
@ -552,128 +552,128 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">test</span> {
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Rc</span>;
<span class="kw">use</span> <span class="ident">std::rc::Rc</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::<span class="ident">Transform</span>,
<span class="ident">dev::Transform</span>,
<span class="ident">http</span>::{<span class="ident">header</span>, <span class="ident">HeaderValue</span>, <span class="ident">Method</span>, <span class="ident">StatusCode</span>},
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
};
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">Cors</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::Cors</span>;
<span class="kw">fn</span> <span class="ident">val_as_str</span>(<span class="ident">val</span>: <span class="kw-2">&amp;</span><span class="ident">HeaderValue</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw-2">&amp;</span><span class="ident">str</span> {
<span class="ident">val</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>()
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_validate_not_allowed_origin</span>() {
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">allowed_origin</span>(<span class="string">&quot;https://www.example.com&quot;</span>)
.<span class="ident">new_transform</span>(<span class="ident">test</span>::<span class="ident">ok_service</span>())
.<span class="ident">new_transform</span>(<span class="ident">test::ok_service</span>())
.<span class="kw">await</span>
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ORIGIN</span>, <span class="string">&quot;https://www.unknown.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>, <span class="string">&quot;DNT&quot;</span>))
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header::ORIGIN</span>, <span class="string">&quot;https://www.unknown.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>, <span class="string">&quot;DNT&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_origin</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_origin</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_preflight</span>() {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">allow_any_origin</span>()
.<span class="ident">send_wildcard</span>()
.<span class="ident">max_age</span>(<span class="number">3600</span>)
.<span class="ident">allowed_methods</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">Method</span>::<span class="ident">GET</span>, <span class="ident">Method</span>::<span class="ident">OPTIONS</span>, <span class="ident">Method</span>::<span class="ident">POST</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="ident">header</span>::<span class="ident">AUTHORIZATION</span>, <span class="ident">header</span>::<span class="ident">ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>)
.<span class="ident">new_transform</span>(<span class="ident">test</span>::<span class="ident">ok_service</span>())
.<span class="ident">allowed_methods</span>(<span class="macro">vec!</span>[<span class="ident">Method::GET</span>, <span class="ident">Method::OPTIONS</span>, <span class="ident">Method::POST</span>])
.<span class="ident">allowed_headers</span>(<span class="macro">vec!</span>[<span class="ident">header::AUTHORIZATION</span>, <span class="ident">header::ACCEPT</span>])
.<span class="ident">allowed_header</span>(<span class="ident">header::CONTENT_TYPE</span>)
.<span class="ident">new_transform</span>(<span class="ident">test::ok_service</span>())
.<span class="kw">await</span>
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>()
.<span class="ident">method</span>(<span class="ident">Method</span>::<span class="ident">OPTIONS</span>)
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>()
.<span class="ident">method</span>(<span class="ident">Method::OPTIONS</span>)
.<span class="ident">insert_header</span>((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>, <span class="string">&quot;X-Not-Allowed&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>, <span class="string">&quot;X-Not-Allowed&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">BAD_REQUEST</span>);
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::BAD_REQUEST</span>);
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>()
.<span class="ident">method</span>(<span class="ident">Method</span>::<span class="ident">OPTIONS</span>)
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>()
.<span class="ident">method</span>(<span class="ident">Method::OPTIONS</span>)
.<span class="ident">insert_header</span>((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;put&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;put&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_ok</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_method</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_err</span>());
<span class="macro">assert!</span>(<span class="ident">cors</span>.<span class="ident">inner</span>.<span class="ident">validate_allowed_headers</span>(<span class="ident">req</span>.<span class="ident">head</span>()).<span class="ident">is_ok</span>());
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>()
.<span class="ident">method</span>(<span class="ident">Method</span>::<span class="ident">OPTIONS</span>)
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>()
.<span class="ident">method</span>(<span class="ident">Method::OPTIONS</span>)
.<span class="ident">insert_header</span>((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;POST&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;POST&quot;</span>))
.<span class="ident">insert_header</span>((
<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>,
<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>,
<span class="string">&quot;AUTHORIZATION,ACCEPT&quot;</span>,
))
.<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(
<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b&quot;*&quot;</span>[..]),
<span class="ident">resp</span>.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue</span>::<span class="ident">as_bytes</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue::as_bytes</span>)
);
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b&quot;3600&quot;</span>[..]),
<span class="ident">resp</span>.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_MAX_AGE</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue</span>::<span class="ident">as_bytes</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_MAX_AGE</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue::as_bytes</span>)
);
<span class="kw">let</span> <span class="ident">hdr</span> <span class="op">=</span> <span class="ident">resp</span>
.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_HEADERS</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_HEADERS</span>)
.<span class="ident">map</span>(<span class="ident">val_as_str</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;authorization&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;accept&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;content-type&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;authorization&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;accept&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">hdr</span>.<span class="ident">contains</span>(<span class="string">&quot;content-type&quot;</span>));
<span class="kw">let</span> <span class="ident">methods</span> <span class="op">=</span> <span class="ident">resp</span>
.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_METHODS</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_METHODS</span>)
.<span class="ident">unwrap</span>()
.<span class="ident">to_str</span>()
.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;POST&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;GET&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;OPTIONS&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;POST&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;GET&quot;</span>));
<span class="macro">assert!</span>(<span class="ident">methods</span>.<span class="ident">contains</span>(<span class="string">&quot;OPTIONS&quot;</span>));
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">cors</span>.<span class="ident">inner</span>).<span class="ident">unwrap</span>().<span class="ident">preflight</span> <span class="op">=</span> <span class="bool-val">false</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">cors</span>.<span class="ident">inner</span>).<span class="ident">unwrap</span>().<span class="ident">preflight</span> <span class="op">=</span> <span class="bool-val">false</span>;
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>()
.<span class="ident">method</span>(<span class="ident">Method</span>::<span class="ident">OPTIONS</span>)
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>()
.<span class="ident">method</span>(<span class="ident">Method::OPTIONS</span>)
.<span class="ident">insert_header</span>((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;POST&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_REQUEST_METHOD</span>, <span class="string">&quot;POST&quot;</span>))
.<span class="ident">insert_header</span>((
<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>,
<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>,
<span class="string">&quot;AUTHORIZATION,ACCEPT&quot;</span>,
))
.<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">cors</span>, <span class="ident">req</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
}
}
</pre></div>

View File

@ -115,11 +115,11 @@
<span class="kw">mod</span> <span class="ident">inner</span>;
<span class="kw">mod</span> <span class="ident">middleware</span>;
<span class="kw">use</span> <span class="ident">all_or_some</span>::<span class="ident">AllOrSome</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">builder</span>::<span class="ident">Cors</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">error</span>::<span class="ident">CorsError</span>;
<span class="kw">use</span> <span class="ident">all_or_some::AllOrSome</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">builder::Cors</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">error::CorsError</span>;
<span class="kw">use</span> <span class="ident">inner</span>::{<span class="ident">Inner</span>, <span class="ident">OriginFn</span>};
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">middleware</span>::<span class="ident">CorsMiddleware</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">middleware::CorsMiddleware</span>;
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-search-js="../../search-index.js"></div>
<script src="../../main.js"></script><script src="../../source-script.js"></script><script src="../../source-files.js"></script></body></html>

View File

@ -217,7 +217,7 @@
<span id="216">216</span>
<span id="217">217</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">convert</span>::<span class="ident">TryInto</span>, <span class="ident">rc</span>::<span class="ident">Rc</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">convert::TryInto</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
@ -228,10 +228,10 @@
},
<span class="ident">HttpResponse</span>,
};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ok</span>, <span class="ident">Either</span>, <span class="ident">FutureExt</span> <span class="kw">as</span> <span class="kw">_</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">debug</span>;
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ok</span>, <span class="ident">Either</span>, <span class="ident">FutureExt</span> <span class="kw">as</span> <span class="kw">_</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">log::debug</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">Inner</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::Inner</span>;
<span class="doccomment">/// Service wrapper for Cross-Origin Resource Sharing support.</span>
<span class="doccomment">///</span>
@ -254,37 +254,37 @@
<span class="kw">return</span> <span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>);
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">HttpResponse::Ok</span>();
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">origin</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">access_control_allow_origin</span>(<span class="ident">req</span>.<span class="ident">head</span>()) {
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_ORIGIN</span>, <span class="ident">origin</span>));
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_ALLOW_ORIGIN</span>, <span class="ident">origin</span>));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">allowed_methods</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">allowed_methods_baked</span> {
<span class="ident">res</span>.<span class="ident">insert_header</span>((
<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_METHODS</span>,
<span class="ident">header::ACCESS_CONTROL_ALLOW_METHODS</span>,
<span class="ident">allowed_methods</span>.<span class="ident">clone</span>(),
));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">headers</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">allowed_headers_baked</span> {
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_HEADERS</span>, <span class="ident">headers</span>.<span class="ident">clone</span>()));
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_ALLOW_HEADERS</span>, <span class="ident">headers</span>.<span class="ident">clone</span>()));
} <span class="kw">else</span> <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">headers</span>) <span class="op">=</span>
<span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_REQUEST_HEADERS</span>)
<span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_REQUEST_HEADERS</span>)
{
<span class="comment">// all headers allowed, return</span>
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_HEADERS</span>, <span class="ident">headers</span>.<span class="ident">clone</span>()));
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_ALLOW_HEADERS</span>, <span class="ident">headers</span>.<span class="ident">clone</span>()));
}
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">supports_credentials</span> {
<span class="ident">res</span>.<span class="ident">insert_header</span>((
<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_CREDENTIALS</span>,
<span class="ident">HeaderValue</span>::<span class="ident">from_static</span>(<span class="string">&quot;true&quot;</span>),
<span class="ident">header::ACCESS_CONTROL_ALLOW_CREDENTIALS</span>,
<span class="ident">HeaderValue::from_static</span>(<span class="string">&quot;true&quot;</span>),
));
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">max_age</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">max_age</span> {
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_MAX_AGE</span>, <span class="ident">max_age</span>.<span class="ident">to_string</span>()));
<span class="ident">res</span>.<span class="ident">insert_header</span>((<span class="ident">header::ACCESS_CONTROL_MAX_AGE</span>, <span class="ident">max_age</span>.<span class="ident">to_string</span>()));
}
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">res</span>.<span class="ident">finish</span>();
@ -298,33 +298,33 @@
) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">origin</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">access_control_allow_origin</span>(<span class="ident">res</span>.<span class="ident">request</span>().<span class="ident">head</span>()) {
<span class="ident">res</span>.<span class="ident">headers_mut</span>()
.<span class="ident">insert</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_ORIGIN</span>, <span class="ident">origin</span>);
.<span class="ident">insert</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_ORIGIN</span>, <span class="ident">origin</span>);
};
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="ident">expose</span>) <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">expose_headers_baked</span> {
<span class="ident">res</span>.<span class="ident">headers_mut</span>()
.<span class="ident">insert</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_EXPOSE_HEADERS</span>, <span class="ident">expose</span>.<span class="ident">clone</span>());
.<span class="ident">insert</span>(<span class="ident">header::ACCESS_CONTROL_EXPOSE_HEADERS</span>, <span class="ident">expose</span>.<span class="ident">clone</span>());
}
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">supports_credentials</span> {
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">insert</span>(
<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_CREDENTIALS</span>,
<span class="ident">HeaderValue</span>::<span class="ident">from_static</span>(<span class="string">&quot;true&quot;</span>),
<span class="ident">header::ACCESS_CONTROL_ALLOW_CREDENTIALS</span>,
<span class="ident">HeaderValue::from_static</span>(<span class="string">&quot;true&quot;</span>),
);
}
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">vary_header</span> {
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">VARY</span>) {
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">get</span>(<span class="ident">header::VARY</span>) {
<span class="prelude-val">Some</span>(<span class="ident">hdr</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">val</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="ident">hdr</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">8</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">val</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Vec::with_capacity</span>(<span class="ident">hdr</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="number">8</span>);
<span class="ident">val</span>.<span class="ident">extend</span>(<span class="ident">hdr</span>.<span class="ident">as_bytes</span>());
<span class="ident">val</span>.<span class="ident">extend</span>(<span class="string">b&quot;, Origin&quot;</span>);
<span class="ident">val</span>.<span class="ident">try_into</span>().<span class="ident">unwrap</span>()
}
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HeaderValue</span>::<span class="ident">from_static</span>(<span class="string">&quot;Origin&quot;</span>),
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HeaderValue::from_static</span>(<span class="string">&quot;Origin&quot;</span>),
};
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">insert</span>(<span class="ident">header</span>::<span class="ident">VARY</span>, <span class="ident">value</span>);
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">insert</span>(<span class="ident">header::VARY</span>, <span class="ident">value</span>);
}
<span class="ident">res</span>
@ -339,32 +339,32 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">CorsMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">CorsMiddlewareServiceFuture</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="ident">actix_service</span>::<span class="macro">forward_ready</span><span class="macro">!</span>(<span class="ident">service</span>);
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">preflight</span> <span class="op">&amp;&amp;</span> <span class="ident">req</span>.<span class="ident">method</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">Method</span>::<span class="ident">OPTIONS</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="self">Self</span>::<span class="ident">handle_preflight</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>, <span class="ident">req</span>);
<span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">ok</span>(<span class="ident">res</span>))
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">preflight</span> <span class="op">&amp;&amp;</span> <span class="ident">req</span>.<span class="ident">method</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">Method::OPTIONS</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="self">Self</span><span class="ident">::handle_preflight</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>, <span class="ident">req</span>);
<span class="ident">Either::Left</span>(<span class="ident">ok</span>(<span class="ident">res</span>))
} <span class="kw">else</span> {
<span class="kw">let</span> <span class="ident">origin</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ORIGIN</span>).<span class="ident">cloned</span>();
<span class="kw">let</span> <span class="ident">origin</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::ORIGIN</span>).<span class="ident">cloned</span>();
<span class="kw">if</span> <span class="ident">origin</span>.<span class="ident">is_some</span>() {
<span class="comment">// Only check requests with a origin header.</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">validate_origin</span>(<span class="ident">req</span>.<span class="ident">head</span>()) {
<span class="macro">debug</span><span class="macro">!</span>(<span class="string">&quot;origin validation failed; inner service is not called&quot;</span>);
<span class="kw">return</span> <span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">ok</span>(<span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>)));
<span class="macro">debug!</span>(<span class="string">&quot;origin validation failed; inner service is not called&quot;</span>);
<span class="kw">return</span> <span class="ident">Either::Left</span>(<span class="ident">ok</span>(<span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>)));
}
}
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">service</span>.<span class="ident">call</span>(<span class="ident">req</span>);
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">async</span> <span class="kw">move</span> {
@ -372,14 +372,14 @@
<span class="kw">if</span> <span class="ident">origin</span>.<span class="ident">is_some</span>() {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">res</span><span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(<span class="self">Self</span>::<span class="ident">augment_response</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>, <span class="ident">res</span>))
<span class="prelude-val">Ok</span>(<span class="self">Self</span><span class="ident">::augment_response</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>, <span class="ident">res</span>))
} <span class="kw">else</span> {
<span class="ident">res</span>
}
}
.<span class="ident">boxed_local</span>();
<span class="ident">Either</span>::<span class="ident">Right</span>(<span class="ident">res</span>)
<span class="ident">Either::Right</span>(<span class="ident">res</span>)
}
}
}
@ -387,50 +387,50 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::<span class="ident">Transform</span>,
<span class="ident">dev::Transform</span>,
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
};
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">Cors</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::Cors</span>;
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_options_no_origin</span>() {
<span class="comment">// Tests case where allowed_origins is All but there are validate functions to run incase.</span>
<span class="comment">// In this case, origins are only allowed when the DNT header is sent.</span>
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors</span>::<span class="ident">default</span>()
<span class="kw">let</span> <span class="ident">cors</span> <span class="op">=</span> <span class="ident">Cors::default</span>()
.<span class="ident">allow_any_origin</span>()
.<span class="ident">allowed_origin_fn</span>(<span class="op">|</span><span class="ident">origin</span>, <span class="ident">req_head</span><span class="op">|</span> {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="ident">origin</span>, <span class="ident">req_head</span>.<span class="ident">headers</span>.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ORIGIN</span>).<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;</span><span class="ident">origin</span>, <span class="ident">req_head</span>.<span class="ident">headers</span>.<span class="ident">get</span>(<span class="ident">header::ORIGIN</span>).<span class="ident">unwrap</span>());
<span class="ident">req_head</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header</span>::<span class="ident">DNT</span>)
<span class="ident">req_head</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header::DNT</span>)
})
.<span class="ident">new_transform</span>(<span class="ident">test</span>::<span class="ident">ok_service</span>())
.<span class="ident">new_transform</span>(<span class="ident">test::ok_service</span>())
.<span class="kw">await</span>
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ORIGIN</span>, <span class="string">&quot;http://example.com&quot;</span>))
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header::ORIGIN</span>, <span class="string">&quot;http://example.com&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">call</span>(<span class="ident">req</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="prelude-val">None</span>,
<span class="ident">res</span>.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue</span>::<span class="ident">as_bytes</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue::as_bytes</span>)
);
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">ORIGIN</span>, <span class="string">&quot;http://example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">DNT</span>, <span class="string">&quot;1&quot;</span>))
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header::ORIGIN</span>, <span class="string">&quot;http://example.com&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::DNT</span>, <span class="string">&quot;1&quot;</span>))
.<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">cors</span>.<span class="ident">call</span>(<span class="ident">req</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b&quot;http://example.com&quot;</span>[..]),
<span class="ident">res</span>.<span class="ident">headers</span>()
.<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue</span>::<span class="ident">as_bytes</span>)
.<span class="ident">get</span>(<span class="ident">header::ACCESS_CONTROL_ALLOW_ORIGIN</span>)
.<span class="ident">map</span>(<span class="ident">HeaderValue::as_bytes</span>)
);
}
}

View File

@ -829,21 +829,21 @@
<span id="826">826</span>
<span id="827">827</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">rc</span>::<span class="ident">Rc</span>, <span class="ident">time</span>::<span class="ident">SystemTime</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">rc::Rc</span>, <span class="ident">time::SystemTime</span>};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">Deserialize</span>, <span class="ident">Serialize</span>};
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">use</span> <span class="ident">time::Duration</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>},
<span class="ident">dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
<span class="ident">error</span>::{<span class="ident">Error</span>, <span class="prelude-ty">Result</span>},
<span class="ident">http</span>::<span class="ident">header</span>::{<span class="self">self</span>, <span class="ident">HeaderValue</span>},
<span class="ident">http::header</span>::{<span class="self">self</span>, <span class="ident">HeaderValue</span>},
<span class="ident">HttpMessage</span>,
};
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">IdentityPolicy</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::IdentityPolicy</span>;
<span class="kw">struct</span> <span class="ident">CookieIdentityInner</span> {
<span class="ident">key</span>: <span class="ident">Key</span>,
@ -880,8 +880,8 @@
<span class="kw">let</span> <span class="ident">key_v2</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="ident">key</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]].<span class="ident">concat</span>();
<span class="ident">CookieIdentityInner</span> {
<span class="ident">key</span>: <span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="ident">key</span>),
<span class="ident">key_v2</span>: <span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key_v2</span>),
<span class="ident">key</span>: <span class="ident">Key::derive_from</span>(<span class="ident">key</span>),
<span class="ident">key_v2</span>: <span class="ident">Key::derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key_v2</span>),
<span class="ident">name</span>: <span class="string">&quot;actix-identity&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">path</span>: <span class="string">&quot;/&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">domain</span>: <span class="prelude-val">None</span>,
@ -902,14 +902,14 @@
<span class="kw">let</span> <span class="ident">add_cookie</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">is_some</span>();
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">map</span>(<span class="op">|</span><span class="ident">val</span><span class="op">|</span> {
<span class="kw">if</span> <span class="op">!</span><span class="self">self</span>.<span class="ident">legacy_supported</span>() {
<span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">val</span>)
<span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="ident">val</span>)
} <span class="kw">else</span> {
<span class="prelude-val">Ok</span>(<span class="ident">val</span>.<span class="ident">identity</span>)
}
});
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span>
<span class="ident">Cookie</span>::<span class="ident">new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">val</span>.<span class="ident">unwrap_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="prelude-val">Ok</span>(<span class="ident">String</span>::<span class="ident">new</span>()))<span class="question-mark">?</span>);
<span class="ident">Cookie::new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">val</span>.<span class="ident">unwrap_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="prelude-val">Ok</span>(<span class="ident">String::new</span>()))<span class="question-mark">?</span>);
<span class="ident">cookie</span>.<span class="ident">set_path</span>(<span class="self">self</span>.<span class="ident">path</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_secure</span>(<span class="self">self</span>.<span class="ident">secure</span>);
<span class="ident">cookie</span>.<span class="ident">set_http_only</span>(<span class="bool-val">true</span>);
@ -930,7 +930,7 @@
<span class="ident">cookie</span>.<span class="ident">set_same_site</span>(<span class="ident">same_site</span>);
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">let</span> <span class="ident">key</span> <span class="op">=</span> <span class="kw">if</span> <span class="self">self</span>.<span class="ident">legacy_supported</span>() {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>
@ -946,8 +946,8 @@
}
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">jar</span>.<span class="ident">delta</span>() {
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">resp</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>, <span class="ident">val</span>);
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">resp</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header::SET_COOKIE</span>, <span class="ident">val</span>);
}
<span class="prelude-val">Ok</span>(())
@ -955,7 +955,7 @@
<span class="kw">fn</span> <span class="ident">load</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">CookieValue</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">cookie</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="ident">jar</span>.<span class="ident">add_original</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>());
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">if</span> <span class="self">self</span>.<span class="ident">legacy_supported</span>() {
@ -976,8 +976,8 @@
}
<span class="kw">fn</span> <span class="ident">parse</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">cookie</span>: <span class="ident">Cookie</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">CookieValue</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">value</span>: <span class="ident">CookieValue</span> <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()).<span class="ident">ok</span>()<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">SystemTime</span>::<span class="ident">now</span>();
<span class="kw">let</span> <span class="ident">value</span>: <span class="ident">CookieValue</span> <span class="op">=</span> <span class="ident">serde_json::from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()).<span class="ident">ok</span>()<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">SystemTime::now</span>();
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">visit_deadline</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">visit_deadline</span> {
<span class="kw">let</span> <span class="ident">inactivity</span> <span class="op">=</span> <span class="ident">now</span>.<span class="ident">duration_since</span>(<span class="ident">value</span>.<span class="ident">visit_timestamp</span><span class="question-mark">?</span>).<span class="ident">ok</span>()<span class="question-mark">?</span>;
@ -1044,7 +1044,7 @@
<span class="doccomment">/// # Panics</span>
<span class="doccomment">/// Panics if `key` is less than 32 bytes in length..</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">key</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>]) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieIdentityPolicy</span> {
<span class="ident">CookieIdentityPolicy</span>(<span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">CookieIdentityInner</span>::<span class="ident">new</span>(<span class="ident">key</span>)))
<span class="ident">CookieIdentityPolicy</span>(<span class="ident">Rc::new</span>(<span class="ident">CookieIdentityInner::new</span>(<span class="ident">key</span>)))
}
<span class="doccomment">/// Sets the name of issued cookies.</span>
@ -1079,7 +1079,7 @@
<span class="doccomment">/// Sets the `Max-Age` attribute of issued cookies with given number of seconds.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">max_age_secs</span>(<span class="self">self</span>, <span class="ident">seconds</span>: <span class="ident">i64</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieIdentityPolicy</span> {
<span class="self">self</span>.<span class="ident">max_age</span>(<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="ident">seconds</span>))
<span class="self">self</span>.<span class="ident">max_age</span>(<span class="ident">Duration::seconds</span>(<span class="ident">seconds</span>))
}
<span class="doccomment">/// Sets the `HttpOnly` attribute of issued cookies.</span>
@ -1124,7 +1124,7 @@
}
<span class="kw">fn</span> <span class="ident">inner_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">CookieIdentityInner</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>()
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>()
}
}
@ -1132,7 +1132,7 @@
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">ResponseFuture</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(<span class="prelude-val">Ok</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">load</span>(<span class="ident">req</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">value</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">CookieValue</span> {
<span class="ident">identity</span>,
@ -1154,9 +1154,9 @@
<span class="ident">id</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
<span class="ident">changed</span>: <span class="ident">bool</span>,
<span class="ident">res</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">ResponseFuture</span> {
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::ResponseFuture</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="kw">if</span> <span class="ident">changed</span> {
<span class="kw">let</span> <span class="ident">login_timestamp</span> <span class="op">=</span> <span class="ident">SystemTime</span>::<span class="ident">now</span>();
<span class="kw">let</span> <span class="ident">login_timestamp</span> <span class="op">=</span> <span class="ident">SystemTime::now</span>();
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">set_cookie</span>(
<span class="ident">res</span>,
@ -1167,7 +1167,7 @@
}),
)
} <span class="kw">else</span> <span class="kw">if</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">always_update_cookie</span>() <span class="op">&amp;&amp;</span> <span class="ident">id</span>.<span class="ident">is_some</span>() {
<span class="kw">let</span> <span class="ident">visit_timestamp</span> <span class="op">=</span> <span class="ident">SystemTime</span>::<span class="ident">now</span>();
<span class="kw">let</span> <span class="ident">visit_timestamp</span> <span class="op">=</span> <span class="ident">SystemTime::now</span>();
<span class="kw">let</span> <span class="ident">login_timestamp</span> <span class="op">=</span> <span class="kw">if</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">requires_oob_data</span>() {
<span class="kw">let</span> <span class="ident">CookieIdentityExtension</span> { <span class="ident">login_timestamp</span> } <span class="op">=</span>
@ -1196,16 +1196,16 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow</span>::<span class="ident">Borrow</span>, <span class="ident">time</span>::<span class="ident">SystemTime</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">borrow::Borrow</span>, <span class="ident">time::SystemTime</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>},
<span class="ident">dev</span>::<span class="ident">ServiceResponse</span>,
<span class="ident">dev::ServiceResponse</span>,
<span class="ident">http</span>::{<span class="ident">header</span>, <span class="ident">StatusCode</span>},
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
<span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">HttpResponse</span>,
};
<span class="kw">use</span> <span class="ident">time</span>::<span class="ident">Duration</span>;
<span class="kw">use</span> <span class="ident">time::Duration</span>;
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">tests</span>::<span class="kw-2">*</span>, <span class="ident">Identity</span>, <span class="ident">IdentityService</span>};
@ -1215,16 +1215,16 @@
<span class="ident">login_timestamp</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">SystemTime</span><span class="op">&gt;</span>,
<span class="ident">visit_timestamp</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">SystemTime</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cookie</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">let</span> <span class="ident">key</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">COOKIE_KEY_MASTER</span>
.<span class="ident">iter</span>()
.<span class="ident">chain</span>([<span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>].<span class="ident">iter</span>())
.<span class="ident">copied</span>()
.<span class="ident">collect</span>();
<span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key</span>)).<span class="ident">add</span>(<span class="ident">Cookie</span>::<span class="ident">new</span>(
<span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key::derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key</span>)).<span class="ident">add</span>(<span class="ident">Cookie::new</span>(
<span class="ident">COOKIE_NAME</span>,
<span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">CookieValue</span> {
<span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="ident">CookieValue</span> {
<span class="ident">identity</span>: <span class="ident">identity</span>.<span class="ident">to_string</span>(),
<span class="ident">login_timestamp</span>,
<span class="ident">visit_timestamp</span>,
@ -1241,10 +1241,10 @@
<span class="ident">login_timestamp</span>: <span class="ident">LoginTimestampCheck</span>,
<span class="ident">visit_timestamp</span>: <span class="ident">VisitTimeStampCheck</span>,
) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie</span>::<span class="ident">parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header::SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie::parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
}
<span class="kw">let</span> <span class="ident">key</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">COOKIE_KEY_MASTER</span>
@ -1254,232 +1254,232 @@
.<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">cookies</span>
.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key</span>))
.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key::derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">key</span>))
.<span class="ident">get</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">cv</span>: <span class="ident">CookieValue</span> <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cv</span>.<span class="ident">identity</span>, <span class="ident">identity</span>);
<span class="kw">let</span> <span class="ident">cv</span>: <span class="ident">CookieValue</span> <span class="op">=</span> <span class="ident">serde_json::from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()).<span class="ident">unwrap</span>();
<span class="macro">assert_eq!</span>(<span class="ident">cv</span>.<span class="ident">identity</span>, <span class="ident">identity</span>);
<span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">SystemTime</span>::<span class="ident">now</span>();
<span class="kw">let</span> <span class="ident">t30sec_ago</span> <span class="op">=</span> <span class="ident">now</span> <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">30</span>);
<span class="kw">let</span> <span class="ident">now</span> <span class="op">=</span> <span class="ident">SystemTime::now</span>();
<span class="kw">let</span> <span class="ident">t30sec_ago</span> <span class="op">=</span> <span class="ident">now</span> <span class="op">-</span> <span class="ident">Duration::seconds</span>(<span class="number">30</span>);
<span class="kw">match</span> <span class="ident">login_timestamp</span> {
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NoTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cv</span>.<span class="ident">login_timestamp</span>, <span class="prelude-val">None</span>),
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NewTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert</span><span class="macro">!</span>(
<span class="ident">LoginTimestampCheck::NoTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert_eq!</span>(<span class="ident">cv</span>.<span class="ident">login_timestamp</span>, <span class="prelude-val">None</span>),
<span class="ident">LoginTimestampCheck::NewTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert!</span>(
<span class="ident">t30sec_ago</span> <span class="op">&lt;</span><span class="op">=</span> <span class="ident">cv</span>.<span class="ident">login_timestamp</span>.<span class="ident">unwrap</span>()
<span class="op">&amp;&amp;</span> <span class="ident">cv</span>.<span class="ident">login_timestamp</span>.<span class="ident">unwrap</span>() <span class="op">&lt;</span><span class="op">=</span> <span class="ident">now</span>
),
<span class="ident">LoginTimestampCheck</span>::<span class="ident">OldTimestamp</span>(<span class="ident">old_timestamp</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cv</span>.<span class="ident">login_timestamp</span>, <span class="prelude-val">Some</span>(<span class="ident">old_timestamp</span>))
<span class="ident">LoginTimestampCheck::OldTimestamp</span>(<span class="ident">old_timestamp</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">assert_eq!</span>(<span class="ident">cv</span>.<span class="ident">login_timestamp</span>, <span class="prelude-val">Some</span>(<span class="ident">old_timestamp</span>))
}
}
<span class="kw">match</span> <span class="ident">visit_timestamp</span> {
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NoTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cv</span>.<span class="ident">visit_timestamp</span>, <span class="prelude-val">None</span>),
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NewTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert</span><span class="macro">!</span>(
<span class="ident">VisitTimeStampCheck::NoTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert_eq!</span>(<span class="ident">cv</span>.<span class="ident">visit_timestamp</span>, <span class="prelude-val">None</span>),
<span class="ident">VisitTimeStampCheck::NewTimestamp</span> <span class="op">=</span><span class="op">&gt;</span> <span class="macro">assert!</span>(
<span class="ident">t30sec_ago</span> <span class="op">&lt;</span><span class="op">=</span> <span class="ident">cv</span>.<span class="ident">visit_timestamp</span>.<span class="ident">unwrap</span>()
<span class="op">&amp;&amp;</span> <span class="ident">cv</span>.<span class="ident">visit_timestamp</span>.<span class="ident">unwrap</span>() <span class="op">&lt;</span><span class="op">=</span> <span class="ident">now</span>
),
}
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_flow</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(
<span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">secure</span>(<span class="bool-val">true</span>),
))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/index&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/index&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="kw">if</span> <span class="ident">id</span>.<span class="ident">identity</span>().<span class="ident">is_some</span>() {
<span class="ident">HttpResponse</span>::<span class="ident">Created</span>()
<span class="ident">HttpResponse::Created</span>()
} <span class="kw">else</span> {
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
}
}))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="ident">COOKIE_LOGIN</span>.<span class="ident">to_string</span>());
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
}))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/logout&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/logout&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="kw">if</span> <span class="ident">id</span>.<span class="ident">identity</span>().<span class="ident">is_some</span>() {
<span class="ident">id</span>.<span class="ident">forget</span>();
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
} <span class="kw">else</span> {
<span class="ident">HttpResponse</span>::<span class="ident">BadRequest</span>()
<span class="ident">HttpResponse::BadRequest</span>()
}
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/index&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/index&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">next</span>().<span class="ident">unwrap</span>().<span class="ident">to_owned</span>();
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/index&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/index&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">c</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
.<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">CREATED</span>);
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::CREATED</span>);
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/logout&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/logout&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">c</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
.<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>))
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="macro">assert!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header::SET_COOKIE</span>))
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_max_age_time</span>() {
<span class="kw">let</span> <span class="ident">duration</span> <span class="op">=</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">1</span>);
<span class="kw">let</span> <span class="ident">duration</span> <span class="op">=</span> <span class="ident">Duration::days</span>(<span class="number">1</span>);
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(
<span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">max_age</span>(<span class="ident">duration</span>)
.<span class="ident">secure</span>(<span class="bool-val">true</span>),
))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">&quot;test&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>));
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="macro">assert!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header::SET_COOKIE</span>));
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">next</span>().<span class="ident">unwrap</span>().<span class="ident">to_owned</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">duration</span>, <span class="ident">c</span>.<span class="ident">max_age</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="ident">duration</span>, <span class="ident">c</span>.<span class="ident">max_age</span>().<span class="ident">unwrap</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_http_only_same_site</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(
<span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">http_only</span>(<span class="bool-val">true</span>)
.<span class="ident">same_site</span>(<span class="ident">SameSite</span>::<span class="prelude-val">None</span>),
.<span class="ident">same_site</span>(<span class="ident">SameSite::None</span>),
))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">&quot;test&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>));
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="macro">assert!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header::SET_COOKIE</span>));
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">next</span>().<span class="ident">unwrap</span>().<span class="ident">to_owned</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">c</span>.<span class="ident">http_only</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">SameSite</span>::<span class="prelude-val">None</span>, <span class="ident">c</span>.<span class="ident">same_site</span>().<span class="ident">unwrap</span>());
<span class="macro">assert!</span>(<span class="ident">c</span>.<span class="ident">http_only</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="ident">SameSite::None</span>, <span class="ident">c</span>.<span class="ident">same_site</span>().<span class="ident">unwrap</span>());
}
<span class="kw">fn</span> <span class="ident">legacy_login_cookie</span>(<span class="ident">identity</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Cookie</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>))
.<span class="ident">add</span>(<span class="ident">Cookie</span>::<span class="ident">new</span>(<span class="ident">COOKIE_NAME</span>, <span class="ident">identity</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key::derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>))
.<span class="ident">add</span>(<span class="ident">Cookie::new</span>(<span class="ident">COOKIE_NAME</span>, <span class="ident">identity</span>));
<span class="ident">jar</span>.<span class="ident">get</span>(<span class="ident">COOKIE_NAME</span>).<span class="ident">unwrap</span>().<span class="ident">clone</span>()
}
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">assert_logged_in</span>(<span class="ident">response</span>: <span class="ident">ServiceResponse</span>, <span class="ident">identity</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span>) {
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">read_body</span>(<span class="ident">response</span>).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_slice</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>[..]).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">borrow</span>()), <span class="ident">identity</span>);
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">test::read_body</span>(<span class="ident">response</span>).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">serde_json::from_slice</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>[..]).<span class="ident">unwrap</span>();
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">borrow</span>()), <span class="ident">identity</span>);
}
<span class="kw">fn</span> <span class="ident">assert_legacy_login_cookie</span>(<span class="ident">response</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span>, <span class="ident">identity</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie</span>::<span class="ident">parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header::SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie::parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
}
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">cookies</span>
.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>))
.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="ident">Key::derive_from</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>))
.<span class="ident">get</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cookie</span>.<span class="ident">value</span>(), <span class="ident">identity</span>);
<span class="macro">assert_eq!</span>(<span class="ident">cookie</span>.<span class="ident">value</span>(), <span class="ident">identity</span>);
}
<span class="kw">fn</span> <span class="ident">assert_no_login_cookie</span>(<span class="ident">response</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span>) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie</span>::<span class="ident">parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookies</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">response</span>.<span class="ident">headers</span>().<span class="ident">get_all</span>(<span class="ident">header::SET_COOKIE</span>) {
<span class="ident">cookies</span>.<span class="ident">add</span>(<span class="ident">Cookie::parse</span>(<span class="ident">cookie</span>.<span class="ident">to_str</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>()).<span class="ident">unwrap</span>());
}
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">cookies</span>.<span class="ident">get</span>(<span class="ident">COOKIE_NAME</span>).<span class="ident">is_none</span>());
<span class="macro">assert!</span>(<span class="ident">cookies</span>.<span class="ident">get</span>(<span class="ident">COOKIE_NAME</span>).<span class="ident">is_none</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_max_age</span>() {
<span class="kw">let</span> <span class="ident">seconds</span> <span class="op">=</span> <span class="number">60</span>;
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(
<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(
<span class="ident">CookieIdentityPolicy::new</span>(<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>)
.<span class="ident">domain</span>(<span class="string">&quot;www.rust-lang.org&quot;</span>)
.<span class="ident">name</span>(<span class="ident">COOKIE_NAME</span>)
.<span class="ident">path</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">max_age_secs</span>(<span class="ident">seconds</span>)
.<span class="ident">secure</span>(<span class="bool-val">true</span>),
))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="string">&quot;test&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="ident">HttpResponse::Ok</span>()
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>));
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="macro">assert!</span>(<span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">contains_key</span>(<span class="ident">header::SET_COOKIE</span>));
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">next</span>().<span class="ident">unwrap</span>().<span class="ident">to_owned</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="ident">seconds</span> <span class="kw">as</span> <span class="ident">i64</span>), <span class="ident">c</span>.<span class="ident">max_age</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="ident">Duration::seconds</span>(<span class="ident">seconds</span> <span class="kw">as</span> <span class="ident">i64</span>), <span class="ident">c</span>.<span class="ident">max_age</span>().<span class="ident">unwrap</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_legacy_cookie_is_set</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>).<span class="kw">await</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">srv</span>, <span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to_request</span>()).<span class="kw">await</span>;
<span class="ident">assert_legacy_login_cookie</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>, <span class="ident">COOKIE_LOGIN</span>);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_legacy_cookie_works</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">legacy_login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1488,13 +1488,13 @@
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">Some</span>(<span class="ident">COOKIE_LOGIN</span>)).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_legacy_cookie_rejected_if_visit_timestamp_needed</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">legacy_login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1502,19 +1502,19 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">LoginTimestampCheck::NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NewTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_legacy_cookie_rejected_if_login_timestamp_needed</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">legacy_login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1522,19 +1522,19 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">LoginTimestampCheck::NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NoTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_rejected_if_login_timestamp_needed</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">None</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime</span>::<span class="ident">now</span>()));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">None</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime::now</span>()));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1542,19 +1542,19 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">LoginTimestampCheck::NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NoTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_rejected_if_visit_timestamp_needed</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime</span>::<span class="ident">now</span>()), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime::now</span>()), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1562,23 +1562,23 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">LoginTimestampCheck::NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NewTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_rejected_if_login_timestamp_too_old</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(
<span class="ident">COOKIE_LOGIN</span>,
<span class="prelude-val">Some</span>(<span class="ident">SystemTime</span>::<span class="ident">now</span>() <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">180</span>)),
<span class="prelude-val">Some</span>(<span class="ident">SystemTime::now</span>() <span class="op">-</span> <span class="ident">Duration::days</span>(<span class="number">180</span>)),
<span class="prelude-val">None</span>,
);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1586,23 +1586,23 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">LoginTimestampCheck::NewTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NoTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_rejected_if_visit_timestamp_too_old</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(
<span class="ident">COOKIE_LOGIN</span>,
<span class="prelude-val">None</span>,
<span class="prelude-val">Some</span>(<span class="ident">SystemTime</span>::<span class="ident">now</span>() <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">180</span>)),
<span class="prelude-val">Some</span>(<span class="ident">SystemTime::now</span>() <span class="op">-</span> <span class="ident">Duration::days</span>(<span class="number">180</span>)),
);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1610,19 +1610,19 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">LoginTimestampCheck::NoTimestamp</span>,
<span class="ident">VisitTimeStampCheck::NewTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_not_updated_on_login_deadline</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime</span>::<span class="ident">now</span>()), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">login_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">Some</span>(<span class="ident">SystemTime::now</span>()), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1631,18 +1631,18 @@
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">Some</span>(<span class="ident">COOKIE_LOGIN</span>)).<span class="kw">await</span>;
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_identity_cookie_updated_on_visit_deadline</span>() {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">create_identity_server</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> {
<span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))
.<span class="ident">login_deadline</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">90</span>))
<span class="ident">c</span>.<span class="ident">visit_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))
.<span class="ident">login_deadline</span>(<span class="ident">Duration::days</span>(<span class="number">90</span>))
})
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">timestamp</span> <span class="op">=</span> <span class="ident">SystemTime</span>::<span class="ident">now</span>() <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">1</span>);
<span class="kw">let</span> <span class="ident">timestamp</span> <span class="op">=</span> <span class="ident">SystemTime::now</span>() <span class="op">-</span> <span class="ident">Duration::days</span>(<span class="number">1</span>);
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">login_cookie</span>(<span class="ident">COOKIE_LOGIN</span>, <span class="prelude-val">Some</span>(<span class="ident">timestamp</span>), <span class="prelude-val">Some</span>(<span class="ident">timestamp</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test::call_service</span>(
<span class="kw-2">&amp;</span><span class="ident">srv</span>,
<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/&quot;</span>)
<span class="ident">TestRequest::with_uri</span>(<span class="string">&quot;/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>())
.<span class="ident">to_request</span>(),
)
@ -1650,8 +1650,8 @@
<span class="ident">assert_login_cookie</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">resp</span>,
<span class="ident">COOKIE_LOGIN</span>,
<span class="ident">LoginTimestampCheck</span>::<span class="ident">OldTimestamp</span>(<span class="ident">timestamp</span>),
<span class="ident">VisitTimeStampCheck</span>::<span class="ident">NewTimestamp</span>,
<span class="ident">LoginTimestampCheck::OldTimestamp</span>(<span class="ident">timestamp</span>),
<span class="ident">VisitTimeStampCheck::NewTimestamp</span>,
);
<span class="ident">assert_logged_in</span>(<span class="ident">resp</span>, <span class="prelude-val">Some</span>(<span class="ident">COOKIE_LOGIN</span>)).<span class="kw">await</span>;
}

View File

@ -107,7 +107,7 @@
<span class="ident">dev</span>::{<span class="ident">Extensions</span>, <span class="ident">Payload</span>},
<span class="ident">Error</span>, <span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>,
};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">struct</span> <span class="ident">IdentityItem</span> {
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="ident">id</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
@ -153,7 +153,7 @@
<span class="doccomment">/// Return the claimed identity of the user associated request or `None` if no identity can be</span>
<span class="doccomment">/// found associated with the request.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> {
<span class="ident">Identity</span>::<span class="ident">get_identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>.<span class="ident">extensions</span>())
<span class="ident">Identity::get_identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>.<span class="ident">extensions</span>())
}
<span class="doccomment">/// Remember identity.</span>
@ -200,7 +200,7 @@
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Identity</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(<span class="prelude-val">Ok</span>(<span class="ident">Identity</span>(<span class="ident">req</span>.<span class="ident">clone</span>())))
}
}

View File

@ -202,7 +202,7 @@
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>, <span class="ident">nonstandard_style</span>)]</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::future::Future</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
@ -213,9 +213,9 @@
<span class="kw">mod</span> <span class="ident">identity</span>;
<span class="kw">mod</span> <span class="ident">middleware</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">cookie</span>::<span class="ident">CookieIdentityPolicy</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">identity</span>::<span class="ident">Identity</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">middleware</span>::<span class="ident">IdentityService</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::cookie::CookieIdentityPolicy</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::identity::Identity</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::middleware::IdentityService</span>;
<span class="doccomment">/// Identity policy.</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">IdentityPolicy</span>: <span class="ident">Sized</span> <span class="op">+</span> <span class="lifetime">&#39;static</span> {
@ -226,7 +226,7 @@
<span class="kw">type</span> <span class="ident">ResponseFuture</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="doccomment">/// Parse the session from request and load data from a service identity.</span>
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span>;
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span>;
<span class="doccomment">/// Write changes to response</span>
<span class="kw">fn</span> <span class="ident">to_response</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>(
@ -234,7 +234,7 @@
<span class="ident">identity</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
<span class="ident">changed</span>: <span class="ident">bool</span>,
<span class="ident">response</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">ResponseFuture</span>;
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::ResponseFuture</span>;
}
<span class="doccomment">/// Helper trait that allows to get Identity.</span>
@ -250,15 +250,15 @@
<span class="ident">T</span>: <span class="ident">HttpMessage</span>,
{
<span class="kw">fn</span> <span class="ident">get_identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> {
<span class="ident">Identity</span>::<span class="ident">get_identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">extensions</span>())
<span class="ident">Identity::get_identity</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">extensions</span>())
}
}
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">time</span>::<span class="ident">SystemTime</span>;
<span class="kw">use</span> <span class="ident">std::time::SystemTime</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">dev</span>::<span class="ident">ServiceResponse</span>, <span class="ident">test</span>, <span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">Error</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">dev::ServiceResponse</span>, <span class="ident">test</span>, <span class="ident">web</span>, <span class="ident">App</span>, <span class="ident">Error</span>};
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
@ -266,14 +266,14 @@
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const</span> <span class="ident">COOKIE_NAME</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;actix_auth&quot;</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const</span> <span class="ident">COOKIE_LOGIN</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;test&quot;</span>;
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">enum_variant_names</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::enum_variant_names</span>)]</span>
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">enum</span> <span class="ident">LoginTimestampCheck</span> {
<span class="ident">NoTimestamp</span>,
<span class="ident">NewTimestamp</span>,
<span class="ident">OldTimestamp</span>(<span class="ident">SystemTime</span>),
}
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">enum_variant_names</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::enum_variant_names</span>)]</span>
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">enum</span> <span class="ident">VisitTimeStampCheck</span> {
<span class="ident">NoTimestamp</span>,
<span class="ident">NewTimestamp</span>,
@ -283,24 +283,24 @@
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="ident">CookieIdentityPolicy</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieIdentityPolicy</span> <span class="op">+</span> <span class="ident">Sync</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Clone</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="op">&gt;</span>(
<span class="ident">f</span>: <span class="ident">F</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">actix_service</span>::<span class="ident">Service</span><span class="op">&lt;</span>
<span class="ident">actix_http</span>::<span class="ident">Request</span>,
<span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">actix_web</span>::<span class="ident">body</span>::<span class="ident">Body</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">actix_service::Service</span><span class="op">&lt;</span>
<span class="ident">actix_http::Request</span>,
<span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">actix_web::body::Body</span><span class="op">&gt;</span>,
<span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>,
<span class="op">&gt;</span> {
<span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService</span>::<span class="ident">new</span>(<span class="ident">f</span>(<span class="ident">CookieIdentityPolicy</span>::<span class="ident">new</span>(
<span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">IdentityService::new</span>(<span class="ident">f</span>(<span class="ident">CookieIdentityPolicy::new</span>(
<span class="kw-2">&amp;</span><span class="ident">COOKIE_KEY_MASTER</span>,
)
.<span class="ident">secure</span>(<span class="bool-val">false</span>)
.<span class="ident">name</span>(<span class="ident">COOKIE_NAME</span>))))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">id</span>: <span class="ident">Identity</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">identity</span> <span class="op">=</span> <span class="ident">id</span>.<span class="ident">identity</span>();
<span class="kw">if</span> <span class="ident">identity</span>.<span class="ident">is_none</span>() {
<span class="ident">id</span>.<span class="ident">remember</span>(<span class="ident">COOKIE_LOGIN</span>.<span class="ident">to_string</span>())
}
<span class="ident">web</span>::<span class="ident">Json</span>(<span class="ident">identity</span>)
<span class="ident">web::Json</span>(<span class="ident">identity</span>)
})),
)
.<span class="kw">await</span>

View File

@ -170,15 +170,15 @@
<span id="167">167</span>
<span id="168">168</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Rc</span>;
<span class="kw">use</span> <span class="ident">std::rc::Rc</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>, <span class="ident">Transform</span>},
<span class="ident">Error</span>, <span class="ident">HttpMessage</span>, <span class="prelude-ty">Result</span>,
};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ready</span>, <span class="ident">FutureExt</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ready</span>, <span class="ident">FutureExt</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">identity</span>::<span class="ident">IdentityItem</span>, <span class="ident">IdentityPolicy</span>};
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">identity::IdentityItem</span>, <span class="ident">IdentityPolicy</span>};
<span class="doccomment">/// Request identity middleware</span>
<span class="doccomment">///</span>
@ -203,7 +203,7 @@
<span class="doccomment">/// Create new identity service with specified backend.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">backend</span>: <span class="ident">T</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">IdentityService</span> {
<span class="ident">backend</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">backend</span>),
<span class="ident">backend</span>: <span class="ident">Rc::new</span>(<span class="ident">backend</span>),
}
}
}
@ -211,7 +211,7 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">T</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Transform</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">IdentityService</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">IdentityPolicy</span>,
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
{
@ -219,12 +219,12 @@
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">InitError</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Transform</span> <span class="op">=</span> <span class="ident">IdentityServiceMiddleware</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">T</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Transform</span>, <span class="self">Self</span>::<span class="ident">InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Transform</span>, <span class="self">Self</span><span class="ident">::InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(<span class="prelude-val">Ok</span>(<span class="ident">IdentityServiceMiddleware</span> {
<span class="ident">backend</span>: <span class="self">self</span>.<span class="ident">backend</span>.<span class="ident">clone</span>(),
<span class="ident">service</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">service</span>),
<span class="ident">service</span>: <span class="ident">Rc::new</span>(<span class="ident">service</span>),
}))
}
}
@ -237,8 +237,8 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Clone</span> <span class="kw">for</span> <span class="ident">IdentityServiceMiddleware</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="self">Self</span> {
<span class="ident">backend</span>: <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">backend</span>),
<span class="ident">service</span>: <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>),
<span class="ident">backend</span>: <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">backend</span>),
<span class="ident">service</span>: <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>),
}
}
}
@ -247,18 +247,18 @@
<span class="kw">where</span>
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">T</span>: <span class="ident">IdentityPolicy</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Response</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Response</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="ident">actix_service</span>::<span class="macro">forward_ready</span><span class="macro">!</span>(<span class="ident">service</span>);
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>);
<span class="kw">let</span> <span class="ident">backend</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">backend</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>);
<span class="kw">let</span> <span class="ident">backend</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">backend</span>);
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">backend</span>.<span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>);
<span class="kw">async</span> <span class="kw">move</span> {
@ -288,23 +288,23 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">rc</span>::<span class="ident">Rc</span>, <span class="ident">time</span>::<span class="ident">Duration</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">rc::Rc</span>, <span class="ident">time::Duration</span>};
<span class="kw">use</span> <span class="ident">actix_service</span>::<span class="ident">into_service</span>;
<span class="kw">use</span> <span class="ident">actix_service::into_service</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">dev</span>, <span class="ident">error</span>, <span class="ident">test</span>, <span class="ident">Error</span>, <span class="prelude-ty">Result</span>};
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_borrowed_mut_error</span>() {
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">lazy</span>, <span class="ident">ok</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">lazy</span>, <span class="ident">ok</span>, <span class="ident">Ready</span>};
<span class="kw">struct</span> <span class="ident">Ident</span>;
<span class="kw">impl</span> <span class="ident">IdentityPolicy</span> <span class="kw">for</span> <span class="ident">Ident</span> {
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">ResponseFuture</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">dev</span>::<span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">dev::ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ok</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;test&quot;</span>.<span class="ident">to_string</span>()))
}
@ -312,28 +312,28 @@
<span class="kw-2">&amp;</span><span class="self">self</span>,
<span class="kw">_</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
<span class="kw">_</span>: <span class="ident">bool</span>,
<span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">dev</span>::<span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">ResponseFuture</span> {
<span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">dev::ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::ResponseFuture</span> {
<span class="ident">ok</span>(())
}
}
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="kw">crate</span>::<span class="ident">middleware</span>::<span class="ident">IdentityServiceMiddleware</span> {
<span class="ident">backend</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">Ident</span>),
<span class="ident">service</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">into_service</span>(<span class="op">|</span><span class="kw">_</span>: <span class="ident">dev</span>::<span class="ident">ServiceRequest</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="ident">actix_rt</span>::<span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_secs</span>(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">dev</span>::<span class="ident">ServiceResponse</span>, <span class="kw">_</span><span class="op">&gt;</span>(<span class="ident">error</span>::<span class="ident">ErrorBadRequest</span>(<span class="string">&quot;error&quot;</span>))
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="kw">crate</span><span class="ident">::middleware::IdentityServiceMiddleware</span> {
<span class="ident">backend</span>: <span class="ident">Rc::new</span>(<span class="ident">Ident</span>),
<span class="ident">service</span>: <span class="ident">Rc::new</span>(<span class="ident">into_service</span>(<span class="op">|</span><span class="kw">_</span>: <span class="ident">dev::ServiceRequest</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="ident">actix_rt::time::sleep</span>(<span class="ident">Duration::from_secs</span>(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">dev::ServiceResponse</span>, <span class="kw">_</span><span class="op">&gt;</span>(<span class="ident">error::ErrorBadRequest</span>(<span class="string">&quot;error&quot;</span>))
})),
};
<span class="kw">let</span> <span class="ident">srv2</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">clone</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="ident">actix_rt</span>::<span class="ident">spawn</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="ident">actix_rt::spawn</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">srv2</span>.<span class="ident">call</span>(<span class="ident">req</span>).<span class="kw">await</span>;
});
<span class="ident">actix_rt</span>::<span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">50</span>)).<span class="kw">await</span>;
<span class="ident">actix_rt::time::sleep</span>(<span class="ident">Duration::from_millis</span>(<span class="number">50</span>)).<span class="kw">await</span>;
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">lazy</span>(<span class="op">|</span><span class="ident">cx</span><span class="op">|</span> <span class="ident">srv</span>.<span class="ident">poll_ready</span>(<span class="ident">cx</span>)).<span class="kw">await</span>;
}

View File

@ -328,25 +328,25 @@
</pre><div class="example-wrap"><pre class="rust ">
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>)]</span>
<span class="kw">use</span> <span class="ident">derive_more</span>::<span class="ident">Display</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">future</span>::<span class="ident">Future</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::{<span class="ident">Deref</span>, <span class="ident">DerefMut</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">task</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">task</span>::<span class="ident">Poll</span>;
<span class="kw">use</span> <span class="ident">derive_more::Display</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::future::Future</span>;
<span class="kw">use</span> <span class="ident">std::ops</span>::{<span class="ident">Deref</span>, <span class="ident">DerefMut</span>};
<span class="kw">use</span> <span class="ident">std::pin::Pin</span>;
<span class="kw">use</span> <span class="ident">std::task</span>;
<span class="kw">use</span> <span class="ident">std::task::Poll</span>;
<span class="kw">use</span> <span class="ident">prost</span>::<span class="ident">DecodeError</span> <span class="kw">as</span> <span class="ident">ProtoBufDecodeError</span>;
<span class="kw">use</span> <span class="ident">prost</span>::<span class="ident">EncodeError</span> <span class="kw">as</span> <span class="ident">ProtoBufEncodeError</span>;
<span class="kw">use</span> <span class="ident">prost</span>::<span class="ident">Message</span>;
<span class="kw">use</span> <span class="ident">prost::DecodeError</span> <span class="kw">as</span> <span class="ident">ProtoBufDecodeError</span>;
<span class="kw">use</span> <span class="ident">prost::EncodeError</span> <span class="kw">as</span> <span class="ident">ProtoBufEncodeError</span>;
<span class="kw">use</span> <span class="ident">prost::Message</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::{<span class="ident">HttpResponseBuilder</span>, <span class="ident">Payload</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">error</span>::{<span class="ident">Error</span>, <span class="ident">PayloadError</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>::{<span class="ident">CONTENT_LENGTH</span>, <span class="ident">CONTENT_TYPE</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">web</span>::<span class="ident">BytesMut</span>;
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">HttpResponseBuilder</span>, <span class="ident">Payload</span>};
<span class="kw">use</span> <span class="ident">actix_web::error</span>::{<span class="ident">Error</span>, <span class="ident">PayloadError</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="ident">CONTENT_LENGTH</span>, <span class="ident">CONTENT_TYPE</span>};
<span class="kw">use</span> <span class="ident">actix_web::web::BytesMut</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">FromRequest</span>, <span class="ident">HttpMessage</span>, <span class="ident">HttpRequest</span>, <span class="ident">HttpResponse</span>, <span class="ident">Responder</span>};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">FutureExt</span>, <span class="ident">LocalBoxFuture</span>};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">StreamExt</span>;
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">FutureExt</span>, <span class="ident">LocalBoxFuture</span>};
<span class="kw">use</span> <span class="ident">futures_util::StreamExt</span>;
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">ProtoBufPayloadError</span> {
@ -370,21 +370,21 @@
<span class="kw">impl</span> <span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span>::<span class="ident">PayloadTooLarge</span>().<span class="ident">into</span>(),
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span>::<span class="ident">BadRequest</span>().<span class="ident">into</span>(),
<span class="ident">ProtoBufPayloadError::Overflow</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse::PayloadTooLarge</span>().<span class="ident">into</span>(),
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse::BadRequest</span>().<span class="ident">into</span>(),
}
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">PayloadError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">err</span>: <span class="ident">PayloadError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Payload</span>(<span class="ident">err</span>)
<span class="ident">ProtoBufPayloadError::Payload</span>(<span class="ident">err</span>)
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">ProtoBufDecodeError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">err</span>: <span class="ident">ProtoBufDecodeError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Deserialize</span>(<span class="ident">err</span>)
<span class="ident">ProtoBufPayloadError::Deserialize</span>(<span class="ident">err</span>)
}
}
@ -404,21 +404,21 @@
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">ProtoBuf</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span><span class="op">&gt;</span> <span class="ident">fmt::Debug</span> <span class="kw">for</span> <span class="ident">ProtoBuf</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">fmt</span>::<span class="ident">Debug</span>,
<span class="ident">T</span>: <span class="ident">fmt::Debug</span>,
{
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</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">&quot;ProtoBuf: {:?}&quot;</span>, <span class="self">self</span>.<span class="number">0</span>)
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt::Result</span> {
<span class="macro">write!</span>(<span class="ident">f</span>, <span class="string">&quot;ProtoBuf: {:?}&quot;</span>, <span class="self">self</span>.<span class="number">0</span>)
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="ident">Display</span> <span class="kw">for</span> <span class="ident">ProtoBuf</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span><span class="op">&gt;</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">ProtoBuf</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">fmt</span>::<span class="ident">Display</span>,
<span class="ident">T</span>: <span class="ident">fmt::Display</span>,
{
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
<span class="ident">fmt</span>::<span class="ident">Display</span>::<span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, <span class="ident">f</span>)
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt::Result</span> {
<span class="ident">fmt::Display::fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, <span class="ident">f</span>)
}
}
@ -449,12 +449,12 @@
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="ident">payload</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="ident">payload</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">let</span> <span class="ident">limit</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">ProtoBufConfig</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">limit</span>)
.<span class="ident">unwrap_or</span>(<span class="number">262_144</span>);
<span class="ident">ProtoBufMessage</span>::<span class="ident">new</span>(<span class="ident">req</span>, <span class="ident">payload</span>)
<span class="ident">ProtoBufMessage::new</span>(<span class="ident">req</span>, <span class="ident">payload</span>)
.<span class="ident">limit</span>(<span class="ident">limit</span>)
.<span class="ident">map</span>(<span class="kw">move</span> <span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">res</span> {
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>()),
@ -466,13 +466,13 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span> <span class="op">+</span> <span class="ident">Default</span><span class="op">&gt;</span> <span class="ident">Responder</span> <span class="kw">for</span> <span class="ident">ProtoBuf</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">respond_to</span>(<span class="self">self</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
<span class="kw">match</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">encode</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
<span class="prelude-val">Ok</span>(()) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()
<span class="prelude-val">Ok</span>(()) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse::Ok</span>()
.<span class="ident">content_type</span>(<span class="string">&quot;application/protobuf&quot;</span>)
.<span class="ident">body</span>(<span class="ident">buf</span>),
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span>::<span class="ident">from_error</span>(<span class="ident">Error</span>::<span class="ident">from</span>(
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Serialize</span>(<span class="ident">err</span>),
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">HttpResponse::from_error</span>(<span class="ident">Error::from</span>(
<span class="ident">ProtoBufPayloadError::Serialize</span>(<span class="ident">err</span>),
)),
}
}
@ -495,7 +495,7 @@
<span class="ident">length</span>: <span class="prelude-val">None</span>,
<span class="ident">stream</span>: <span class="prelude-val">None</span>,
<span class="ident">fut</span>: <span class="prelude-val">None</span>,
<span class="ident">err</span>: <span class="prelude-val">Some</span>(<span class="ident">ProtoBufPayloadError</span>::<span class="ident">ContentType</span>),
<span class="ident">err</span>: <span class="prelude-val">Some</span>(<span class="ident">ProtoBufPayloadError::ContentType</span>),
};
}
@ -529,20 +529,20 @@
<span class="kw">fn</span> <span class="ident">poll</span>(
<span class="kw-2">mut</span> <span class="self">self</span>: <span class="ident">Pin</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="op">&gt;</span>,
<span class="ident">task</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">task</span>::<span class="ident">Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Poll</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Output</span><span class="op">&gt;</span> {
<span class="ident">task</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">task::Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Poll</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Output</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">fut</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">fut</span> {
<span class="kw">return</span> <span class="ident">Pin</span>::<span class="ident">new</span>(<span class="ident">fut</span>).<span class="ident">poll</span>(<span class="ident">task</span>);
<span class="kw">return</span> <span class="ident">Pin::new</span>(<span class="ident">fut</span>).<span class="ident">poll</span>(<span class="ident">task</span>);
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">err</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">err</span>.<span class="ident">take</span>() {
<span class="kw">return</span> <span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="prelude-val">Err</span>(<span class="ident">err</span>));
<span class="kw">return</span> <span class="ident">Poll::Ready</span>(<span class="prelude-val">Err</span>(<span class="ident">err</span>));
}
<span class="kw">let</span> <span class="ident">limit</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">limit</span>;
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">len</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">length</span>.<span class="ident">take</span>() {
<span class="kw">if</span> <span class="ident">len</span> <span class="op">&gt;</span> <span class="ident">limit</span> {
<span class="kw">return</span> <span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="prelude-val">Err</span>(<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span>));
<span class="kw">return</span> <span class="ident">Poll::Ready</span>(<span class="prelude-val">Err</span>(<span class="ident">ProtoBufPayloadError::Overflow</span>));
}
}
@ -553,18 +553,18 @@
<span class="self">self</span>.<span class="ident">fut</span> <span class="op">=</span> <span class="prelude-val">Some</span>(
<span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">BytesMut</span>::<span class="ident">with_capacity</span>(<span class="number">8192</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">BytesMut::with_capacity</span>(<span class="number">8192</span>);
<span class="kw">while</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">item</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">next</span>().<span class="kw">await</span> {
<span class="kw">let</span> <span class="ident">chunk</span> <span class="op">=</span> <span class="ident">item</span><span class="question-mark">?</span>;
<span class="kw">if</span> (<span class="ident">body</span>.<span class="ident">len</span>() <span class="op">+</span> <span class="ident">chunk</span>.<span class="ident">len</span>()) <span class="op">&gt;</span> <span class="ident">limit</span> {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span>);
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">ProtoBufPayloadError::Overflow</span>);
} <span class="kw">else</span> {
<span class="ident">body</span>.<span class="ident">extend_from_slice</span>(<span class="kw-2">&amp;</span><span class="ident">chunk</span>);
}
}
<span class="prelude-val">Ok</span>(<span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>::<span class="ident">decode</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">body</span>)<span class="question-mark">?</span>)
<span class="prelude-val">Ok</span>(<span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span><span class="ident">::decode</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">body</span>)<span class="question-mark">?</span>)
}
.<span class="ident">boxed_local</span>(),
);
@ -580,10 +580,10 @@
<span class="kw">fn</span> <span class="ident">protobuf</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">Message</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">T</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">HttpResponse</span>, <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">insert_header</span>((<span class="ident">CONTENT_TYPE</span>, <span class="string">&quot;application/protobuf&quot;</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
<span class="ident">value</span>
.<span class="ident">encode</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">body</span>)
.<span class="ident">map_err</span>(<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Serialize</span>)<span class="question-mark">?</span>;
.<span class="ident">map_err</span>(<span class="ident">ProtoBufPayloadError::Serialize</span>)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(<span class="self">self</span>.<span class="ident">body</span>(<span class="ident">body</span>))
}
}
@ -591,17 +591,17 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">test</span>::<span class="ident">TestRequest</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>;
<span class="kw">use</span> <span class="ident">actix_web::test::TestRequest</span>;
<span class="kw">impl</span> <span class="ident">PartialEq</span> <span class="kw">for</span> <span class="ident">ProtoBufPayloadError</span> {
<span class="kw">fn</span> <span class="ident">eq</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">other</span>: <span class="kw-2">&amp;</span><span class="ident">ProtoBufPayloadError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">bool</span> {
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">matches</span><span class="macro">!</span>(<span class="kw-2">*</span><span class="ident">other</span>, <span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span>)
<span class="ident">ProtoBufPayloadError::Overflow</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">matches!</span>(<span class="kw-2">*</span><span class="ident">other</span>, <span class="ident">ProtoBufPayloadError::Overflow</span>)
}
<span class="ident">ProtoBufPayloadError</span>::<span class="ident">ContentType</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">matches</span><span class="macro">!</span>(<span class="kw-2">*</span><span class="ident">other</span>, <span class="ident">ProtoBufPayloadError</span>::<span class="ident">ContentType</span>)
<span class="ident">ProtoBufPayloadError::ContentType</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">matches!</span>(<span class="kw-2">*</span><span class="ident">other</span>, <span class="ident">ProtoBufPayloadError::ContentType</span>)
}
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="bool-val">false</span>,
}
@ -616,38 +616,38 @@
<span class="kw">pub</span> <span class="ident">name</span>: <span class="ident">String</span>,
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_protobuf</span>() {
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBuf</span>(<span class="ident">MyObject</span> {
<span class="ident">number</span>: <span class="number">9</span>,
<span class="ident">name</span>: <span class="string">&quot;test&quot;</span>.<span class="ident">to_owned</span>(),
});
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_http_request</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">TestRequest::default</span>().<span class="ident">to_http_request</span>();
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">protobuf</span>.<span class="ident">respond_to</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">ct</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">ct</span>, <span class="string">&quot;application/protobuf&quot;</span>);
<span class="kw">let</span> <span class="ident">ct</span> <span class="op">=</span> <span class="ident">resp</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::CONTENT_TYPE</span>).<span class="ident">unwrap</span>();
<span class="macro">assert_eq!</span>(<span class="ident">ct</span>, <span class="string">&quot;application/protobuf&quot;</span>);
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_protobuf_message</span>() {
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_http_parts</span>();
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError</span>::<span class="ident">ContentType</span>);
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest::default</span>().<span class="ident">to_http_parts</span>();
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span><span class="ident">::new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError::ContentType</span>);
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>, <span class="string">&quot;application/text&quot;</span>))
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest::get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header::CONTENT_TYPE</span>, <span class="string">&quot;application/text&quot;</span>))
.<span class="ident">to_http_parts</span>();
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError</span>::<span class="ident">ContentType</span>);
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span><span class="ident">::new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError::ContentType</span>);
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest</span>::<span class="ident">get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">CONTENT_TYPE</span>, <span class="string">&quot;application/protobuf&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header</span>::<span class="ident">CONTENT_LENGTH</span>, <span class="string">&quot;10000&quot;</span>))
<span class="kw">let</span> (<span class="ident">req</span>, <span class="kw-2">mut</span> <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">TestRequest::get</span>()
.<span class="ident">insert_header</span>((<span class="ident">header::CONTENT_TYPE</span>, <span class="string">&quot;application/protobuf&quot;</span>))
.<span class="ident">insert_header</span>((<span class="ident">header::CONTENT_LENGTH</span>, <span class="string">&quot;10000&quot;</span>))
.<span class="ident">to_http_parts</span>();
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span>::<span class="ident">new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>)
<span class="kw">let</span> <span class="ident">protobuf</span> <span class="op">=</span> <span class="ident">ProtoBufMessage</span>::<span class="op">&lt;</span><span class="ident">MyObject</span><span class="op">&gt;</span><span class="ident">::new</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">pl</span>)
.<span class="ident">limit</span>(<span class="number">100</span>)
.<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError</span>::<span class="ident">Overflow</span>);
<span class="macro">assert_eq!</span>(<span class="ident">protobuf</span>.<span class="ident">err</span>().<span class="ident">unwrap</span>(), <span class="ident">ProtoBufPayloadError::Overflow</span>);
}
}
</pre></div>

View File

@ -49,15 +49,15 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;web&quot;</span>)]</span>
<span class="kw">mod</span> <span class="ident">session</span>;
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;web&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">cookie</span>::<span class="ident">SameSite</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">actix_web::cookie::SameSite</span>;
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;web&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">session</span>::<span class="ident">RedisSession</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">session::RedisSession</span>;
<span class="doccomment">/// General purpose actix redis error</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>, <span class="ident">Error</span>, <span class="ident">From</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Error</span> {
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Redis error {}&quot;</span>, <span class="ident">_0</span>)]</span>
<span class="ident">Redis</span>(<span class="ident">redis_async</span>::<span class="ident">error</span>::<span class="ident">Error</span>),
<span class="ident">Redis</span>(<span class="ident">redis_async::error::Error</span>),
<span class="doccomment">/// Receiving message during reconnecting</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Redis: Not connected&quot;</span>)]</span>
<span class="ident">NotConnected</span>,
@ -67,11 +67,11 @@
}
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;web&quot;</span>)]</span>
<span class="kw">impl</span> <span class="ident">actix_web</span>::<span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">Error</span> {}
<span class="kw">impl</span> <span class="ident">actix_web::ResponseError</span> <span class="kw">for</span> <span class="ident">Error</span> {}
<span class="comment">// re-export</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">error</span>::<span class="ident">Error</span> <span class="kw">as</span> <span class="ident">RespError</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">resp</span>::<span class="ident">RespValue</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::error::Error</span> <span class="kw">as</span> <span class="ident">RespError</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::resp::RespValue</span>;
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-search-js="../../search-index.js"></div>
<script src="../../main.js"></script><script src="../../source-script.js"></script><script src="../../source-files.js"></script></body></html>

View File

@ -143,23 +143,23 @@
<span id="140">140</span>
<span id="141">141</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">VecDeque</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
<span class="kw">use</span> <span class="ident">std::collections::VecDeque</span>;
<span class="kw">use</span> <span class="ident">std::io</span>;
<span class="kw">use</span> <span class="ident">actix</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_rt</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
<span class="kw">use</span> <span class="ident">actix_service</span>::<span class="ident">boxed</span>::{<span class="ident">service</span>, <span class="ident">BoxService</span>};
<span class="kw">use</span> <span class="ident">actix_tls</span>::<span class="ident">connect</span>::{<span class="ident">default_connector</span>, <span class="ident">Connect</span>, <span class="ident">ConnectError</span>, <span class="ident">Connection</span>};
<span class="kw">use</span> <span class="ident">backoff</span>::<span class="ident">backoff</span>::<span class="ident">Backoff</span>;
<span class="kw">use</span> <span class="ident">backoff</span>::<span class="ident">ExponentialBackoff</span>;
<span class="kw">use</span> <span class="ident">actix::prelude</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_rt::net::TcpStream</span>;
<span class="kw">use</span> <span class="ident">actix_service::boxed</span>::{<span class="ident">service</span>, <span class="ident">BoxService</span>};
<span class="kw">use</span> <span class="ident">actix_tls::connect</span>::{<span class="ident">default_connector</span>, <span class="ident">Connect</span>, <span class="ident">ConnectError</span>, <span class="ident">Connection</span>};
<span class="kw">use</span> <span class="ident">backoff::backoff::Backoff</span>;
<span class="kw">use</span> <span class="ident">backoff::ExponentialBackoff</span>;
<span class="kw">use</span> <span class="ident">log</span>::{<span class="ident">error</span>, <span class="ident">info</span>, <span class="ident">warn</span>};
<span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">error</span>::<span class="ident">Error</span> <span class="kw">as</span> <span class="ident">RespError</span>;
<span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">resp</span>::{<span class="ident">RespCodec</span>, <span class="ident">RespValue</span>};
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="ident">split</span>, <span class="ident">WriteHalf</span>};
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">sync</span>::<span class="ident">oneshot</span>;
<span class="kw">use</span> <span class="ident">tokio_util</span>::<span class="ident">codec</span>::<span class="ident">FramedRead</span>;
<span class="kw">use</span> <span class="ident">redis_async::error::Error</span> <span class="kw">as</span> <span class="ident">RespError</span>;
<span class="kw">use</span> <span class="ident">redis_async::resp</span>::{<span class="ident">RespCodec</span>, <span class="ident">RespValue</span>};
<span class="kw">use</span> <span class="ident">tokio::io</span>::{<span class="ident">split</span>, <span class="ident">WriteHalf</span>};
<span class="kw">use</span> <span class="ident">tokio::sync::oneshot</span>;
<span class="kw">use</span> <span class="ident">tokio_util::codec::FramedRead</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">Error</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::Error</span>;
<span class="doccomment">/// Command for send data to Redis</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>)]</span>
@ -174,8 +174,8 @@
<span class="ident">addr</span>: <span class="ident">String</span>,
<span class="ident">connector</span>: <span class="ident">BoxService</span><span class="op">&lt;</span><span class="ident">Connect</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>, <span class="ident">Connection</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">TcpStream</span><span class="op">&gt;</span>, <span class="ident">ConnectError</span><span class="op">&gt;</span>,
<span class="ident">backoff</span>: <span class="ident">ExponentialBackoff</span>,
<span class="ident">cell</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">actix</span>::<span class="ident">io</span>::<span class="ident">FramedWrite</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">WriteHalf</span><span class="op">&lt;</span><span class="ident">TcpStream</span><span class="op">&gt;</span>, <span class="ident">RespCodec</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">queue</span>: <span class="ident">VecDeque</span><span class="op">&lt;</span><span class="ident">oneshot</span>::<span class="ident">Sender</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">cell</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">actix::io::FramedWrite</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">WriteHalf</span><span class="op">&lt;</span><span class="ident">TcpStream</span><span class="op">&gt;</span>, <span class="ident">RespCodec</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">queue</span>: <span class="ident">VecDeque</span><span class="op">&lt;</span><span class="ident">oneshot::Sender</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>,
}
<span class="kw">impl</span> <span class="ident">RedisActor</span> {
@ -185,15 +185,15 @@
<span class="kw">let</span> <span class="ident">backoff</span> <span class="op">=</span> <span class="ident">ExponentialBackoff</span> {
<span class="ident">max_elapsed_time</span>: <span class="prelude-val">None</span>,
..<span class="ident">Default</span>::<span class="ident">default</span>()
..<span class="ident">Default::default</span>()
};
<span class="ident">Supervisor</span>::<span class="ident">start</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">RedisActor</span> {
<span class="ident">Supervisor::start</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">RedisActor</span> {
<span class="ident">addr</span>,
<span class="ident">connector</span>: <span class="ident">service</span>(<span class="ident">default_connector</span>()),
<span class="ident">cell</span>: <span class="prelude-val">None</span>,
<span class="ident">backoff</span>,
<span class="ident">queue</span>: <span class="ident">VecDeque</span>::<span class="ident">new</span>(),
<span class="ident">queue</span>: <span class="ident">VecDeque::new</span>(),
})
}
}
@ -202,28 +202,28 @@
<span class="kw">type</span> <span class="ident">Context</span> <span class="op">=</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">started</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span>) {
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">Connect</span>::<span class="ident">new</span>(<span class="self">self</span>.<span class="ident">addr</span>.<span class="ident">to_owned</span>());
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">Connect::new</span>(<span class="self">self</span>.<span class="ident">addr</span>.<span class="ident">to_owned</span>());
<span class="self">self</span>.<span class="ident">connector</span>
.<span class="ident">call</span>(<span class="ident">req</span>)
.<span class="ident">into_actor</span>(<span class="self">self</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">res</span>, <span class="ident">act</span>, <span class="ident">ctx</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">res</span> {
<span class="prelude-val">Ok</span>(<span class="ident">conn</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">conn</span>.<span class="ident">into_parts</span>().<span class="number">0</span>;
<span class="macro">info</span><span class="macro">!</span>(<span class="string">&quot;Connected to redis server: {}&quot;</span>, <span class="ident">act</span>.<span class="ident">addr</span>);
<span class="macro">info!</span>(<span class="string">&quot;Connected to redis server: {}&quot;</span>, <span class="ident">act</span>.<span class="ident">addr</span>);
<span class="kw">let</span> (<span class="ident">r</span>, <span class="ident">w</span>) <span class="op">=</span> <span class="ident">split</span>(<span class="ident">stream</span>);
<span class="comment">// configure write side of the connection</span>
<span class="kw">let</span> <span class="ident">framed</span> <span class="op">=</span> <span class="ident">actix</span>::<span class="ident">io</span>::<span class="ident">FramedWrite</span>::<span class="ident">new</span>(<span class="ident">w</span>, <span class="ident">RespCodec</span>, <span class="ident">ctx</span>);
<span class="kw">let</span> <span class="ident">framed</span> <span class="op">=</span> <span class="ident">actix::io::FramedWrite::new</span>(<span class="ident">w</span>, <span class="ident">RespCodec</span>, <span class="ident">ctx</span>);
<span class="ident">act</span>.<span class="ident">cell</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">framed</span>);
<span class="comment">// read side of the connection</span>
<span class="ident">ctx</span>.<span class="ident">add_stream</span>(<span class="ident">FramedRead</span>::<span class="ident">new</span>(<span class="ident">r</span>, <span class="ident">RespCodec</span>));
<span class="ident">ctx</span>.<span class="ident">add_stream</span>(<span class="ident">FramedRead::new</span>(<span class="ident">r</span>, <span class="ident">RespCodec</span>));
<span class="ident">act</span>.<span class="ident">backoff</span>.<span class="ident">reset</span>();
}
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;Can not connect to redis server: {}&quot;</span>, <span class="ident">err</span>);
<span class="macro">error!</span>(<span class="string">&quot;Can not connect to redis server: {}&quot;</span>, <span class="ident">err</span>);
<span class="comment">// re-connect with backoff time.</span>
<span class="comment">// we stop current context, supervisor will restart it.</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">timeout</span>) <span class="op">=</span> <span class="ident">act</span>.<span class="ident">backoff</span>.<span class="ident">next_backoff</span>() {
@ -236,23 +236,23 @@
}
<span class="kw">impl</span> <span class="ident">Supervised</span> <span class="kw">for</span> <span class="ident">RedisActor</span> {
<span class="kw">fn</span> <span class="ident">restarting</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span>::<span class="ident">Context</span>) {
<span class="kw">fn</span> <span class="ident">restarting</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="ident">::Context</span>) {
<span class="self">self</span>.<span class="ident">cell</span>.<span class="ident">take</span>();
<span class="kw">for</span> <span class="ident">tx</span> <span class="kw">in</span> <span class="self">self</span>.<span class="ident">queue</span>.<span class="ident">drain</span>(..) {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">tx</span>.<span class="ident">send</span>(<span class="prelude-val">Err</span>(<span class="ident">Error</span>::<span class="ident">Disconnected</span>));
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">tx</span>.<span class="ident">send</span>(<span class="prelude-val">Err</span>(<span class="ident">Error::Disconnected</span>));
}
}
}
<span class="kw">impl</span> <span class="ident">actix</span>::<span class="ident">io</span>::<span class="ident">WriteHandler</span><span class="op">&lt;</span><span class="ident">io</span>::<span class="ident">Error</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisActor</span> {
<span class="kw">fn</span> <span class="ident">error</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">err</span>: <span class="ident">io</span>::<span class="ident">Error</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span>::<span class="ident">Context</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Running</span> {
<span class="macro">warn</span><span class="macro">!</span>(<span class="string">&quot;Redis connection dropped: {} error: {}&quot;</span>, <span class="self">self</span>.<span class="ident">addr</span>, <span class="ident">err</span>);
<span class="ident">Running</span>::<span class="ident">Stop</span>
<span class="kw">impl</span> <span class="ident">actix::io::WriteHandler</span><span class="op">&lt;</span><span class="ident">io::Error</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisActor</span> {
<span class="kw">fn</span> <span class="ident">error</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">err</span>: <span class="ident">io::Error</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="ident">::Context</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Running</span> {
<span class="macro">warn!</span>(<span class="string">&quot;Redis connection dropped: {} error: {}&quot;</span>, <span class="self">self</span>.<span class="ident">addr</span>, <span class="ident">err</span>);
<span class="ident">Running::Stop</span>
}
}
<span class="kw">impl</span> <span class="ident">StreamHandler</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">RespError</span><span class="op">&gt;</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisActor</span> {
<span class="kw">fn</span> <span class="ident">handle</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">msg</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">RespError</span><span class="op">&gt;</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span>::<span class="ident">Context</span>) {
<span class="kw">fn</span> <span class="ident">handle</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">msg</span>: <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">RespError</span><span class="op">&gt;</span>, <span class="ident">ctx</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="ident">::Context</span>) {
<span class="kw">match</span> <span class="ident">msg</span> {
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">tx</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">queue</span>.<span class="ident">pop_front</span>() {
@ -272,16 +272,16 @@
<span class="kw">impl</span> <span class="ident">Handler</span><span class="op">&lt;</span><span class="ident">Command</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisActor</span> {
<span class="kw">type</span> <span class="prelude-ty">Result</span> <span class="op">=</span> <span class="ident">ResponseFuture</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">RespValue</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">handle</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">msg</span>: <span class="ident">Command</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span>::<span class="ident">Context</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="prelude-ty">Result</span> {
<span class="kw">let</span> (<span class="ident">tx</span>, <span class="ident">rx</span>) <span class="op">=</span> <span class="ident">oneshot</span>::<span class="ident">channel</span>();
<span class="kw">fn</span> <span class="ident">handle</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">msg</span>: <span class="ident">Command</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="ident">::Context</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Result</span> {
<span class="kw">let</span> (<span class="ident">tx</span>, <span class="ident">rx</span>) <span class="op">=</span> <span class="ident">oneshot::channel</span>();
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">cell</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">cell</span> {
<span class="self">self</span>.<span class="ident">queue</span>.<span class="ident">push_back</span>(<span class="ident">tx</span>);
<span class="ident">cell</span>.<span class="ident">write</span>(<span class="ident">msg</span>.<span class="number">0</span>);
} <span class="kw">else</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">tx</span>.<span class="ident">send</span>(<span class="prelude-val">Err</span>(<span class="ident">Error</span>::<span class="ident">NotConnected</span>));
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">tx</span>.<span class="ident">send</span>(<span class="prelude-val">Err</span>(<span class="ident">Error::NotConnected</span>));
}
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="kw">async</span> <span class="kw">move</span> { <span class="ident">rx</span>.<span class="kw">await</span>.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">Error</span>::<span class="ident">Disconnected</span>)<span class="question-mark">?</span> })
<span class="ident">Box::pin</span>(<span class="kw">async</span> <span class="kw">move</span> { <span class="ident">rx</span>.<span class="kw">await</span>.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="ident">Error::Disconnected</span>)<span class="question-mark">?</span> })
}
}
</pre></div>

View File

@ -708,22 +708,22 @@
<span id="705">705</span>
<span id="706">706</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections</span>::<span class="ident">HashMap</span>, <span class="ident">iter</span>, <span class="ident">rc</span>::<span class="ident">Rc</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections::HashMap</span>, <span class="ident">iter</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix::prelude</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_service</span>::{<span class="ident">Service</span>, <span class="ident">Transform</span>};
<span class="kw">use</span> <span class="ident">actix_session</span>::{<span class="ident">Session</span>, <span class="ident">SessionStatus</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>::{<span class="self">self</span>, <span class="ident">HeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web::cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>};
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>::{<span class="self">self</span>, <span class="ident">HeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">error</span>, <span class="ident">Error</span>, <span class="ident">HttpMessage</span>};
<span class="kw">use</span> <span class="ident">futures_core</span>::<span class="ident">future</span>::<span class="ident">LocalBoxFuture</span>;
<span class="kw">use</span> <span class="ident">rand</span>::{<span class="ident">distributions</span>::<span class="ident">Alphanumeric</span>, <span class="ident">rngs</span>::<span class="ident">OsRng</span>, <span class="ident">Rng</span>};
<span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">resp</span>::<span class="ident">RespValue</span>;
<span class="kw">use</span> <span class="ident">redis_async</span>::<span class="ident">resp_array</span>;
<span class="kw">use</span> <span class="ident">futures_core::future::LocalBoxFuture</span>;
<span class="kw">use</span> <span class="ident">rand</span>::{<span class="ident">distributions::Alphanumeric</span>, <span class="ident">rngs::OsRng</span>, <span class="ident">Rng</span>};
<span class="kw">use</span> <span class="ident">redis_async::resp::RespValue</span>;
<span class="kw">use</span> <span class="ident">redis_async::resp_array</span>;
<span class="kw">use</span> <span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>, <span class="ident">OffsetDateTime</span>};
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">redis</span>::{<span class="ident">Command</span>, <span class="ident">RedisActor</span>};
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::redis</span>::{<span class="ident">Command</span>, <span class="ident">RedisActor</span>};
<span class="doccomment">/// Use redis as session storage.</span>
<span class="doccomment">///</span>
@ -739,16 +739,16 @@
<span class="doccomment">///</span>
<span class="doccomment">/// * `addr` - address of the redis server</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="ident">addr</span>: <span class="ident">S</span>, <span class="ident">key</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>]) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">RedisSession</span> {
<span class="ident">RedisSession</span>(<span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">Inner</span> {
<span class="ident">key</span>: <span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="ident">key</span>),
<span class="ident">cache_keygen</span>: <span class="ident">Box</span>::<span class="ident">new</span>(<span class="op">|</span><span class="ident">key</span>: <span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">|</span> <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;session:{}&quot;</span>, <span class="kw-2">&amp;</span><span class="ident">key</span>)),
<span class="ident">RedisSession</span>(<span class="ident">Rc::new</span>(<span class="ident">Inner</span> {
<span class="ident">key</span>: <span class="ident">Key::derive_from</span>(<span class="ident">key</span>),
<span class="ident">cache_keygen</span>: <span class="ident">Box::new</span>(<span class="op">|</span><span class="ident">key</span>: <span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">|</span> <span class="macro">format!</span>(<span class="string">&quot;session:{}&quot;</span>, <span class="kw-2">&amp;</span><span class="ident">key</span>)),
<span class="ident">ttl</span>: <span class="string">&quot;7200&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">addr</span>: <span class="ident">RedisActor</span>::<span class="ident">start</span>(<span class="ident">addr</span>),
<span class="ident">addr</span>: <span class="ident">RedisActor::start</span>(<span class="ident">addr</span>),
<span class="ident">name</span>: <span class="string">&quot;actix-session&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">path</span>: <span class="string">&quot;/&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">domain</span>: <span class="prelude-val">None</span>,
<span class="ident">secure</span>: <span class="bool-val">false</span>,
<span class="ident">max_age</span>: <span class="prelude-val">Some</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">7</span>)),
<span class="ident">max_age</span>: <span class="prelude-val">Some</span>(<span class="ident">Duration::days</span>(<span class="number">7</span>)),
<span class="ident">same_site</span>: <span class="prelude-val">None</span>,
<span class="ident">http_only</span>: <span class="bool-val">true</span>,
}))
@ -756,25 +756,25 @@
<span class="doccomment">/// Set time to live in seconds for session value.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">ttl</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">ttl</span>: <span class="ident">u32</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">ttl</span> <span class="op">=</span> <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">ttl</span>);
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">ttl</span> <span class="op">=</span> <span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">ttl</span>);
<span class="self">self</span>
}
<span class="doccomment">/// Set custom cookie name for session ID.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_name</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">name</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">name</span> <span class="op">=</span> <span class="ident">name</span>.<span class="ident">to_owned</span>();
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">name</span> <span class="op">=</span> <span class="ident">name</span>.<span class="ident">to_owned</span>();
<span class="self">self</span>
}
<span class="doccomment">/// Set custom cookie path.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_path</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">path</span> <span class="op">=</span> <span class="ident">path</span>.<span class="ident">to_owned</span>();
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">path</span> <span class="op">=</span> <span class="ident">path</span>.<span class="ident">to_owned</span>();
<span class="self">self</span>
}
<span class="doccomment">/// Set custom cookie domain.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_domain</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">domain</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">domain</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">domain</span>.<span class="ident">to_owned</span>());
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">domain</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">domain</span>.<span class="ident">to_owned</span>());
<span class="self">self</span>
}
@ -785,7 +785,7 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Default is false.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_secure</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">secure</span>: <span class="ident">bool</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">secure</span> <span class="op">=</span> <span class="ident">secure</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">secure</span> <span class="op">=</span> <span class="ident">secure</span>;
<span class="self">self</span>
}
@ -793,7 +793,7 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Use `None` for session-only cookies.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_max_age</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">max_age</span>: <span class="kw">impl</span> <span class="ident">Into</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Duration</span><span class="op">&gt;</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">max_age</span> <span class="op">=</span> <span class="ident">max_age</span>.<span class="ident">into</span>();
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">max_age</span> <span class="op">=</span> <span class="ident">max_age</span>.<span class="ident">into</span>();
<span class="self">self</span>
}
@ -801,7 +801,7 @@
<span class="doccomment">///</span>
<span class="doccomment">/// By default, the attribute is omitted.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_same_site</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">same_site</span>: <span class="ident">SameSite</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">same_site</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">same_site</span>);
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">same_site</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">same_site</span>);
<span class="self">self</span>
}
@ -809,13 +809,13 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Default is true.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cookie_http_only</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">http_only</span>: <span class="ident">bool</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">http_only</span> <span class="op">=</span> <span class="ident">http_only</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">http_only</span> <span class="op">=</span> <span class="ident">http_only</span>;
<span class="self">self</span>
}
<span class="doccomment">/// Set a custom cache key generation strategy, expecting session key as input.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cache_keygen</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">keygen</span>: <span class="ident">Box</span><span class="op">&lt;</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">String</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">cache_keygen</span> <span class="op">=</span> <span class="ident">keygen</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">cache_keygen</span> <span class="op">=</span> <span class="ident">keygen</span>;
<span class="self">self</span>
}
}
@ -823,20 +823,20 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Transform</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisSession</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S</span>::<span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S::Error</span>;
<span class="kw">type</span> <span class="ident">Transform</span> <span class="op">=</span> <span class="ident">RedisSessionMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">InitError</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Transform</span>, <span class="self">Self</span>::<span class="ident">InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Transform</span>, <span class="self">Self</span><span class="ident">::InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">clone</span>();
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="kw">async</span> {
<span class="ident">Box::pin</span>(<span class="kw">async</span> {
<span class="prelude-val">Ok</span>(<span class="ident">RedisSessionMiddleware</span> {
<span class="ident">service</span>: <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">service</span>),
<span class="ident">service</span>: <span class="ident">Rc::new</span>(<span class="ident">service</span>),
<span class="ident">inner</span>,
})
})
@ -852,24 +852,24 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">RedisSessionMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">B</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Response</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Response</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="ident">actix_service</span>::<span class="macro">forward_ready</span><span class="macro">!</span>(<span class="ident">service</span>);
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>);
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">service</span>);
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="ident">Box::pin</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">load</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">state</span>, <span class="ident">value</span>)) <span class="op">=</span> <span class="ident">state</span> {
<span class="ident">Session</span>::<span class="ident">set_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>, <span class="ident">state</span>);
<span class="ident">Session::set_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>, <span class="ident">state</span>);
<span class="prelude-val">Some</span>(<span class="ident">value</span>)
} <span class="kw">else</span> {
<span class="prelude-val">None</span>
@ -877,8 +877,8 @@
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">call</span>(<span class="ident">req</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">match</span> <span class="ident">Session</span>::<span class="ident">get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>) {
(<span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">match</span> <span class="ident">Session::get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>) {
(<span class="ident">SessionStatus::Unchanged</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">value</span>.<span class="ident">is_none</span>() {
<span class="comment">// implies the session is new</span>
<span class="ident">inner</span>.<span class="ident">update</span>(<span class="ident">res</span>, <span class="ident">state</span>, <span class="ident">value</span>).<span class="kw">await</span>
@ -887,21 +887,21 @@
}
}
(<span class="ident">SessionStatus</span>::<span class="ident">Changed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">inner</span>.<span class="ident">update</span>(<span class="ident">res</span>, <span class="ident">state</span>, <span class="ident">value</span>).<span class="kw">await</span>,
(<span class="ident">SessionStatus::Changed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">inner</span>.<span class="ident">update</span>(<span class="ident">res</span>, <span class="ident">state</span>, <span class="ident">value</span>).<span class="kw">await</span>,
(<span class="ident">SessionStatus</span>::<span class="ident">Purged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
(<span class="ident">SessionStatus::Purged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">value</span> {
<span class="ident">inner</span>.<span class="ident">clear_cache</span>(<span class="ident">val</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">match</span> <span class="ident">inner</span>.<span class="ident">remove_cookie</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>) {
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(<span class="ident">res</span>),
<span class="prelude-val">Err</span>(<span class="ident">_err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>(<span class="ident">_err</span>)),
<span class="prelude-val">Err</span>(<span class="ident">_err</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">error::ErrorInternalServerError</span>(<span class="ident">_err</span>)),
}
} <span class="kw">else</span> {
<span class="prelude-val">Err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>(<span class="string">&quot;unexpected&quot;</span>))
<span class="prelude-val">Err</span>(<span class="ident">error::ErrorInternalServerError</span>(<span class="string">&quot;unexpected&quot;</span>))
}
}
(<span class="ident">SessionStatus</span>::<span class="ident">Renewed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
(<span class="ident">SessionStatus::Renewed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">value</span> {
<span class="ident">inner</span>.<span class="ident">clear_cache</span>(<span class="ident">val</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">inner</span>.<span class="ident">update</span>(<span class="ident">res</span>, <span class="ident">state</span>, <span class="prelude-val">None</span>).<span class="kw">await</span>
@ -944,7 +944,7 @@
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cookie</span>) <span class="op">=</span>
<span class="ident">cookies</span>.<span class="ident">iter</span>().<span class="ident">find</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">cookie</span><span class="op">|</span> <span class="ident">cookie</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">name</span>)
{
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="ident">jar</span>.<span class="ident">add_original</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>());
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cookie</span>) <span class="op">=</span> <span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>) {
@ -961,22 +961,22 @@
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="self">self</span>
.<span class="ident">addr</span>
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array</span><span class="macro">!</span>[<span class="string">&quot;GET&quot;</span>, <span class="ident">cache_key</span>]))
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array!</span>[<span class="string">&quot;GET&quot;</span>, <span class="ident">cache_key</span>]))
.<span class="kw">await</span>
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>;
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>;
<span class="kw">match</span> <span class="ident">val</span> {
<span class="ident">RespValue</span>::<span class="ident">Error</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>(<span class="ident">err</span>));
<span class="ident">RespValue::Error</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">error::ErrorInternalServerError</span>(<span class="ident">err</span>));
}
<span class="ident">RespValue</span>::<span class="ident">SimpleString</span>(<span class="ident">s</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">s</span>) {
<span class="ident">RespValue::SimpleString</span>(<span class="ident">s</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">s</span>) {
<span class="kw">return</span> <span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>((<span class="ident">val</span>, <span class="ident">value</span>)));
}
}
<span class="ident">RespValue</span>::<span class="ident">BulkString</span>(<span class="ident">s</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_slice</span>(<span class="kw-2">&amp;</span><span class="ident">s</span>) {
<span class="ident">RespValue::BulkString</span>(<span class="ident">s</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json::from_slice</span>(<span class="kw-2">&amp;</span><span class="ident">s</span>) {
<span class="kw">return</span> <span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>((<span class="ident">val</span>, <span class="ident">value</span>)));
}
}
@ -995,14 +995,14 @@
<span class="kw">let</span> (<span class="ident">value</span>, <span class="ident">jar</span>) <span class="op">=</span> <span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>) <span class="op">=</span> <span class="ident">value</span> {
(<span class="ident">value</span>, <span class="prelude-val">None</span>)
} <span class="kw">else</span> {
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">iter</span>::<span class="ident">repeat</span>(())
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">iter::repeat</span>(())
.<span class="ident">map</span>(<span class="op">|</span>()<span class="op">|</span> <span class="ident">OsRng</span>.<span class="ident">sample</span>(<span class="ident">Alphanumeric</span>))
.<span class="ident">take</span>(<span class="number">32</span>)
.<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>();
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from_utf8</span>(<span class="ident">value</span>).<span class="ident">unwrap_or_default</span>();
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">String::from_utf8</span>(<span class="ident">value</span>).<span class="ident">unwrap_or_default</span>();
<span class="comment">// prepare session id cookie</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie</span>::<span class="ident">new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">value</span>.<span class="ident">clone</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie::new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">value</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_path</span>(<span class="self">self</span>.<span class="ident">path</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_secure</span>(<span class="self">self</span>.<span class="ident">secure</span>);
<span class="ident">cookie</span>.<span class="ident">set_http_only</span>(<span class="self">self</span>.<span class="ident">http_only</span>);
@ -1020,7 +1020,7 @@
}
<span class="comment">// set cookie</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">add</span>(<span class="ident">cookie</span>);
(<span class="ident">value</span>, <span class="prelude-val">Some</span>(<span class="ident">jar</span>))
@ -1030,23 +1030,23 @@
<span class="kw">let</span> <span class="ident">state</span>: <span class="ident">HashMap</span><span class="op">&lt;</span><span class="kw">_</span>, <span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">state</span>.<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">state</span>) {
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="ident">state</span>) {
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>()),
<span class="prelude-val">Ok</span>(<span class="ident">body</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">body</span>,
};
<span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command</span>(<span class="macro">resp_array</span><span class="macro">!</span>[<span class="string">&quot;SET&quot;</span>, <span class="ident">cache_key</span>, <span class="ident">body</span>, <span class="string">&quot;EX&quot;</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">ttl</span>]);
<span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command</span>(<span class="macro">resp_array!</span>[<span class="string">&quot;SET&quot;</span>, <span class="ident">cache_key</span>, <span class="ident">body</span>, <span class="string">&quot;EX&quot;</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">ttl</span>]);
<span class="self">self</span>.<span class="ident">addr</span>
.<span class="ident">send</span>(<span class="ident">cmd</span>)
.<span class="kw">await</span>
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>;
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>;
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">jar</span>) <span class="op">=</span> <span class="ident">jar</span> {
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">jar</span>.<span class="ident">delta</span>() {
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>, <span class="ident">val</span>);
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header::SET_COOKIE</span>, <span class="ident">val</span>);
}
}
@ -1059,14 +1059,14 @@
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="self">self</span>
.<span class="ident">addr</span>
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array</span><span class="macro">!</span>[<span class="string">&quot;DEL&quot;</span>, <span class="ident">cache_key</span>]))
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array!</span>[<span class="string">&quot;DEL&quot;</span>, <span class="ident">cache_key</span>]))
.<span class="kw">await</span>
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>;
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>;
<span class="kw">match</span> <span class="ident">res</span> {
<span class="comment">// redis responds with number of deleted records</span>
<span class="prelude-val">Ok</span>(<span class="ident">RespValue</span>::<span class="ident">Integer</span>(<span class="ident">x</span>)) <span class="kw">if</span> <span class="ident">x</span> <span class="op">&gt;</span> <span class="number">0</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(()),
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>(
<span class="prelude-val">Ok</span>(<span class="ident">RespValue::Integer</span>(<span class="ident">x</span>)) <span class="kw">if</span> <span class="ident">x</span> <span class="op">&gt;</span> <span class="number">0</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(()),
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Err</span>(<span class="ident">error::ErrorInternalServerError</span>(
<span class="string">&quot;failed to remove session from cache&quot;</span>,
)),
}
@ -1074,14 +1074,14 @@
<span class="doccomment">/// Invalidates session cookie.</span>
<span class="kw">fn</span> <span class="ident">remove_cookie</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">res</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie</span>::<span class="ident">named</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie::named</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_value</span>(<span class="string">&quot;&quot;</span>);
<span class="ident">cookie</span>.<span class="ident">set_max_age</span>(<span class="ident">Duration</span>::<span class="ident">zero</span>());
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime</span>::<span class="ident">now_utc</span>() <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">365</span>));
<span class="ident">cookie</span>.<span class="ident">set_max_age</span>(<span class="ident">Duration::zero</span>());
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime::now_utc</span>() <span class="op">-</span> <span class="ident">Duration::days</span>(<span class="number">365</span>));
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())
.<span class="ident">map_err</span>(<span class="ident">error</span>::<span class="ident">ErrorInternalServerError</span>)<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>, <span class="ident">val</span>);
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())
.<span class="ident">map_err</span>(<span class="ident">error::ErrorInternalServerError</span>)<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">header::SET_COOKIE</span>, <span class="ident">val</span>);
<span class="prelude-val">Ok</span>(())
}
@ -1090,14 +1090,14 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">test</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_session</span>::<span class="ident">Session</span>;
<span class="kw">use</span> <span class="ident">actix_session::Session</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">middleware</span>, <span class="ident">web</span>,
<span class="ident">web</span>::{<span class="ident">get</span>, <span class="ident">post</span>, <span class="ident">resource</span>},
<span class="ident">App</span>, <span class="ident">HttpResponse</span>, <span class="prelude-ty">Result</span>,
};
<span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">Deserialize</span>, <span class="ident">Serialize</span>};
<span class="kw">use</span> <span class="ident">serde_json</span>::<span class="ident">json</span>;
<span class="kw">use</span> <span class="ident">serde_json::json</span>;
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Serialize</span>, <span class="ident">Deserialize</span>, <span class="ident">Debug</span>, <span class="ident">PartialEq</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">IndexResponse</span> {
@ -1112,7 +1112,7 @@
.<span class="ident">unwrap_or</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>))
.<span class="ident">unwrap_or</span>(<span class="number">0</span>);
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> { <span class="ident">user_id</span>, <span class="ident">counter</span> }))
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> { <span class="ident">user_id</span>, <span class="ident">counter</span> }))
}
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">do_something</span>(<span class="ident">session</span>: <span class="ident">Session</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">HttpResponse</span><span class="op">&gt;</span> {
@ -1123,7 +1123,7 @@
.<span class="ident">map_or</span>(<span class="number">1</span>, <span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="ident">inner</span> <span class="op">+</span> <span class="number">1</span>);
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="kw-2">&amp;</span><span class="ident">counter</span>)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> { <span class="ident">user_id</span>, <span class="ident">counter</span> }))
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> { <span class="ident">user_id</span>, <span class="ident">counter</span> }))
}
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Deserialize</span>)]</span>
@ -1132,7 +1132,7 @@
}
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">login</span>(
<span class="ident">user_id</span>: <span class="ident">web</span>::<span class="ident">Json</span><span class="op">&lt;</span><span class="ident">Identity</span><span class="op">&gt;</span>,
<span class="ident">user_id</span>: <span class="ident">web::Json</span><span class="op">&lt;</span><span class="ident">Identity</span><span class="op">&gt;</span>,
<span class="ident">session</span>: <span class="ident">Session</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">HttpResponse</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">id</span> <span class="op">=</span> <span class="ident">user_id</span>.<span class="ident">into_inner</span>().<span class="ident">user_id</span>;
@ -1144,7 +1144,7 @@
.<span class="ident">unwrap_or</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>))
.<span class="ident">unwrap_or</span>(<span class="number">0</span>);
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> {
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">json</span>(<span class="kw-2">&amp;</span><span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">Some</span>(<span class="ident">id</span>),
<span class="ident">counter</span>,
}))
@ -1154,13 +1154,13 @@
<span class="kw">let</span> <span class="ident">id</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>(<span class="string">&quot;user_id&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">x</span>) <span class="op">=</span> <span class="ident">id</span> {
<span class="ident">session</span>.<span class="ident">purge</span>();
<span class="prelude-val">Ok</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;Logged out: {}&quot;</span>, <span class="ident">x</span>).<span class="ident">into</span>())
<span class="prelude-val">Ok</span>(<span class="macro">format!</span>(<span class="string">&quot;Logged out: {}&quot;</span>, <span class="ident">x</span>).<span class="ident">into</span>())
} <span class="kw">else</span> {
<span class="prelude-val">Ok</span>(<span class="string">&quot;Could not log out anonymous user&quot;</span>.<span class="ident">into</span>())
}
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_session_workflow</span>() {
<span class="comment">// Step 1: GET index</span>
<span class="comment">// - set-cookie actix-session will be in response (session cookie #1)</span>
@ -1193,13 +1193,13 @@
<span class="comment">// - set-cookie actix-session will be in response (session cookie #3)</span>
<span class="comment">// - response should be: {&quot;counter&quot;: 0, &quot;user_id&quot;: None}</span>
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">actix_test</span>::<span class="ident">start</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">actix_test::start</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(
<span class="ident">RedisSession</span>::<span class="ident">new</span>(<span class="string">&quot;127.0.0.1:6379&quot;</span>, <span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="ident">RedisSession::new</span>(<span class="string">&quot;127.0.0.1:6379&quot;</span>, <span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">cookie_name</span>(<span class="string">&quot;test-session&quot;</span>),
)
.<span class="ident">wrap</span>(<span class="ident">middleware</span>::<span class="ident">Logger</span>::<span class="ident">default</span>())
.<span class="ident">wrap</span>(<span class="ident">middleware::Logger::default</span>())
.<span class="ident">service</span>(<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">route</span>(<span class="ident">get</span>().<span class="ident">to</span>(<span class="ident">index</span>)))
.<span class="ident">service</span>(<span class="ident">resource</span>(<span class="string">&quot;/do_something&quot;</span>).<span class="ident">route</span>(<span class="ident">post</span>().<span class="ident">to</span>(<span class="ident">do_something</span>)))
.<span class="ident">service</span>(<span class="ident">resource</span>(<span class="string">&quot;/login&quot;</span>).<span class="ident">route</span>(<span class="ident">post</span>().<span class="ident">to</span>(<span class="ident">login</span>)))
@ -1219,14 +1219,14 @@
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_1</span> <span class="op">=</span> <span class="ident">resp_1</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_1</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">None</span>,
<span class="ident">counter</span>: <span class="number">0</span>
}
);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cookie_1</span>.<span class="ident">max_age</span>(), <span class="prelude-val">Some</span>(<span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">7</span>)));
<span class="macro">assert_eq!</span>(<span class="ident">cookie_1</span>.<span class="ident">max_age</span>(), <span class="prelude-val">Some</span>(<span class="ident">Duration::days</span>(<span class="number">7</span>)));
<span class="comment">// Step 2: GET index, including session cookie #1 in request</span>
<span class="comment">// - set-cookie will *not* be in response</span>
@ -1239,7 +1239,7 @@
.<span class="ident">clone</span>()
.<span class="ident">into_iter</span>()
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cookie_2</span>, <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(<span class="ident">cookie_2</span>, <span class="prelude-val">None</span>);
<span class="comment">// Step 3: POST to do_something, including session cookie #1 in request</span>
<span class="comment">// - adds new session state in redis: {&quot;counter&quot;: 1}</span>
@ -1247,7 +1247,7 @@
<span class="kw">let</span> <span class="ident">req_3</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">post</span>(<span class="string">&quot;/do_something&quot;</span>).<span class="ident">cookie</span>(<span class="ident">cookie_1</span>.<span class="ident">clone</span>()).<span class="ident">send</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_3</span> <span class="op">=</span> <span class="ident">req_3</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_3</span> <span class="op">=</span> <span class="ident">resp_3</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_3</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">None</span>,
@ -1261,7 +1261,7 @@
<span class="kw">let</span> <span class="ident">req_4</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">post</span>(<span class="string">&quot;/do_something&quot;</span>).<span class="ident">cookie</span>(<span class="ident">cookie_1</span>.<span class="ident">clone</span>()).<span class="ident">send</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_4</span> <span class="op">=</span> <span class="ident">req_4</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_4</span> <span class="op">=</span> <span class="ident">resp_4</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_4</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">None</span>,
@ -1275,7 +1275,7 @@
<span class="kw">let</span> <span class="ident">req_5</span> <span class="op">=</span> <span class="ident">srv</span>
.<span class="ident">post</span>(<span class="string">&quot;/login&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie_1</span>.<span class="ident">clone</span>())
.<span class="ident">send_json</span>(<span class="kw-2">&amp;</span><span class="macro">json</span><span class="macro">!</span>({<span class="string">&quot;user_id&quot;</span>: <span class="string">&quot;ferris&quot;</span>}));
.<span class="ident">send_json</span>(<span class="kw-2">&amp;</span><span class="macro">json!</span>({<span class="string">&quot;user_id&quot;</span>: <span class="string">&quot;ferris&quot;</span>}));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_5</span> <span class="op">=</span> <span class="ident">req_5</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">cookie_2</span> <span class="op">=</span> <span class="ident">resp_5</span>
.<span class="ident">cookies</span>()
@ -1284,10 +1284,10 @@
.<span class="ident">into_iter</span>()
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert_ne</span><span class="macro">!</span>(<span class="ident">cookie_1</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
<span class="macro">assert_ne!</span>(<span class="ident">cookie_1</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
<span class="kw">let</span> <span class="ident">result_5</span> <span class="op">=</span> <span class="ident">resp_5</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_5</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.<span class="ident">into</span>()),
@ -1300,7 +1300,7 @@
<span class="kw">let</span> <span class="ident">req_6</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">get</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">cookie</span>(<span class="ident">cookie_2</span>.<span class="ident">clone</span>()).<span class="ident">send</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_6</span> <span class="op">=</span> <span class="ident">req_6</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_6</span> <span class="op">=</span> <span class="ident">resp_6</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_6</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.<span class="ident">into</span>()),
@ -1314,7 +1314,7 @@
<span class="kw">let</span> <span class="ident">req_7</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">post</span>(<span class="string">&quot;/do_something&quot;</span>).<span class="ident">cookie</span>(<span class="ident">cookie_2</span>.<span class="ident">clone</span>()).<span class="ident">send</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_7</span> <span class="op">=</span> <span class="ident">req_7</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_7</span> <span class="op">=</span> <span class="ident">resp_7</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_7</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.<span class="ident">into</span>()),
@ -1335,14 +1335,14 @@
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_8</span> <span class="op">=</span> <span class="ident">resp_8</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_8</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">None</span>,
<span class="ident">counter</span>: <span class="number">0</span>
}
);
<span class="macro">assert_ne</span><span class="macro">!</span>(<span class="ident">cookie_3</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
<span class="macro">assert_ne!</span>(<span class="ident">cookie_3</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
<span class="comment">// Step 9: POST to logout, including session cookie #2</span>
<span class="comment">// - set-cookie actix-session will be in response with session cookie #2</span>
@ -1356,8 +1356,8 @@
.<span class="ident">into_iter</span>()
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert_ne</span><span class="macro">!</span>(
<span class="ident">OffsetDateTime</span>::<span class="ident">now_utc</span>().<span class="ident">year</span>(),
<span class="macro">assert_ne!</span>(
<span class="ident">OffsetDateTime::now_utc</span>().<span class="ident">year</span>(),
<span class="ident">cookie_4</span>.<span class="ident">expires</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">t</span><span class="op">|</span> <span class="ident">t</span>.<span class="ident">year</span>()).<span class="ident">unwrap</span>()
);
@ -1367,7 +1367,7 @@
<span class="kw">let</span> <span class="ident">req_10</span> <span class="op">=</span> <span class="ident">srv</span>.<span class="ident">get</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">cookie</span>(<span class="ident">cookie_2</span>.<span class="ident">clone</span>()).<span class="ident">send</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">resp_10</span> <span class="op">=</span> <span class="ident">req_10</span>.<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">result_10</span> <span class="op">=</span> <span class="ident">resp_10</span>.<span class="ident">json</span>::<span class="op">&lt;</span><span class="ident">IndexResponse</span><span class="op">&gt;</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">assert_eq!</span>(
<span class="ident">result_10</span>,
<span class="ident">IndexResponse</span> {
<span class="ident">user_id</span>: <span class="prelude-val">None</span>,
@ -1382,22 +1382,22 @@
.<span class="ident">into_iter</span>()
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert_ne</span><span class="macro">!</span>(<span class="ident">cookie_5</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
<span class="macro">assert_ne!</span>(<span class="ident">cookie_5</span>.<span class="ident">value</span>(), <span class="ident">cookie_2</span>.<span class="ident">value</span>());
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_max_age_session_only</span>() {
<span class="comment">//</span>
<span class="comment">// Test that removing max_age results in a session-only cookie</span>
<span class="comment">//</span>
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">actix_test</span>::<span class="ident">start</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">actix_test::start</span>(<span class="op">|</span><span class="op">|</span> {
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(
<span class="ident">RedisSession</span>::<span class="ident">new</span>(<span class="string">&quot;127.0.0.1:6379&quot;</span>, <span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="ident">RedisSession::new</span>(<span class="string">&quot;127.0.0.1:6379&quot;</span>, <span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">cookie_name</span>(<span class="string">&quot;test-session&quot;</span>)
.<span class="ident">cookie_max_age</span>(<span class="prelude-val">None</span>),
)
.<span class="ident">wrap</span>(<span class="ident">middleware</span>::<span class="ident">Logger</span>::<span class="ident">default</span>())
.<span class="ident">wrap</span>(<span class="ident">middleware::Logger::default</span>())
.<span class="ident">service</span>(<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">route</span>(<span class="ident">get</span>().<span class="ident">to</span>(<span class="ident">index</span>)))
});
@ -1411,7 +1411,7 @@
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;test-session&quot;</span>)
.<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cookie</span>.<span class="ident">max_age</span>(), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(<span class="ident">cookie</span>.<span class="ident">max_age</span>(), <span class="prelude-val">None</span>);
}
}
</pre></div>

View File

@ -556,16 +556,16 @@
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Cookie based sessions. See docs for [`CookieSession`].</span>
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections</span>::<span class="ident">HashMap</span>, <span class="ident">rc</span>::<span class="ident">Rc</span>};
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections::HashMap</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix_service</span>::{<span class="ident">Service</span>, <span class="ident">Transform</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::{<span class="ident">header</span>::<span class="ident">SET_COOKIE</span>, <span class="ident">HeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web::cookie</span>::{<span class="ident">Cookie</span>, <span class="ident">CookieJar</span>, <span class="ident">Key</span>, <span class="ident">SameSite</span>};
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>};
<span class="kw">use</span> <span class="ident">actix_web::http</span>::{<span class="ident">header::SET_COOKIE</span>, <span class="ident">HeaderValue</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">Error</span>, <span class="ident">HttpMessage</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="ident">derive_more</span>::<span class="ident">Display</span>;
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ok</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">serde_json</span>::<span class="ident">error</span>::<span class="ident">Error</span> <span class="kw">as</span> <span class="ident">JsonError</span>;
<span class="kw">use</span> <span class="ident">derive_more::Display</span>;
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ok</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">serde_json::error::Error</span> <span class="kw">as</span> <span class="ident">JsonError</span>;
<span class="kw">use</span> <span class="ident">time</span>::{<span class="ident">Duration</span>, <span class="ident">OffsetDateTime</span>};
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">Session</span>, <span class="ident">SessionStatus</span>};
@ -607,7 +607,7 @@
<span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">key</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>], <span class="ident">security</span>: <span class="ident">CookieSecurity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSessionInner</span> {
<span class="ident">CookieSessionInner</span> {
<span class="ident">security</span>,
<span class="ident">key</span>: <span class="ident">Key</span>::<span class="ident">derive_from</span>(<span class="ident">key</span>),
<span class="ident">key</span>: <span class="ident">Key::derive_from</span>(<span class="ident">key</span>),
<span class="ident">name</span>: <span class="string">&quot;actix-session&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">path</span>: <span class="string">&quot;/&quot;</span>.<span class="ident">to_owned</span>(),
<span class="ident">domain</span>: <span class="prelude-val">None</span>,
@ -632,13 +632,13 @@
}
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span>
<span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">state</span>).<span class="ident">map_err</span>(<span class="ident">CookieSessionError</span>::<span class="ident">Serialize</span>)<span class="question-mark">?</span>;
<span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="ident">state</span>).<span class="ident">map_err</span>(<span class="ident">CookieSessionError::Serialize</span>)<span class="question-mark">?</span>;
<span class="kw">if</span> <span class="ident">value</span>.<span class="ident">len</span>() <span class="op">&gt;</span> <span class="number">4064</span> {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CookieSessionError</span>::<span class="ident">Overflow</span>.<span class="ident">into</span>());
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">CookieSessionError::Overflow</span>.<span class="ident">into</span>());
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie</span>::<span class="ident">new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">value</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie::new</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>(), <span class="ident">value</span>);
<span class="ident">cookie</span>.<span class="ident">set_path</span>(<span class="self">self</span>.<span class="ident">path</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_secure</span>(<span class="self">self</span>.<span class="ident">secure</span>);
<span class="ident">cookie</span>.<span class="ident">set_http_only</span>(<span class="self">self</span>.<span class="ident">http_only</span>);
@ -648,7 +648,7 @@
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">expires_in</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">expires_in</span> {
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime</span>::<span class="ident">now_utc</span>() <span class="op">+</span> <span class="ident">expires_in</span>);
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime::now_utc</span>() <span class="op">+</span> <span class="ident">expires_in</span>);
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">max_age</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">max_age</span> {
@ -659,15 +659,15 @@
<span class="ident">cookie</span>.<span class="ident">set_same_site</span>(<span class="ident">same_site</span>);
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">security</span> {
<span class="ident">CookieSecurity</span>::<span class="ident">Signed</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">add</span>(<span class="ident">cookie</span>),
<span class="ident">CookieSecurity</span>::<span class="ident">Private</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">add</span>(<span class="ident">cookie</span>),
<span class="ident">CookieSecurity::Signed</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">add</span>(<span class="ident">cookie</span>),
<span class="ident">CookieSecurity::Private</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">add</span>(<span class="ident">cookie</span>),
}
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">jar</span>.<span class="ident">delta</span>() {
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">encoded</span>().<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">encoded</span>().<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">SET_COOKIE</span>, <span class="ident">val</span>);
}
@ -676,13 +676,13 @@
<span class="doccomment">/// invalidates session cookie</span>
<span class="kw">fn</span> <span class="ident">remove_cookie</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">res</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie</span>::<span class="ident">named</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">Cookie::named</span>(<span class="self">self</span>.<span class="ident">name</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_path</span>(<span class="self">self</span>.<span class="ident">path</span>.<span class="ident">clone</span>());
<span class="ident">cookie</span>.<span class="ident">set_value</span>(<span class="string">&quot;&quot;</span>);
<span class="ident">cookie</span>.<span class="ident">set_max_age</span>(<span class="ident">Duration</span>::<span class="ident">zero</span>());
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime</span>::<span class="ident">now_utc</span>() <span class="op">-</span> <span class="ident">Duration</span>::<span class="ident">days</span>(<span class="number">365</span>));
<span class="ident">cookie</span>.<span class="ident">set_max_age</span>(<span class="ident">Duration::zero</span>());
<span class="ident">cookie</span>.<span class="ident">set_expires</span>(<span class="ident">OffsetDateTime::now_utc</span>() <span class="op">-</span> <span class="ident">Duration::days</span>(<span class="number">365</span>));
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">HeaderValue::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">cookie</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="ident">res</span>.<span class="ident">headers_mut</span>().<span class="ident">append</span>(<span class="ident">SET_COOKIE</span>, <span class="ident">val</span>);
<span class="prelude-val">Ok</span>(())
@ -692,18 +692,18 @@
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">cookies</span>) <span class="op">=</span> <span class="ident">req</span>.<span class="ident">cookies</span>() {
<span class="kw">for</span> <span class="ident">cookie</span> <span class="kw">in</span> <span class="ident">cookies</span>.<span class="ident">iter</span>() {
<span class="kw">if</span> <span class="ident">cookie</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">name</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">jar</span> <span class="op">=</span> <span class="ident">CookieJar::new</span>();
<span class="ident">jar</span>.<span class="ident">add_original</span>(<span class="ident">cookie</span>.<span class="ident">clone</span>());
<span class="kw">let</span> <span class="ident">cookie_opt</span> <span class="op">=</span> <span class="kw">match</span> <span class="self">self</span>.<span class="ident">security</span> {
<span class="ident">CookieSecurity</span>::<span class="ident">Signed</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>),
<span class="ident">CookieSecurity</span>::<span class="ident">Private</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">CookieSecurity::Signed</span> <span class="op">=</span><span class="op">&gt;</span> <span class="ident">jar</span>.<span class="ident">signed</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>),
<span class="ident">CookieSecurity::Private</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">jar</span>.<span class="ident">private</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">key</span>).<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">name</span>)
}
};
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">cookie</span>) <span class="op">=</span> <span class="ident">cookie_opt</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()) {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">serde_json::from_str</span>(<span class="ident">cookie</span>.<span class="ident">value</span>()) {
<span class="kw">return</span> (<span class="bool-val">false</span>, <span class="ident">val</span>);
}
}
@ -711,7 +711,7 @@
}
}
(<span class="bool-val">true</span>, <span class="ident">HashMap</span>::<span class="ident">new</span>())
(<span class="bool-val">true</span>, <span class="ident">HashMap::new</span>())
}
}
@ -761,9 +761,9 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Panics if key length is less than 32 bytes.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">signed</span>(<span class="ident">key</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>]) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">CookieSession</span>(<span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">CookieSessionInner</span>::<span class="ident">new</span>(
<span class="ident">CookieSession</span>(<span class="ident">Rc::new</span>(<span class="ident">CookieSessionInner::new</span>(
<span class="ident">key</span>,
<span class="ident">CookieSecurity</span>::<span class="ident">Signed</span>,
<span class="ident">CookieSecurity::Signed</span>,
)))
}
@ -771,27 +771,27 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Panics if key length is less than 32 bytes.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">private</span>(<span class="ident">key</span>: <span class="kw-2">&amp;</span>[<span class="ident">u8</span>]) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">CookieSession</span>(<span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">CookieSessionInner</span>::<span class="ident">new</span>(
<span class="ident">CookieSession</span>(<span class="ident">Rc::new</span>(<span class="ident">CookieSessionInner::new</span>(
<span class="ident">key</span>,
<span class="ident">CookieSecurity</span>::<span class="ident">Private</span>,
<span class="ident">CookieSecurity::Private</span>,
)))
}
<span class="doccomment">/// Sets the `path` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">path</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">path</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">into</span>();
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">path</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">into</span>();
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `name` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">name</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">name</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">into</span>();
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">name</span> <span class="op">=</span> <span class="ident">value</span>.<span class="ident">into</span>();
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `domain` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">domain</span><span class="op">&lt;</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">domain</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>.<span class="ident">into</span>());
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">domain</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>.<span class="ident">into</span>());
<span class="self">self</span>
}
@ -800,7 +800,7 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Useful when trying to comply with laws that require consent for setting cookies.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">lazy</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">bool</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">lazy</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">lazy</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="self">self</span>
}
@ -809,41 +809,41 @@
<span class="doccomment">/// If the `secure` field is set, a cookie will only be transmitted when the</span>
<span class="doccomment">/// connection is secure - i.e. `https`</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">secure</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">bool</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">secure</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">secure</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `http_only` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">http_only</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">bool</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">http_only</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">http_only</span> <span class="op">=</span> <span class="ident">value</span>;
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `same_site` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">same_site</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">SameSite</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">same_site</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">same_site</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `max-age` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">max_age</span>(<span class="self">self</span>, <span class="ident">seconds</span>: <span class="ident">i64</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="self">self</span>.<span class="ident">max_age_time</span>(<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="ident">seconds</span>))
<span class="self">self</span>.<span class="ident">max_age_time</span>(<span class="ident">Duration::seconds</span>(<span class="ident">seconds</span>))
}
<span class="doccomment">/// Sets the `max-age` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">max_age_time</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">time</span>::<span class="ident">Duration</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">max_age</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">max_age_time</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">time::Duration</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">max_age</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="self">self</span>
}
<span class="doccomment">/// Sets the `expires` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">expires_in</span>(<span class="self">self</span>, <span class="ident">seconds</span>: <span class="ident">i64</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="self">self</span>.<span class="ident">expires_in_time</span>(<span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="ident">seconds</span>))
<span class="self">self</span>.<span class="ident">expires_in_time</span>(<span class="ident">Duration::seconds</span>(<span class="ident">seconds</span>))
}
<span class="doccomment">/// Sets the `expires` field in the session cookie being built.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">expires_in_time</span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">value</span>: <span class="ident">Duration</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">CookieSession</span> {
<span class="ident">Rc</span>::<span class="ident">get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">expires_in</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="ident">Rc::get_mut</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">expires_in</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">value</span>);
<span class="self">self</span>
}
}
@ -851,16 +851,16 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span>: <span class="lifetime">&#39;static</span><span class="op">&gt;</span> <span class="ident">Transform</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">CookieSession</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Error</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Error</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S</span>::<span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S::Error</span>;
<span class="kw">type</span> <span class="ident">InitError</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Transform</span> <span class="op">=</span> <span class="ident">CookieSessionMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Transform</span>, <span class="self">Self</span>::<span class="ident">InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Transform</span>, <span class="self">Self</span><span class="ident">::InitError</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">new_transform</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">service</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ok</span>(<span class="ident">CookieSessionMiddleware</span> {
<span class="ident">service</span>,
<span class="ident">inner</span>: <span class="self">self</span>.<span class="number">0</span>.<span class="ident">clone</span>(),
@ -877,51 +877,51 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span>: <span class="lifetime">&#39;static</span><span class="op">&gt;</span> <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">CookieSessionMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">S</span>::<span class="ident">Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S</span>::<span class="ident">Error</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Future</span>: <span class="lifetime">&#39;static</span>,
<span class="ident">S::Error</span>: <span class="lifetime">&#39;static</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S</span>::<span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Response</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">S::Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Response</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="ident">actix_service</span>::<span class="macro">forward_ready</span><span class="macro">!</span>(<span class="ident">service</span>);
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
<span class="doccomment">/// On first request, a new session cookie is returned in response, regardless</span>
<span class="doccomment">/// of whether any session state is set. With subsequent requests, if the</span>
<span class="doccomment">/// session state changes, then set-cookie is returned in response. As</span>
<span class="doccomment">/// a user logs out, call session.purge() to set SessionStatus accordingly</span>
<span class="doccomment">/// and this will trigger removal of the session cookie in the response.</span>
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">call</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">req</span>: <span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">clone</span>();
<span class="kw">let</span> (<span class="ident">is_new</span>, <span class="ident">state</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">load</span>(<span class="kw-2">&amp;</span><span class="ident">req</span>);
<span class="kw">let</span> <span class="ident">prolong_expiration</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">expires_in</span>.<span class="ident">is_some</span>();
<span class="ident">Session</span>::<span class="ident">set_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>, <span class="ident">state</span>);
<span class="ident">Session::set_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>, <span class="ident">state</span>);
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">service</span>.<span class="ident">call</span>(<span class="ident">req</span>);
<span class="ident">Box</span>::<span class="ident">pin</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="ident">Box::pin</span>(<span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">fut</span>.<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">Session</span>::<span class="ident">get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>) {
(<span class="ident">SessionStatus</span>::<span class="ident">Changed</span>, <span class="ident">state</span>) <span class="op">|</span> (<span class="ident">SessionStatus</span>::<span class="ident">Renewed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">Session::get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>) {
(<span class="ident">SessionStatus::Changed</span>, <span class="ident">state</span>) <span class="op">|</span> (<span class="ident">SessionStatus::Renewed</span>, <span class="ident">state</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">res</span>.<span class="ident">checked_expr</span>(<span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="ident">inner</span>.<span class="ident">set_cookie</span>(<span class="ident">res</span>, <span class="ident">state</span>))
}
(<span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>, <span class="ident">state</span>) <span class="kw">if</span> <span class="ident">prolong_expiration</span> <span class="op">=</span><span class="op">&gt;</span> {
(<span class="ident">SessionStatus::Unchanged</span>, <span class="ident">state</span>) <span class="kw">if</span> <span class="ident">prolong_expiration</span> <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">res</span>.<span class="ident">checked_expr</span>(<span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="ident">inner</span>.<span class="ident">set_cookie</span>(<span class="ident">res</span>, <span class="ident">state</span>))
}
<span class="comment">// set a new session cookie upon first request (new client)</span>
(<span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
(<span class="ident">SessionStatus::Unchanged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">is_new</span> {
<span class="kw">let</span> <span class="ident">state</span>: <span class="ident">HashMap</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashMap</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="ident">state</span>: <span class="ident">HashMap</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashMap::new</span>();
<span class="ident">res</span>.<span class="ident">checked_expr</span>(<span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="ident">inner</span>.<span class="ident">set_cookie</span>(<span class="ident">res</span>, <span class="ident">state</span>.<span class="ident">into_iter</span>()))
} <span class="kw">else</span> {
<span class="ident">res</span>
}
}
(<span class="ident">SessionStatus</span>::<span class="ident">Purged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
(<span class="ident">SessionStatus::Purged</span>, <span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">inner</span>.<span class="ident">remove_cookie</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>);
<span class="ident">res</span>
}
@ -935,120 +935,120 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">web</span>::<span class="ident">Bytes</span>;
<span class="kw">use</span> <span class="ident">actix_web::web::Bytes</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">test</span>, <span class="ident">web</span>, <span class="ident">App</span>};
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">cookie_session</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;</span>
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">response</span>
<span class="macro">assert!</span>(<span class="ident">response</span>
.<span class="ident">response</span>()
.<span class="ident">cookies</span>()
.<span class="ident">any</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;actix-session&quot;</span>));
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">private_cookie</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">private</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession::private</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;</span>
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">response</span>
<span class="macro">assert!</span>(<span class="ident">response</span>
.<span class="ident">response</span>()
.<span class="ident">cookies</span>()
.<span class="ident">any</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;actix-session&quot;</span>));
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">lazy_cookie</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>).<span class="ident">lazy</span>(<span class="bool-val">true</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/count&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>).<span class="ident">lazy</span>(<span class="bool-val">true</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/count&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;counting&quot;</span>
}))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">_ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="string">&quot;test&quot;</span> })),
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">_ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="string">&quot;test&quot;</span> })),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">response</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">count</span>() <span class="op">=</span><span class="op">=</span> <span class="number">0</span>);
<span class="macro">assert!</span>(<span class="ident">response</span>.<span class="ident">response</span>().<span class="ident">cookies</span>().<span class="ident">count</span>() <span class="op">=</span><span class="op">=</span> <span class="number">0</span>);
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/count&quot;</span>).<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::with_uri</span>(<span class="string">&quot;/count&quot;</span>).<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">response</span>
<span class="macro">assert!</span>(<span class="ident">response</span>
.<span class="ident">response</span>()
.<span class="ident">cookies</span>()
.<span class="ident">any</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;actix-session&quot;</span>));
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">cookie_session_extractor</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;</span>
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">response</span>
<span class="macro">assert!</span>(<span class="ident">response</span>
.<span class="ident">response</span>()
.<span class="ident">cookies</span>()
.<span class="ident">any</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;actix-session&quot;</span>));
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">basics</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(
<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>])
.<span class="ident">path</span>(<span class="string">&quot;/test/&quot;</span>)
.<span class="ident">name</span>(<span class="string">&quot;actix-test&quot;</span>)
.<span class="ident">domain</span>(<span class="string">&quot;localhost&quot;</span>)
.<span class="ident">http_only</span>(<span class="bool-val">true</span>)
.<span class="ident">same_site</span>(<span class="ident">SameSite</span>::<span class="ident">Lax</span>)
.<span class="ident">same_site</span>(<span class="ident">SameSite::Lax</span>)
.<span class="ident">max_age</span>(<span class="number">100</span>),
)
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;</span>
}))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/test/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/test/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">val</span>: <span class="ident">usize</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">get</span>(<span class="string">&quot;counter&quot;</span>).<span class="ident">unwrap</span>().<span class="ident">unwrap</span>();
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;counter: {}&quot;</span>, <span class="ident">val</span>)
<span class="macro">format!</span>(<span class="string">&quot;counter: {}&quot;</span>, <span class="ident">val</span>)
})),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">cookie</span> <span class="op">=</span> <span class="ident">response</span>
.<span class="ident">response</span>()
@ -1056,32 +1056,32 @@
.<span class="ident">find</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">name</span>() <span class="op">=</span><span class="op">=</span> <span class="string">&quot;actix-test&quot;</span>)
.<span class="ident">unwrap</span>()
.<span class="ident">clone</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cookie</span>.<span class="ident">path</span>().<span class="ident">unwrap</span>(), <span class="string">&quot;/test/&quot;</span>);
<span class="macro">assert_eq!</span>(<span class="ident">cookie</span>.<span class="ident">path</span>().<span class="ident">unwrap</span>(), <span class="string">&quot;/test/&quot;</span>);
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/test/&quot;</span>)
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::with_uri</span>(<span class="string">&quot;/test/&quot;</span>)
.<span class="ident">cookie</span>(<span class="ident">cookie</span>)
.<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">read_response</span>(<span class="kw-2">&amp;</span><span class="ident">app</span>, <span class="ident">request</span>).<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">body</span>, <span class="ident">Bytes</span>::<span class="ident">from_static</span>(<span class="string">b&quot;counter: 100&quot;</span>));
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">test::read_response</span>(<span class="kw-2">&amp;</span><span class="ident">app</span>, <span class="ident">request</span>).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">body</span>, <span class="ident">Bytes::from_static</span>(<span class="string">b&quot;counter: 100&quot;</span>));
}
<span class="attribute">#[<span class="ident">actix_rt</span>::<span class="ident">test</span>]</span>
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">prolong_expiration</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
<span class="ident">App</span>::<span class="ident">new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession</span>::<span class="ident">signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>).<span class="ident">expires_in</span>(<span class="number">60</span>))
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test::init_service</span>(
<span class="ident">App::new</span>()
.<span class="ident">wrap</span>(<span class="ident">CookieSession::signed</span>(<span class="kw-2">&amp;</span>[<span class="number">0</span>; <span class="number">32</span>]).<span class="ident">secure</span>(<span class="bool-val">false</span>).<span class="ident">expires_in</span>(<span class="number">60</span>))
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">&quot;/&quot;</span>).<span class="ident">to</span>(<span class="op">|</span><span class="ident">ses</span>: <span class="ident">Session</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">ses</span>.<span class="ident">insert</span>(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;</span>
}))
.<span class="ident">service</span>(
<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">&quot;/test/&quot;</span>)
<span class="ident">web::resource</span>(<span class="string">&quot;/test/&quot;</span>)
.<span class="ident">to</span>(<span class="op">|</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="string">&quot;no-changes-in-session&quot;</span> }),
),
)
.<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::get</span>().<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">expires_1</span> <span class="op">=</span> <span class="ident">response</span>
.<span class="ident">response</span>()
@ -1091,9 +1091,9 @@
.<span class="ident">expires</span>()
.<span class="ident">expect</span>(<span class="string">&quot;Expiration is set&quot;</span>);
<span class="ident">actix_rt</span>::<span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">std</span>::<span class="ident">time</span>::<span class="ident">Duration</span>::<span class="ident">from_secs</span>(<span class="number">1</span>)).<span class="kw">await</span>;
<span class="ident">actix_rt::time::sleep</span>(<span class="ident">std::time::Duration::from_secs</span>(<span class="number">1</span>)).<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">&quot;/test/&quot;</span>).<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">request</span> <span class="op">=</span> <span class="ident">test::TestRequest::with_uri</span>(<span class="string">&quot;/test/&quot;</span>).<span class="ident">to_request</span>();
<span class="kw">let</span> <span class="ident">response</span> <span class="op">=</span> <span class="ident">app</span>.<span class="ident">call</span>(<span class="ident">request</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">expires_2</span> <span class="op">=</span> <span class="ident">response</span>
.<span class="ident">response</span>()
@ -1103,7 +1103,7 @@
.<span class="ident">expires</span>()
.<span class="ident">expect</span>(<span class="string">&quot;Expiration is set&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">expires_2</span> <span class="op">-</span> <span class="ident">expires_1</span> <span class="op">&gt;</span><span class="op">=</span> <span class="ident">Duration</span>::<span class="ident">seconds</span>(<span class="number">1</span>));
<span class="macro">assert!</span>(<span class="ident">expires_2</span> <span class="op">-</span> <span class="ident">expires_1</span> <span class="op">&gt;</span><span class="op">=</span> <span class="ident">Duration::seconds</span>(<span class="number">1</span>));
}
}
</pre></div>

View File

@ -459,22 +459,22 @@
<span class="kw">use</span> <span class="ident">std</span>::{
<span class="ident">cell</span>::{<span class="ident">Ref</span>, <span class="ident">RefCell</span>},
<span class="ident">collections</span>::<span class="ident">HashMap</span>,
<span class="ident">collections::HashMap</span>,
<span class="ident">mem</span>,
<span class="ident">rc</span>::<span class="ident">Rc</span>,
<span class="ident">rc::Rc</span>,
};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev</span>::{<span class="ident">Extensions</span>, <span class="ident">Payload</span>, <span class="ident">RequestHead</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
<span class="ident">Error</span>, <span class="ident">FromRequest</span>, <span class="ident">HttpMessage</span>, <span class="ident">HttpRequest</span>,
};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ok</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">de</span>::<span class="ident">DeserializeOwned</span>, <span class="ident">Serialize</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ok</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">de::DeserializeOwned</span>, <span class="ident">Serialize</span>};
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;cookie-session&quot;</span>)]</span>
<span class="kw">mod</span> <span class="ident">cookie</span>;
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">&quot;cookie-session&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">cookie</span>::<span class="ident">CookieSession</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::cookie::CookieSession</span>;
<span class="doccomment">/// The high-level interface you use to modify session data.</span>
<span class="doccomment">///</span>
@ -506,19 +506,19 @@
<span class="kw">impl</span> <span class="ident">UserSession</span> <span class="kw">for</span> <span class="ident">HttpRequest</span> {
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Session</span> {
<span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
<span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
}
}
<span class="kw">impl</span> <span class="ident">UserSession</span> <span class="kw">for</span> <span class="ident">ServiceRequest</span> {
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Session</span> {
<span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
<span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
}
}
<span class="kw">impl</span> <span class="ident">UserSession</span> <span class="kw">for</span> <span class="ident">RequestHead</span> {
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Session</span> {
<span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
<span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
}
}
@ -549,7 +549,7 @@
<span class="kw">impl</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">SessionStatus</span> {
<span class="kw">fn</span> <span class="ident">default</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="ident">SessionStatus</span> {
<span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>
<span class="ident">SessionStatus::Unchanged</span>
}
}
@ -563,7 +563,7 @@
<span class="doccomment">/// Get a `value` from the session.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">get</span><span class="op">&lt;</span><span class="ident">T</span>: <span class="ident">DeserializeOwned</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">key</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>, <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">s</span>) <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">state</span>.<span class="ident">get</span>(<span class="ident">key</span>) {
<span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>(<span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="ident">s</span>)<span class="question-mark">?</span>))
<span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>(<span class="ident">serde_json::from_str</span>(<span class="ident">s</span>)<span class="question-mark">?</span>))
} <span class="kw">else</span> {
<span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>)
}
@ -573,7 +573,7 @@
<span class="doccomment">///</span>
<span class="doccomment">/// Note that values are JSON encoded.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">entries</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Ref</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span>, <span class="ident">HashMap</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span> {
<span class="ident">Ref</span>::<span class="ident">map</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>(), <span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="kw-2">&amp;</span><span class="ident">inner</span>.<span class="ident">state</span>)
<span class="ident">Ref::map</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>(), <span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="kw-2">&amp;</span><span class="ident">inner</span>.<span class="ident">state</span>)
}
<span class="doccomment">/// Inserts a key-value pair into the session.</span>
@ -587,9 +587,9 @@
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">Error</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Changed</span>;
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="ident">value</span>)<span class="question-mark">?</span>;
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="ident">value</span>)<span class="question-mark">?</span>;
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">insert</span>(<span class="ident">key</span>.<span class="ident">into</span>(), <span class="ident">val</span>);
}
@ -602,8 +602,8 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">remove</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">key</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Changed</span>;
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
<span class="kw">return</span> <span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">remove</span>(<span class="ident">key</span>);
}
@ -619,13 +619,13 @@
<span class="ident">key</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">String</span><span class="op">&gt;</span><span class="op">&gt;</span> {
<span class="self">self</span>.<span class="ident">remove</span>(<span class="ident">key</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">val_str</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">serde_json</span>::<span class="ident">from_str</span>(<span class="kw-2">&amp;</span><span class="ident">val_str</span>) {
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">val_str</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">serde_json::from_str</span>(<span class="kw-2">&amp;</span><span class="ident">val_str</span>) {
<span class="prelude-val">Ok</span>(<span class="ident">val</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Ok</span>(<span class="ident">val</span>),
<span class="prelude-val">Err</span>(<span class="ident">_err</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="ident">log</span>::<span class="macro">debug</span><span class="macro">!</span>(
<span class="macro">log::debug!</span>(
<span class="string">&quot;removed value (key: {}) could not be deserialized as {}&quot;</span>,
<span class="ident">key</span>,
<span class="ident">std</span>::<span class="ident">any</span>::<span class="ident">type_name</span>::<span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>()
<span class="ident">std::any::type_name</span>::<span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>()
);
<span class="prelude-val">Err</span>(<span class="ident">val_str</span>)
}
@ -636,8 +636,8 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">clear</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Changed</span>;
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">clear</span>()
}
}
@ -645,7 +645,7 @@
<span class="doccomment">/// Removes session both client and server side.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">purge</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Purged</span>;
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Purged</span>;
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">clear</span>();
}
@ -653,8 +653,8 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">renew</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus</span>::<span class="ident">Renewed</span>;
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Renewed</span>;
}
}
@ -678,7 +678,7 @@
<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">ServiceRequest</span>,
<span class="ident">data</span>: <span class="kw">impl</span> <span class="ident">IntoIterator</span><span class="op">&lt;</span><span class="ident">Item</span> <span class="op">=</span> (<span class="ident">String</span>, <span class="ident">String</span>)<span class="op">&gt;</span>,
) {
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">extend</span>(<span class="ident">data</span>);
}
@ -692,18 +692,18 @@
.<span class="ident">extensions</span>()
.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">RefCell</span><span class="op">&lt;</span><span class="ident">SessionInner</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>()
{
<span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">mem</span>::<span class="ident">take</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">s_impl</span>.<span class="ident">borrow_mut</span>().<span class="ident">state</span>);
<span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">mem::take</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">s_impl</span>.<span class="ident">borrow_mut</span>().<span class="ident">state</span>);
(<span class="ident">s_impl</span>.<span class="ident">borrow</span>().<span class="ident">status</span>.<span class="ident">clone</span>(), <span class="ident">state</span>.<span class="ident">into_iter</span>())
} <span class="kw">else</span> {
(<span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>, <span class="ident">HashMap</span>::<span class="ident">new</span>().<span class="ident">into_iter</span>())
(<span class="ident">SessionStatus::Unchanged</span>, <span class="ident">HashMap::new</span>().<span class="ident">into_iter</span>())
}
}
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="ident">extensions</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Extensions</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">Session</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">s_impl</span>) <span class="op">=</span> <span class="ident">extensions</span>.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">RefCell</span><span class="op">&lt;</span><span class="ident">SessionInner</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span>() {
<span class="kw">return</span> <span class="ident">Session</span>(<span class="ident">Rc</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</span><span class="ident">s_impl</span>));
<span class="kw">return</span> <span class="ident">Session</span>(<span class="ident">Rc::clone</span>(<span class="kw-2">&amp;</span><span class="ident">s_impl</span>));
}
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">RefCell</span>::<span class="ident">new</span>(<span class="ident">SessionInner</span>::<span class="ident">default</span>()));
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::new</span>(<span class="ident">RefCell::new</span>(<span class="ident">SessionInner::default</span>()));
<span class="ident">extensions</span>.<span class="ident">insert</span>(<span class="ident">inner</span>.<span class="ident">clone</span>());
<span class="ident">Session</span>(<span class="ident">inner</span>)
}
@ -735,8 +735,8 @@
<span class="kw">type</span> <span class="ident">Config</span> <span class="op">=</span> ();
<span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="ident">ok</span>(<span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>()))
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>, <span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ok</span>(<span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>()))
}
}
@ -748,74 +748,74 @@
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">session</span>() {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="ident">Session</span>::<span class="ident">set_session</span>(
<span class="ident">Session::set_session</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>,
<span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="string">&quot;value&quot;</span>).<span class="ident">unwrap</span>())],
<span class="macro">vec!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json::to_string</span>(<span class="string">&quot;value&quot;</span>).<span class="ident">unwrap</span>())],
);
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>(<span class="string">&quot;key&quot;</span>).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="string">&quot;value&quot;</span>.<span class="ident">to_string</span>()));
<span class="macro">assert_eq!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="string">&quot;value&quot;</span>.<span class="ident">to_string</span>()));
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;key2&quot;</span>, <span class="string">&quot;value2&quot;</span>).<span class="ident">unwrap</span>();
<span class="ident">session</span>.<span class="ident">remove</span>(<span class="string">&quot;key&quot;</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">into_response</span>(<span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>().<span class="ident">finish</span>());
<span class="kw">let</span> (<span class="ident">_status</span>, <span class="ident">state</span>) <span class="op">=</span> <span class="ident">Session</span>::<span class="ident">get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">into_response</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">finish</span>());
<span class="kw">let</span> (<span class="ident">_status</span>, <span class="ident">state</span>) <span class="op">=</span> <span class="ident">Session::get_changes</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">res</span>);
<span class="kw">let</span> <span class="ident">changes</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">state</span>.<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">changes</span>, [(<span class="string">&quot;key2&quot;</span>.<span class="ident">to_string</span>(), <span class="string">&quot;\&quot;value2\&quot;&quot;</span>.<span class="ident">to_string</span>())]);
<span class="macro">assert_eq!</span>(<span class="ident">changes</span>, [(<span class="string">&quot;key2&quot;</span>.<span class="ident">to_string</span>(), <span class="string">&quot;\&quot;value2\&quot;&quot;</span>.<span class="ident">to_string</span>())]);
}
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">get_session</span>() {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="ident">Session</span>::<span class="ident">set_session</span>(
<span class="ident">Session::set_session</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>,
<span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="bool-val">true</span>).<span class="ident">unwrap</span>())],
<span class="macro">vec!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="bool-val">true</span>).<span class="ident">unwrap</span>())],
);
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">get_session</span>();
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>(<span class="string">&quot;key&quot;</span>).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="bool-val">true</span>));
<span class="macro">assert_eq!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="bool-val">true</span>));
}
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">get_session_from_request_head</span>() {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="ident">Session</span>::<span class="ident">set_session</span>(
<span class="ident">Session::set_session</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">req</span>,
<span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json</span>::<span class="ident">to_string</span>(<span class="kw-2">&amp;</span><span class="number">10</span>).<span class="ident">unwrap</span>())],
<span class="macro">vec!</span>[(<span class="string">&quot;key&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">serde_json::to_string</span>(<span class="kw-2">&amp;</span><span class="number">10</span>).<span class="ident">unwrap</span>())],
);
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">head_mut</span>().<span class="ident">get_session</span>();
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">session</span>.<span class="ident">get</span>::<span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>(<span class="string">&quot;key&quot;</span>).<span class="ident">unwrap</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="number">10</span>));
<span class="macro">assert_eq!</span>(<span class="ident">res</span>, <span class="prelude-val">Some</span>(<span class="number">10</span>));
}
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">purge_session</span>() {
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>);
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="macro">assert_eq!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus::Unchanged</span>);
<span class="ident">session</span>.<span class="ident">purge</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus</span>::<span class="ident">Purged</span>);
<span class="macro">assert_eq!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus::Purged</span>);
}
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">renew_session</span>() {
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>::<span class="ident">get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus</span>::<span class="ident">Unchanged</span>);
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test::TestRequest::default</span>().<span class="ident">to_srv_request</span>();
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session::get_session</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
<span class="macro">assert_eq!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus::Unchanged</span>);
<span class="ident">session</span>.<span class="ident">renew</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus</span>::<span class="ident">Renewed</span>);
<span class="macro">assert_eq!</span>(<span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">status</span>, <span class="ident">SessionStatus::Renewed</span>);
}
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">session_entries</span>() {
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>(<span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">RefCell</span>::<span class="ident">new</span>(<span class="ident">SessionInner</span>::<span class="ident">default</span>())));
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session</span>(<span class="ident">Rc::new</span>(<span class="ident">RefCell::new</span>(<span class="ident">SessionInner::default</span>())));
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;test_str&quot;</span>, <span class="string">&quot;val&quot;</span>).<span class="ident">unwrap</span>();
<span class="ident">session</span>.<span class="ident">insert</span>(<span class="string">&quot;test_num&quot;</span>, <span class="number">1</span>).<span class="ident">unwrap</span>();

View File

@ -156,18 +156,18 @@
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Extractor for the &quot;Basic&quot; HTTP Authentication Scheme</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Cow</span>;
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>::<span class="ident">Header</span>;
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header::Header</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">config</span>::<span class="ident">AuthExtractorConfig</span>;
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">errors</span>::<span class="ident">AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">AuthExtractor</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">authorization</span>::{<span class="ident">Authorization</span>, <span class="ident">Basic</span>};
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">basic</span>::<span class="ident">Basic</span> <span class="kw">as</span> <span class="ident">Challenge</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::config::AuthExtractorConfig</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::errors::AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::AuthExtractor</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::authorization</span>::{<span class="ident">Authorization</span>, <span class="ident">Basic</span>};
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::basic::Basic</span> <span class="kw">as</span> <span class="ident">Challenge</span>;
<span class="doccomment">/// [`BasicAuth`] extractor configuration,</span>
<span class="doccomment">/// used for [`WWW-Authenticate`] header later.</span>
@ -201,13 +201,13 @@
<span class="kw">impl</span> <span class="ident">AuthExtractorConfig</span> <span class="kw">for</span> <span class="ident">Config</span> {
<span class="kw">type</span> <span class="ident">Inner</span> <span class="op">=</span> <span class="ident">Challenge</span>;
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Inner</span> {
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Inner</span> {
<span class="self">self</span>.<span class="number">0</span>
}
}
<span class="comment">// Needs `fn main` to display complete example.</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">needless_doctest_main</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::needless_doctest_main</span>)]</span>
<span class="doccomment">/// Extractor for HTTP Basic auth.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
@ -260,26 +260,26 @@
}
<span class="kw">impl</span> <span class="ident">FromRequest</span> <span class="kw">for</span> <span class="ident">BasicAuth</span> {
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Config</span> <span class="op">=</span> <span class="ident">Config</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Challenge</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_request</span>(
<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>,
<span class="kw">_</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="op">&lt;</span><span class="self">Self</span> <span class="kw">as</span> <span class="ident">FromRequest</span><span class="op">&gt;</span>::<span class="ident">Future</span> {
) <span class="op">-</span><span class="op">&gt;</span> <span class="op">&lt;</span><span class="self">Self</span> <span class="kw">as</span> <span class="ident">FromRequest</span><span class="op">&gt;</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span>::<span class="ident">parse</span>(<span class="ident">req</span>)
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BasicAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="comment">// TODO: debug! the original error</span>
<span class="kw">let</span> <span class="ident">challenge</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
<span class="comment">// TODO: Add trace! about `Default::default` call</span>
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default</span>::<span class="ident">default</span>);
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">challenge</span>)
<span class="ident">AuthenticationError::new</span>(<span class="ident">challenge</span>)
}),
)
}
@ -287,11 +287,11 @@
<span class="kw">impl</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="ident">BasicAuth</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Challenge</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span>::<span class="ident">parse</span>(<span class="ident">req</span>)
<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BasicAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="comment">// TODO: debug! the original error</span>
@ -299,9 +299,9 @@
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
<span class="comment">// TODO: Add trace! about `Default::default` call</span>
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default</span>::<span class="ident">default</span>);
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">challenge</span>)
<span class="ident">AuthenticationError::new</span>(<span class="ident">challenge</span>)
}),
)
}

View File

@ -184,24 +184,24 @@
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Extractor for the &quot;Bearer&quot; HTTP Authentication Scheme</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Cow</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">default</span>::<span class="ident">Default</span>;
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">std::default::Default</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>::<span class="ident">Header</span>;
<span class="kw">use</span> <span class="ident">actix_web::dev</span>::{<span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>};
<span class="kw">use</span> <span class="ident">actix_web::http::header::Header</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">FromRequest</span>, <span class="ident">HttpRequest</span>};
<span class="kw">use</span> <span class="ident">futures_util</span>::<span class="ident">future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">config</span>::<span class="ident">AuthExtractorConfig</span>;
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">errors</span>::<span class="ident">AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">AuthExtractor</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">authorization</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">bearer</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">bearer</span>::<span class="ident">Error</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::config::AuthExtractorConfig</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::errors::AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::AuthExtractor</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::authorization</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::bearer</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::bearer::Error</span>;
<span class="doccomment">/// [BearerAuth](./struct/BearerAuth.html) extractor configuration.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>, <span class="ident">Default</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Config</span>(<span class="ident">bearer</span>::<span class="ident">Bearer</span>);
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Config</span>(<span class="ident">bearer::Bearer</span>);
<span class="kw">impl</span> <span class="ident">Config</span> {
<span class="doccomment">/// Set challenge `scope` attribute.</span>
@ -224,22 +224,22 @@
}
}
<span class="kw">impl</span> <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">bearer</span>::<span class="ident">Bearer</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Config</span> {
<span class="kw">fn</span> <span class="ident">as_ref</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw-2">&amp;</span><span class="ident">bearer</span>::<span class="ident">Bearer</span> {
<span class="kw">impl</span> <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">Config</span> {
<span class="kw">fn</span> <span class="ident">as_ref</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="kw-2">&amp;</span><span class="ident">bearer::Bearer</span> {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>
}
}
<span class="kw">impl</span> <span class="ident">AuthExtractorConfig</span> <span class="kw">for</span> <span class="ident">Config</span> {
<span class="kw">type</span> <span class="ident">Inner</span> <span class="op">=</span> <span class="ident">bearer</span>::<span class="ident">Bearer</span>;
<span class="kw">type</span> <span class="ident">Inner</span> <span class="op">=</span> <span class="ident">bearer::Bearer</span>;
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Inner</span> {
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Inner</span> {
<span class="self">self</span>.<span class="number">0</span>
}
}
<span class="comment">// Needs `fn main` to display complete example.</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy</span>::<span class="ident">needless_doctest_main</span>)]</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">clippy::needless_doctest_main</span>)]</span>
<span class="doccomment">/// Extractor for HTTP Bearer auth</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Example</span>
@ -277,7 +277,7 @@
<span class="doccomment">/// }</span>
<span class="doccomment">/// ```</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BearerAuth</span>(<span class="ident">authorization</span>::<span class="ident">Bearer</span>);
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BearerAuth</span>(<span class="ident">authorization::Bearer</span>);
<span class="kw">impl</span> <span class="ident">BearerAuth</span> {
<span class="doccomment">/// Returns bearer token provided by client.</span>
@ -288,50 +288,50 @@
<span class="kw">impl</span> <span class="ident">FromRequest</span> <span class="kw">for</span> <span class="ident">BearerAuth</span> {
<span class="kw">type</span> <span class="ident">Config</span> <span class="op">=</span> <span class="ident">Config</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer</span>::<span class="ident">Bearer</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_request</span>(
<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">HttpRequest</span>,
<span class="ident">_payload</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">Payload</span>,
) <span class="op">-</span><span class="op">&gt;</span> <span class="op">&lt;</span><span class="self">Self</span> <span class="kw">as</span> <span class="ident">FromRequest</span><span class="op">&gt;</span>::<span class="ident">Future</span> {
) <span class="op">-</span><span class="op">&gt;</span> <span class="op">&lt;</span><span class="self">Self</span> <span class="kw">as</span> <span class="ident">FromRequest</span><span class="op">&gt;</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(
<span class="ident">authorization</span>::<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">authorization</span>::<span class="ident">Bearer</span><span class="op">&gt;</span>::<span class="ident">parse</span>(<span class="ident">req</span>)
<span class="ident">authorization::Authorization</span>::<span class="op">&lt;</span><span class="ident">authorization::Bearer</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BearerAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">bearer</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="self">Self</span><span class="ident">::Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default</span>::<span class="ident">default</span>);
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">bearer</span>)
<span class="ident">AuthenticationError::new</span>(<span class="ident">bearer</span>)
}),
)
}
}
<span class="kw">impl</span> <span class="ident">AuthExtractor</span> <span class="kw">for</span> <span class="ident">BearerAuth</span> {
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer</span>::<span class="ident">Bearer</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span> {
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span> {
<span class="ident">ready</span>(
<span class="ident">authorization</span>::<span class="ident">Authorization</span>::<span class="op">&lt;</span><span class="ident">authorization</span>::<span class="ident">Bearer</span><span class="op">&gt;</span>::<span class="ident">parse</span>(<span class="ident">req</span>)
<span class="ident">authorization::Authorization</span>::<span class="op">&lt;</span><span class="ident">authorization::Bearer</span><span class="op">&gt;</span><span class="ident">::parse</span>(<span class="ident">req</span>)
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">auth</span><span class="op">|</span> <span class="ident">BearerAuth</span>(<span class="ident">auth</span>.<span class="ident">into_scheme</span>()))
.<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> {
<span class="kw">let</span> <span class="ident">bearer</span> <span class="op">=</span> <span class="ident">req</span>
.<span class="ident">app_data</span>::<span class="op">&lt;</span><span class="ident">Config</span><span class="op">&gt;</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">config</span><span class="op">|</span> <span class="ident">config</span>.<span class="number">0</span>.<span class="ident">clone</span>())
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default</span>::<span class="ident">default</span>);
.<span class="ident">unwrap_or_else</span>(<span class="ident">Default::default</span>);
<span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">bearer</span>)
<span class="ident">AuthenticationError::new</span>(<span class="ident">bearer</span>)
}),
)
}
}
<span class="doccomment">/// Extended error customization for HTTP `Bearer` auth.</span>
<span class="kw">impl</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer</span>::<span class="ident">Bearer</span><span class="op">&gt;</span> {
<span class="kw">impl</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">bearer::Bearer</span><span class="op">&gt;</span> {
<span class="doccomment">/// Attach `Error` to the current Authentication error.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Error status code will be changed to the one provided by the `kind`</span>

View File

@ -25,8 +25,8 @@
<span id="22">22</span>
<span id="23">23</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="kw">super</span>::<span class="ident">AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">Challenge</span>;
<span class="kw">use</span> <span class="kw">super</span><span class="ident">::AuthenticationError</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::Challenge</span>;
<span class="doccomment">/// Trait implemented for types that provides configuration</span>
<span class="doccomment">/// for the authentication [extractors].</span>
@ -37,15 +37,15 @@
<span class="kw">type</span> <span class="ident">Inner</span>: <span class="ident">Challenge</span>;
<span class="doccomment">/// Convert the config instance into a HTTP challenge.</span>
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Inner</span>;
<span class="kw">fn</span> <span class="ident">into_inner</span>(<span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Inner</span>;
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="op">&lt;</span><span class="ident">T</span> <span class="kw">as</span> <span class="ident">AuthExtractorConfig</span><span class="op">&gt;</span>::<span class="ident">Inner</span><span class="op">&gt;</span>
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="op">&lt;</span><span class="ident">T</span> <span class="kw">as</span> <span class="ident">AuthExtractorConfig</span><span class="op">&gt;</span><span class="ident">::Inner</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">AuthExtractorConfig</span>,
{
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">config</span>: <span class="ident">T</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">config</span>.<span class="ident">into_inner</span>())
<span class="ident">AuthenticationError::new</span>(<span class="ident">config</span>.<span class="ident">into_inner</span>())
}
}
</pre></div>

View File

@ -84,14 +84,14 @@
<span id="81">81</span>
<span id="82">82</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</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::error::Error</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">StatusCode</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::StatusCode</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">HttpResponse</span>, <span class="ident">ResponseError</span>};
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">Challenge</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">WwwAuthenticate</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::Challenge</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::WwwAuthenticate</span>;
<span class="doccomment">/// Authentication error returned by authentication extractors.</span>
<span class="doccomment">///</span>
@ -110,7 +110,7 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">challenge</span>: <span class="ident">C</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="ident">AuthenticationError</span> {
<span class="ident">challenge</span>,
<span class="ident">status_code</span>: <span class="ident">StatusCode</span>::<span class="ident">UNAUTHORIZED</span>,
<span class="ident">status_code</span>: <span class="ident">StatusCode::UNAUTHORIZED</span>,
}
}
@ -128,9 +128,9 @@
}
}
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="ident">Display</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
<span class="ident">fmt</span>::<span class="ident">Display</span>::<span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">status_code</span>, <span class="ident">f</span>)
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt::Result</span> {
<span class="ident">fmt::Display::fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">status_code</span>, <span class="ident">f</span>)
}
}
@ -138,7 +138,7 @@
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">C</span>: <span class="lifetime">&#39;static</span> <span class="op">+</span> <span class="ident">Challenge</span><span class="op">&gt;</span> <span class="ident">ResponseError</span> <span class="kw">for</span> <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">C</span><span class="op">&gt;</span> {
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="ident">HttpResponse</span>::<span class="ident">build</span>(<span class="self">self</span>.<span class="ident">status_code</span>)
<span class="ident">HttpResponse::build</span>(<span class="self">self</span>.<span class="ident">status_code</span>)
<span class="comment">// TODO: Get rid of the `.clone()`</span>
.<span class="ident">insert_header</span>(<span class="ident">WwwAuthenticate</span>(<span class="self">self</span>.<span class="ident">challenge</span>.<span class="ident">clone</span>()))
.<span class="ident">finish</span>()
@ -152,18 +152,18 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="ident">headers</span>::<span class="ident">www_authenticate</span>::<span class="ident">basic</span>::<span class="ident">Basic</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">Error</span>;
<span class="kw">use</span> <span class="kw">crate</span><span class="ident">::headers::www_authenticate::basic::Basic</span>;
<span class="kw">use</span> <span class="ident">actix_web::Error</span>;
<span class="attribute">#[<span class="ident">test</span>]</span>
<span class="kw">fn</span> <span class="ident">test_status_code_is_preserved_across_error_conversions</span>() {
<span class="kw">let</span> <span class="ident">ae</span>: <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">AuthenticationError</span>::<span class="ident">new</span>(<span class="ident">Basic</span>::<span class="ident">default</span>());
<span class="kw">let</span> <span class="ident">ae</span>: <span class="ident">AuthenticationError</span><span class="op">&lt;</span><span class="ident">Basic</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">AuthenticationError::new</span>(<span class="ident">Basic::default</span>());
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> <span class="ident">ae</span>.<span class="ident">status_code</span>;
<span class="comment">// Converting the AuthenticationError into a ResponseError should preserve the status code.</span>
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">Error</span>::<span class="ident">from</span>(<span class="ident">ae</span>);
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="ident">Error::from</span>(<span class="ident">ae</span>);
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">e</span>.<span class="ident">as_response_error</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">expected</span>, <span class="ident">re</span>.<span class="ident">status_code</span>());
<span class="macro">assert_eq!</span>(<span class="ident">expected</span>, <span class="ident">re</span>.<span class="ident">status_code</span>());
}
}
</pre></div>

View File

@ -37,17 +37,17 @@
</pre><div class="example-wrap"><pre class="rust ">
<span class="doccomment">//! Type-safe authentication information extractors</span>
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">dev</span>::<span class="ident">ServiceRequest</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">Error</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">actix_web::dev::ServiceRequest</span>;
<span class="kw">use</span> <span class="ident">actix_web::Error</span>;
<span class="kw">use</span> <span class="ident">std::future::Future</span>;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">basic</span>;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">bearer</span>;
<span class="kw">mod</span> <span class="ident">config</span>;
<span class="kw">mod</span> <span class="ident">errors</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">config</span>::<span class="ident">AuthExtractorConfig</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span>::<span class="ident">errors</span>::<span class="ident">AuthenticationError</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::config::AuthExtractorConfig</span>;
<span class="kw">pub</span> <span class="kw">use</span> <span class="self">self</span><span class="ident">::errors::AuthenticationError</span>;
<span class="doccomment">/// Trait implemented by types that can extract</span>
<span class="doccomment">/// HTTP authentication scheme credentials from the request.</span>
@ -63,10 +63,10 @@
<span class="kw">type</span> <span class="ident">Error</span>: <span class="ident">Into</span><span class="op">&lt;</span><span class="ident">Error</span><span class="op">&gt;</span>;
<span class="doccomment">/// Future that resolves into extracted credentials type.</span>
<span class="kw">type</span> <span class="ident">Future</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span>::<span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Future</span>: <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="self">Self</span><span class="ident">::Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="doccomment">/// Parse the authentication credentials from the actix&#39; `ServiceRequest`.</span>
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span>::<span class="ident">Future</span>;
<span class="kw">fn</span> <span class="ident">from_service_request</span>(<span class="ident">req</span>: <span class="kw-2">&amp;</span><span class="ident">ServiceRequest</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span><span class="ident">::Future</span>;
}
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-search-js="../../../search-index.js"></div>

Some files were not shown because too many files have changed in this diff Show More