1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-09-02 04:56:38 +02:00

Deploying to gh-pages from @ actix/actix-extras@2f30fd71a9 🚀

This commit is contained in:
github-merge-queue[bot]
2023-12-06 14:01:24 +00:00
parent 0b3131af9b
commit 258efbfa75
222 changed files with 1494 additions and 1494 deletions

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/all_or_some.rs`."><title>all_or_some.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/all_or_some.rs`."><title>all_or_some.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -699,10 +699,10 @@
<span class="doccomment">/// Convenience for getting mut refs to inner. Cleaner than `Rc::get_mut`.
/// Additionally, always causes first error (if any) to be reported during initialization.
</span><span class="kw">fn </span>cors&lt;<span class="lifetime">&#39;a</span>&gt;(
inner: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span><span class="kw-2">mut </span>Rc&lt;Inner&gt;,
</span><span class="kw">fn </span>cors&lt;<span class="lifetime">'a</span>&gt;(
inner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span><span class="kw-2">mut </span>Rc&lt;Inner&gt;,
err: <span class="kw-2">&amp;</span><span class="prelude-ty">Option</span>&lt;Either&lt;HttpError, CorsError&gt;&gt;,
) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span><span class="kw-2">mut </span>Inner&gt; {
) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">'a </span><span class="kw-2">mut </span>Inner&gt; {
<span class="kw">if </span>err.is_some() {
<span class="kw">return </span><span class="prelude-val">None</span>;
}
@@ -751,8 +751,8 @@
/// use actix_web::http::header;
///
/// let cors = Cors::default()
/// .allowed_origin(&quot;https://www.rust-lang.org&quot;)
/// .allowed_methods(vec![&quot;GET&quot;, &quot;POST&quot;])
/// .allowed_origin("https://www.rust-lang.org")
/// .allowed_methods(vec!["GET", "POST"])
/// .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
/// .allowed_header(header::CONTENT_TYPE)
/// .max_age(3600);
@@ -791,7 +791,7 @@
preflight: <span class="bool-val">true</span>,
send_wildcard: <span class="bool-val">false</span>,
supports_credentials: <span class="bool-val">true</span>,
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span>allow_private_network_access: <span class="bool-val">false</span>,
vary_header: <span class="bool-val">true</span>,
block_on_origin_mismatch: <span class="bool-val">true</span>,
@@ -821,15 +821,15 @@
///
/// By default, no origins are accepted.
///
/// When this list is set, the client&#39;s `Origin` request header will be checked in a
/// When this list is set, the client's `Origin` request header will be checked in a
/// case-sensitive manner.
///
/// When all origins are allowed and `send_wildcard` is set, `*` will be sent in the
/// `Access-Control-Allow-Origin` response header. If `send_wildcard` is not set, the client&#39;s
/// `Access-Control-Allow-Origin` response header. If `send_wildcard` is not set, the client's
/// `Origin` request header will be echoed back in the `Access-Control-Allow-Origin`
/// response header.
///
/// If the origin of the request doesn&#39;t match any allowed origins and at least one
/// If the origin of the request doesn't match any allowed origins and at least one
/// `allowed_origin_fn` function is set, these functions will be used to determinate
/// allowed origins.
///
@@ -841,8 +841,8 @@
</span><span class="kw">pub fn </span>allowed_origin(<span class="kw-2">mut </span><span class="self">self</span>, origin: <span class="kw-2">&amp;</span>str) -&gt; Cors {
<span class="kw">if let </span><span class="prelude-val">Some</span>(cors) = cors(<span class="kw-2">&amp;mut </span><span class="self">self</span>.inner, <span class="kw-2">&amp;</span><span class="self">self</span>.error) {
<span class="kw">match </span>TryInto::&lt;Uri&gt;::try_into(origin) {
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) <span class="kw">if </span>origin == <span class="string">&quot;*&quot; </span>=&gt; {
<span class="macro">error!</span>(<span class="string">&quot;Wildcard in `allowed_origin` is not allowed. Use `send_wildcard`.&quot;</span>);
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) <span class="kw">if </span>origin == <span class="string">"*" </span>=&gt; {
<span class="macro">error!</span>(<span class="string">"Wildcard in `allowed_origin` is not allowed. Use `send_wildcard`."</span>);
<span class="self">self</span>.error = <span class="prelude-val">Some</span>(Either::Right(CorsError::WildcardOrigin));
}
@@ -867,17 +867,17 @@
<span class="self">self
</span>}
<span class="doccomment">/// Determinates allowed origins by processing requests which didn&#39;t match any origins specified
<span class="doccomment">/// Determinates allowed origins by processing requests which didn't match any origins specified
/// in the `allowed_origin`.
///
/// The function will receive two parameters, the Origin header value, and the `RequestHead` of
/// each request, which can be used to determine whether to allow the request or not.
///
/// If the function returns `true`, the client&#39;s `Origin` request header will be echoed back
/// If the function returns `true`, the client's `Origin` request header will be echoed back
/// into the `Access-Control-Allow-Origin` response header.
</span><span class="kw">pub fn </span>allowed_origin_fn&lt;F&gt;(<span class="kw-2">mut </span><span class="self">self</span>, f: F) -&gt; Cors
<span class="kw">where
</span>F: (Fn(<span class="kw-2">&amp;</span>HeaderValue, <span class="kw-2">&amp;</span>RequestHead) -&gt; bool) + <span class="lifetime">&#39;static</span>,
</span>F: (Fn(<span class="kw-2">&amp;</span>HeaderValue, <span class="kw-2">&amp;</span>RequestHead) -&gt; bool) + <span class="lifetime">'static</span>,
{
<span class="kw">if let </span><span class="prelude-val">Some</span>(cors) = cors(<span class="kw-2">&amp;mut </span><span class="self">self</span>.inner, <span class="kw-2">&amp;</span><span class="self">self</span>.error) {
cors.allowed_origins_fns.push(OriginFn {
@@ -1106,7 +1106,7 @@
/// Defaults to `false`.
///
/// [Private Network Access]: https://wicg.github.io/private-network-access
</span><span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
</span><span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span><span class="kw">pub fn </span>allow_private_network_access(<span class="kw-2">mut </span><span class="self">self</span>) -&gt; Cors {
<span class="kw">if let </span><span class="prelude-val">Some</span>(cors) = cors(<span class="kw-2">&amp;mut </span><span class="self">self</span>.inner, <span class="kw-2">&amp;</span><span class="self">self</span>.error) {
cors.allow_private_network_access = <span class="bool-val">true</span>;
@@ -1121,7 +1121,7 @@
/// implementation guidelines.
///
/// Setting this header when the `Access-Control-Allow-Origin` is dynamically generated
/// (eg. when there is more than one allowed origin, and an Origin other than &#39;*&#39; is returned)
/// (eg. when there is more than one allowed origin, and an Origin other than '*' is returned)
/// informs CDNs and other caches that the CORS headers are dynamic, and cannot be cached.
///
/// By default, `Vary` header support is enabled.
@@ -1170,7 +1170,7 @@
<span class="doccomment">/// A restrictive (security paranoid) set of defaults.
///
/// *No* allowed origins, methods, request headers or exposed headers. Credentials
/// not supported. No max age (will use browser&#39;s default).
/// not supported. No max age (will use browser's default).
</span><span class="kw">fn </span>default() -&gt; Cors {
<span class="kw">let </span>inner = Inner {
allowed_origins: AllOrSome::Some(HashSet::with_capacity(<span class="number">8</span>)),
@@ -1189,7 +1189,7 @@
preflight: <span class="bool-val">true</span>,
send_wildcard: <span class="bool-val">false</span>,
supports_credentials: <span class="bool-val">false</span>,
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span>allow_private_network_access: <span class="bool-val">false</span>,
vary_header: <span class="bool-val">true</span>,
block_on_origin_mismatch: <span class="bool-val">true</span>,
@@ -1205,9 +1205,9 @@
<span class="kw">impl</span>&lt;S, B&gt; Transform&lt;S, ServiceRequest&gt; <span class="kw">for </span>Cors
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt;,
S::Future: <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = Error;
@@ -1218,8 +1218,8 @@
<span class="kw">fn </span>new_transform(<span class="kw-2">&amp;</span><span class="self">self</span>, service: S) -&gt; <span class="self">Self</span>::Future {
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>err) = <span class="self">self</span>.error {
<span class="kw">match </span>err {
Either::Left(err) =&gt; <span class="macro">error!</span>(<span class="string">&quot;{}&quot;</span>, err),
Either::Right(err) =&gt; <span class="macro">error!</span>(<span class="string">&quot;{}&quot;</span>, err),
Either::Left(err) =&gt; <span class="macro">error!</span>(<span class="string">"{}"</span>, err),
Either::Right(err) =&gt; <span class="macro">error!</span>(<span class="string">"{}"</span>, err),
}
<span class="kw">return </span>future::err(());
@@ -1229,8 +1229,8 @@
<span class="kw">if </span>inner.supports_credentials &amp;&amp; inner.send_wildcard &amp;&amp; inner.allowed_origins.is_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 class="string">"Illegal combination of CORS options: credentials can not be supported when all \
origins are allowed and `send_wildcard` is enabled."
</span>);
<span class="kw">return </span>future::err(());
}
@@ -1270,17 +1270,17 @@
{
<span class="macro">debug_assert!</span>(
!val_set.is_empty(),
<span class="string">&quot;only call `intersperse_header_values` when set is not empty&quot;
<span class="string">"only call `intersperse_header_values` when set is not empty"
</span>);
val_set
.iter()
.fold(String::with_capacity(<span class="number">64</span>), |<span class="kw-2">mut </span>acc, val| {
acc.push_str(<span class="string">&quot;, &quot;</span>);
acc.push_str(<span class="string">", "</span>);
acc.push_str(val.as_ref());
acc
})
<span class="comment">// set is not empty so string will always have leading &quot;, &quot; to trim
<span class="comment">// set is not empty so string will always have leading ", " to trim
</span>[<span class="number">2</span>..]
.try_into()
<span class="comment">// all method names are valid header values
@@ -1322,7 +1322,7 @@
</span>.unwrap();
<span class="kw">let </span>req = TestRequest::default()
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.to_srv_request();
<span class="kw">let </span>resp = test::call_service(<span class="kw-2">&amp;</span>cors, req).<span class="kw">await</span>;
@@ -1331,7 +1331,7 @@
<span class="attr">#[actix_web::test]
</span><span class="kw">async fn </span>allowed_header_try_from() {
<span class="kw">let </span>_cors = Cors::default().allowed_header(<span class="string">&quot;Content-Type&quot;</span>);
<span class="kw">let </span>_cors = Cors::default().allowed_header(<span class="string">"Content-Type"</span>);
}
<span class="attr">#[actix_web::test]
@@ -1342,7 +1342,7 @@
<span class="kw">type </span>Error = Infallible;
<span class="kw">fn </span>try_into(<span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;HeaderName, <span class="self">Self</span>::Error&gt; {
<span class="prelude-val">Ok</span>(HeaderName::from_static(<span class="string">&quot;content-type&quot;</span>))
<span class="prelude-val">Ok</span>(HeaderName::from_static(<span class="string">"content-type"</span>))
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -55,35 +55,35 @@
#[non_exhaustive]
</span><span class="kw">pub enum </span>CorsError {
<span class="doccomment">/// Allowed origin argument must not be wildcard (`*`).
</span><span class="attr">#[display(fmt = <span class="string">&quot;`allowed_origin` argument must not be wildcard (`*`)&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"`allowed_origin` argument must not be wildcard (`*`)"</span>)]
</span>WildcardOrigin,
<span class="doccomment">/// Request header `Origin` is required but was not provided.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Request header `Origin` is required but was not provided&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Request header `Origin` is required but was not provided"</span>)]
</span>MissingOrigin,
<span class="doccomment">/// Request header `Access-Control-Request-Method` is required but is missing.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Request header `Access-Control-Request-Method` is required but is missing&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Request header `Access-Control-Request-Method` is required but is missing"</span>)]
</span>MissingRequestMethod,
<span class="doccomment">/// Request header `Access-Control-Request-Method` has an invalid value.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Request header `Access-Control-Request-Method` has an invalid value&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Request header `Access-Control-Request-Method` has an invalid value"</span>)]
</span>BadRequestMethod,
<span class="doccomment">/// Request header `Access-Control-Request-Headers` has an invalid value.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Request header `Access-Control-Request-Headers` has an invalid value&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Request header `Access-Control-Request-Headers` has an invalid value"</span>)]
</span>BadRequestHeaders,
<span class="doccomment">/// Origin is not allowed to make this request.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Origin is not allowed to make this request&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Origin is not allowed to make this request"</span>)]
</span>OriginNotAllowed,
<span class="doccomment">/// Request method is not allowed.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Requested method is not allowed&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Requested method is not allowed"</span>)]
</span>MethodNotAllowed,
<span class="doccomment">/// One or more request headers are not allowed.
</span><span class="attr">#[display(fmt = <span class="string">&quot;One or more request headers are not allowed&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"One or more request headers are not allowed"</span>)]
</span>HeadersNotAllowed,
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/inner.rs`."><title>inner.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/inner.rs`."><title>inner.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -440,8 +440,8 @@
}
<span class="kw">impl </span>fmt::Debug <span class="kw">for </span>OriginFn {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
f.write_str(<span class="string">&quot;origin_fn&quot;</span>)
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_str(<span class="string">"origin_fn"</span>)
}
}
@@ -471,7 +471,7 @@
<span class="kw">pub</span>(<span class="kw">crate</span>) preflight: bool,
<span class="kw">pub</span>(<span class="kw">crate</span>) send_wildcard: bool,
<span class="kw">pub</span>(<span class="kw">crate</span>) supports_credentials: bool,
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) allow_private_network_access: bool,
<span class="kw">pub</span>(<span class="kw">crate</span>) vary_header: bool,
<span class="kw">pub</span>(<span class="kw">crate</span>) block_on_origin_mismatch: bool,
@@ -519,14 +519,14 @@
.any(|origin_fn| (origin_fn.boxed_fn)(origin, req))
}
<span class="doccomment">/// Only called if origin exists and always after it&#39;s validated.
<span class="doccomment">/// Only called if origin exists and always after it's validated.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>access_control_allow_origin(<span class="kw-2">&amp;</span><span class="self">self</span>, req: <span class="kw-2">&amp;</span>RequestHead) -&gt; <span class="prelude-ty">Option</span>&lt;HeaderValue&gt; {
<span class="kw">let </span>origin = req.headers().get(header::ORIGIN);
<span class="kw">match </span><span class="self">self</span>.allowed_origins {
AllOrSome::All =&gt; {
<span class="kw">if </span><span class="self">self</span>.send_wildcard {
<span class="prelude-val">Some</span>(HeaderValue::from_static(<span class="string">&quot;*&quot;</span>))
<span class="prelude-val">Some</span>(HeaderValue::from_static(<span class="string">"*"</span>))
} <span class="kw">else </span>{
<span class="comment">// see note below about why `.cloned()` is correct
</span>origin.cloned()
@@ -590,7 +590,7 @@
</span><span class="kw">let </span><span class="kw-2">mut </span>request_headers = HashSet::with_capacity(<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>hdr <span class="kw">in </span>headers.split(<span class="string">&#39;,&#39;</span>) {
</span><span class="kw">for </span>hdr <span class="kw">in </span>headers.split(<span class="string">','</span>) {
<span class="kw">match </span>hdr.trim().try_into() {
<span class="prelude-val">Ok</span>(hdr) =&gt; request_headers.insert(hdr),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(CorsError::BadRequestHeaders),
@@ -619,7 +619,7 @@
}
}
<span class="doccomment">/// Add CORS related request headers to response&#39;s Vary header.
<span class="doccomment">/// Add CORS related request headers to response's Vary header.
///
/// See &lt;https://fetch.spec.whatwg.org/#cors-protocol-and-http-caches&gt;.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>add_vary_header(headers: <span class="kw-2">&amp;mut </span>HeaderMap) {
@@ -627,23 +627,23 @@
<span class="prelude-val">Some</span>(hdr) =&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>val: Vec&lt;u8&gt; = Vec::with_capacity(hdr.len() + <span class="number">71</span>);
val.extend(hdr.as_bytes());
val.extend(<span class="string">b&quot;, Origin, Access-Control-Request-Method, Access-Control-Request-Headers&quot;</span>);
val.extend(<span class="string">b", Origin, Access-Control-Request-Method, Access-Control-Request-Headers"</span>);
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
</span>val.extend(<span class="string">b&quot;, Access-Control-Allow-Private-Network&quot;</span>);
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span>val.extend(<span class="string">b", Access-Control-Request-Private-Network"</span>);
val.try_into().unwrap()
}
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span><span class="prelude-val">None </span>=&gt; HeaderValue::from_static(
<span class="string">&quot;Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \
Access-Control-Allow-Private-Network&quot;</span>,
<span class="string">"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \
Access-Control-Request-Private-Network"</span>,
),
<span class="attr">#[cfg(not(feature = <span class="string">&quot;draft-private-network-access&quot;</span>))]
<span class="attr">#[cfg(not(feature = <span class="string">"draft-private-network-access"</span>))]
</span><span class="prelude-val">None </span>=&gt; HeaderValue::from_static(
<span class="string">&quot;Origin, Access-Control-Request-Method, Access-Control-Request-Headers&quot;</span>,
<span class="string">"Origin, Access-Control-Request-Method, Access-Control-Request-Headers"</span>,
),
};
@@ -672,14 +672,14 @@
<span class="attr">#[actix_web::test]
</span><span class="kw">async fn </span>test_validate_not_allowed_origin() {
<span class="kw">let </span>cors = Cors::default()
.allowed_origin(<span class="string">&quot;https://www.example.com&quot;</span>)
.allowed_origin(<span class="string">"https://www.example.com"</span>)
.new_transform(test::ok_service())
.<span class="kw">await
</span>.unwrap();
<span class="kw">let </span>req = TestRequest::get()
.insert_header((header::ORIGIN, <span class="string">&quot;https://www.unknown.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_HEADERS, <span class="string">&quot;DNT&quot;</span>))
.insert_header((header::ORIGIN, <span class="string">"https://www.unknown.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_HEADERS, <span class="string">"DNT"</span>))
.to_srv_request();
<span class="macro">assert!</span>(cors.inner.validate_origin(req.head()).is_err());
@@ -702,8 +702,8 @@
<span class="kw">let </span>req = TestRequest::default()
.method(Method::OPTIONS)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_HEADERS, <span class="string">&quot;X-Not-Allowed&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_HEADERS, <span class="string">"X-Not-Allowed"</span>))
.to_srv_request();
<span class="macro">assert!</span>(cors.inner.validate_allowed_method(req.head()).is_err());
@@ -713,8 +713,8 @@
<span class="kw">let </span>req = TestRequest::default()
.method(Method::OPTIONS)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">&quot;put&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">"put"</span>))
.to_srv_request();
<span class="macro">assert!</span>(cors.inner.validate_allowed_method(req.head()).is_err());
@@ -722,23 +722,23 @@
<span class="kw">let </span>req = TestRequest::default()
.method(Method::OPTIONS)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">&quot;POST&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">"POST"</span>))
.insert_header((
header::ACCESS_CONTROL_REQUEST_HEADERS,
<span class="string">&quot;AUTHORIZATION,ACCEPT&quot;</span>,
<span class="string">"AUTHORIZATION,ACCEPT"</span>,
))
.to_srv_request();
<span class="kw">let </span>resp = test::call_service(<span class="kw-2">&amp;</span>cors, req).<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="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b"*"</span>[..]),
resp.headers()
.get(header::ACCESS_CONTROL_ALLOW_ORIGIN)
.map(HeaderValue::as_bytes)
);
<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="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b"3600"</span>[..]),
resp.headers()
.get(header::ACCESS_CONTROL_MAX_AGE)
.map(HeaderValue::as_bytes)
@@ -749,9 +749,9 @@
.get(header::ACCESS_CONTROL_ALLOW_HEADERS)
.map(val_as_str)
.unwrap();
<span class="macro">assert!</span>(hdr.contains(<span class="string">&quot;authorization&quot;</span>));
<span class="macro">assert!</span>(hdr.contains(<span class="string">&quot;accept&quot;</span>));
<span class="macro">assert!</span>(hdr.contains(<span class="string">&quot;content-type&quot;</span>));
<span class="macro">assert!</span>(hdr.contains(<span class="string">"authorization"</span>));
<span class="macro">assert!</span>(hdr.contains(<span class="string">"accept"</span>));
<span class="macro">assert!</span>(hdr.contains(<span class="string">"content-type"</span>));
<span class="kw">let </span>methods = resp
.headers()
@@ -759,19 +759,19 @@
.unwrap()
.to_str()
.unwrap();
<span class="macro">assert!</span>(methods.contains(<span class="string">&quot;POST&quot;</span>));
<span class="macro">assert!</span>(methods.contains(<span class="string">&quot;GET&quot;</span>));
<span class="macro">assert!</span>(methods.contains(<span class="string">&quot;OPTIONS&quot;</span>));
<span class="macro">assert!</span>(methods.contains(<span class="string">"POST"</span>));
<span class="macro">assert!</span>(methods.contains(<span class="string">"GET"</span>));
<span class="macro">assert!</span>(methods.contains(<span class="string">"OPTIONS"</span>));
Rc::get_mut(<span class="kw-2">&amp;mut </span>cors.inner).unwrap().preflight = <span class="bool-val">false</span>;
<span class="kw">let </span>req = TestRequest::default()
.method(Method::OPTIONS)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">&quot;POST&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">"POST"</span>))
.insert_header((
header::ACCESS_CONTROL_REQUEST_HEADERS,
<span class="string">&quot;AUTHORIZATION,ACCEPT&quot;</span>,
<span class="string">"AUTHORIZATION,ACCEPT"</span>,
))
.to_srv_request();
@@ -786,7 +786,7 @@
<span class="kw">let </span>head_origin = head
.headers()
.get(header::ORIGIN)
.expect(<span class="string">&quot;unwrapping origin header should never fail in allowed_origin_fn&quot;</span>);
.expect(<span class="string">"unwrapping origin header should never fail in allowed_origin_fn"</span>);
<span class="macro">assert!</span>(origin == head_origin);
<span class="bool-val">true
</span>})
@@ -798,15 +798,15 @@
<span class="kw">let </span>req = TestRequest::default()
.method(Method::OPTIONS)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">&quot;POST&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, <span class="string">"POST"</span>))
.to_srv_request();
<span class="kw">let </span>resp = test::call_service(<span class="kw-2">&amp;</span>cors, req).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(resp.status(), StatusCode::OK);
<span class="kw">let </span>req = TestRequest::default()
.method(Method::GET)
.insert_header((<span class="string">&quot;Origin&quot;</span>, <span class="string">&quot;https://www.example.com&quot;</span>))
.insert_header((<span class="string">"Origin"</span>, <span class="string">"https://www.example.com"</span>))
.to_srv_request();
<span class="kw">let </span>resp = test::call_service(<span class="kw-2">&amp;</span>cors, req).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(resp.status(), StatusCode::NO_CONTENT);

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -69,7 +69,7 @@
</pre></div><pre class="rust"><code><span class="doccomment">//! Cross-Origin Resource Sharing (CORS) controls for Actix Web.
//!
//! This middleware can be applied to both applications and resources. Once built, a [`Cors`]
//! builder can be used as an argument for Actix Web&#39;s `App::wrap()`, `Scope::wrap()`, or
//! builder can be used as an argument for Actix Web's `App::wrap()`, `Scope::wrap()`, or
//! `Resource::wrap()` methods.
//!
//! This CORS middleware automatically handles `OPTIONS` preflight requests.
@@ -84,20 +84,20 @@
//! use actix_cors::Cors;
//! use actix_web::{get, http, web, App, HttpRequest, HttpResponse, HttpServer};
//!
//! #[get(&quot;/index.html&quot;)]
//! async fn index(req: HttpRequest) -&gt; &amp;&#39;static str {
//! &quot;&lt;p&gt;Hello World!&lt;/p&gt;&quot;
//! #[get("/index.html")]
//! async fn index(req: HttpRequest) -&gt; &amp;'static str {
//! "&lt;p&gt;Hello World!&lt;/p&gt;"
//! }
//!
//! #[actix_web::main]
//! async fn main() -&gt; std::io::Result&lt;()&gt; {
//! HttpServer::new(|| {
//! let cors = Cors::default()
//! .allowed_origin(&quot;https://www.rust-lang.org&quot;)
//! .allowed_origin("https://www.rust-lang.org")
//! .allowed_origin_fn(|origin, _req_head| {
//! origin.as_bytes().ends_with(b&quot;.rust-lang.org&quot;)
//! origin.as_bytes().ends_with(b".rust-lang.org")
//! })
//! .allowed_methods(vec![&quot;GET&quot;, &quot;POST&quot;])
//! .allowed_methods(vec!["GET", "POST"])
//! .allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
//! .allowed_header(http::header::CONTENT_TYPE)
//! .max_age(3600);
@@ -106,7 +106,7 @@
//! .wrap(cors)
//! .service(index)
//! })
//! .bind((&quot;127.0.0.1&quot;, 8080))?
//! .bind(("127.0.0.1", 8080))?
//! .run()
//! .await;
//!
@@ -119,8 +119,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs, missing_debug_implementations)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">mod </span>all_or_some;

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-cors/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-cors/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_cors" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_cors/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_cors"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -393,22 +393,22 @@
</span>res.insert_header((header::ACCESS_CONTROL_ALLOW_HEADERS, headers.clone()));
}
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span><span class="kw">if </span>inner.allow_private_network_access
&amp;&amp; req
.headers()
.contains_key(<span class="string">&quot;access-control-request-private-network&quot;</span>)
.contains_key(<span class="string">"access-control-request-private-network"</span>)
{
res.insert_header((
header::HeaderName::from_static(<span class="string">&quot;access-control-allow-private-network&quot;</span>),
HeaderValue::from_static(<span class="string">&quot;true&quot;</span>),
header::HeaderName::from_static(<span class="string">"access-control-allow-private-network"</span>),
HeaderValue::from_static(<span class="string">"true"</span>),
));
}
<span class="kw">if </span>inner.supports_credentials {
res.insert_header((
header::ACCESS_CONTROL_ALLOW_CREDENTIALS,
HeaderValue::from_static(<span class="string">&quot;true&quot;</span>),
HeaderValue::from_static(<span class="string">"true"</span>),
));
}
@@ -438,7 +438,7 @@
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>expose) = inner.expose_headers_baked {
<span class="macro">log::trace!</span>(<span class="string">&quot;exposing selected headers: {:?}&quot;</span>, expose);
<span class="macro">log::trace!</span>(<span class="string">"exposing selected headers: {:?}"</span>, expose);
res.headers_mut()
.insert(header::ACCESS_CONTROL_EXPOSE_HEADERS, expose.clone());
@@ -456,7 +456,7 @@
</span><span class="kw">let </span>expose_headers_value = intersperse_header_values(<span class="kw-2">&amp;</span>expose_all_request_headers);
<span class="macro">log::trace!</span>(
<span class="string">&quot;exposing all headers from request: {:?}&quot;</span>,
<span class="string">"exposing all headers from request: {:?}"</span>,
expose_headers_value
);
@@ -469,20 +469,20 @@
<span class="kw">if </span>inner.supports_credentials {
res.headers_mut().insert(
header::ACCESS_CONTROL_ALLOW_CREDENTIALS,
HeaderValue::from_static(<span class="string">&quot;true&quot;</span>),
HeaderValue::from_static(<span class="string">"true"</span>),
);
}
<span class="attr">#[cfg(feature = <span class="string">&quot;draft-private-network-access&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"draft-private-network-access"</span>)]
</span><span class="kw">if </span>inner.allow_private_network_access
&amp;&amp; res
.request()
.headers()
.contains_key(<span class="string">&quot;access-control-request-private-network&quot;</span>)
.contains_key(<span class="string">"access-control-request-private-network"</span>)
{
res.headers_mut().insert(
header::HeaderName::from_static(<span class="string">&quot;access-control-allow-private-network&quot;</span>),
HeaderValue::from_static(<span class="string">&quot;true&quot;</span>),
header::HeaderName::from_static(<span class="string">"access-control-allow-private-network"</span>),
HeaderValue::from_static(<span class="string">"true"</span>),
);
}
@@ -497,13 +497,13 @@
<span class="kw">impl</span>&lt;S, B&gt; Service&lt;ServiceRequest&gt; <span class="kw">for </span>CorsMiddleware&lt;S&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt;,
S::Future: <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = Error;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;ServiceResponse&lt;EitherBody&lt;B&gt;&gt;, Error&gt;&gt;;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;ServiceResponse&lt;EitherBody&lt;B&gt;&gt;, Error&gt;&gt;;
<span class="macro">forward_ready!</span>(service);
@@ -521,7 +521,7 @@
(<span class="prelude-val">None</span>, <span class="kw">_</span>) =&gt; <span class="bool-val">false</span>,
(<span class="kw">_</span>, <span class="prelude-val">Ok</span>(origin_allowed)) =&gt; origin_allowed,
(<span class="kw">_</span>, <span class="prelude-val">Err</span>(err)) =&gt; {
<span class="macro">debug!</span>(<span class="string">&quot;origin validation failed; inner service is not called&quot;</span>);
<span class="macro">debug!</span>(<span class="string">"origin validation failed; inner service is not called"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>res = req.error_response(err);
<span class="kw">if </span><span class="self">self</span>.inner.vary_header {
@@ -575,7 +575,7 @@
</span>.unwrap();
<span class="kw">let </span>req = TestRequest::get()
.insert_header((header::ORIGIN, <span class="string">&quot;http://example.com&quot;</span>))
.insert_header((header::ORIGIN, <span class="string">"http://example.com"</span>))
.to_srv_request();
<span class="kw">let </span>res = cors.call(req).<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
@@ -586,12 +586,12 @@
);
<span class="kw">let </span>req = TestRequest::get()
.insert_header((header::ORIGIN, <span class="string">&quot;http://example.com&quot;</span>))
.insert_header((header::DNT, <span class="string">&quot;1&quot;</span>))
.insert_header((header::ORIGIN, <span class="string">"http://example.com"</span>))
.insert_header((header::DNT, <span class="string">"1"</span>))
.to_srv_request();
<span class="kw">let </span>res = cors.call(req).<span class="kw">await</span>.unwrap();
<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="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">b"http://example.com"</span>[..]),
res.headers()
.get(header::ACCESS_CONTROL_ALLOW_ORIGIN)
.map(HeaderValue::as_bytes)

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -132,14 +132,14 @@
<span class="doccomment">/// When [`Identity::logout`](crate::Identity::logout) is called, purge the current session.
///
/// This behaviour might be desirable when you have stored additional information in the
/// session state that are tied to the user&#39;s identity and should not be retained after logout.
/// session state that are tied to the user's identity and should not be retained after logout.
</span>PurgeSession,
<span class="doccomment">/// When [`Identity::logout`](crate::Identity::logout) is called, remove the identity
/// information from the current session state. The session itself is not destroyed.
///
/// This behaviour might be desirable when you have stored information in the session state that
/// is not tied to the user&#39;s identity and should be retained after logout.
/// is not tied to the user's identity and should be retained after logout.
</span>DeleteIdentityKeys,
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -76,7 +76,7 @@
<span class="doccomment">/// Error that can occur during login attempts.
</span><span class="attr">#[derive(Debug, Display, Error, From)]
#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
#[display(fmt = <span class="string">"{_0}"</span>)]
</span><span class="kw">pub struct </span>LoginError(SessionInsertError);
<span class="kw">impl </span>ResponseError <span class="kw">for </span>LoginError {
@@ -87,7 +87,7 @@
<span class="doccomment">/// Error encountered when working with a session that has expired.
</span><span class="attr">#[derive(Debug, Display, Error)]
#[display(fmt = <span class="string">&quot;The given session has expired and is no longer valid&quot;</span>)]
#[display(fmt = <span class="string">"The given session has expired and is no longer valid"</span>)]
</span><span class="kw">pub struct </span>SessionExpiryError(<span class="attr">#[error(not(source))] </span><span class="kw">pub</span>(<span class="kw">crate</span>) ComponentRange);
<span class="doccomment">/// The identity information has been lost.
@@ -95,15 +95,15 @@
/// Seeing this error in user code indicates a bug in actix-identity.
</span><span class="attr">#[derive(Debug, Display, Error)]
#[display(
fmt = <span class="string">&quot;The identity information in the current session has disappeared after having been \
successfully validated. This is likely to be a bug.&quot;
fmt = <span class="string">"The identity information in the current session has disappeared after having been \
successfully validated. This is likely to be a bug."
</span>)]
#[non_exhaustive]
</span><span class="kw">pub struct </span>LostIdentityError;
<span class="doccomment">/// There is no identity information attached to the current session.
</span><span class="attr">#[derive(Debug, Display, Error)]
#[display(fmt = <span class="string">&quot;There is no identity information attached to the current session&quot;</span>)]
#[display(fmt = <span class="string">"There is no identity information attached to the current session"</span>)]
#[non_exhaustive]
</span><span class="kw">pub struct </span>MissingIdentityError;
@@ -112,21 +112,21 @@
#[non_exhaustive]
</span><span class="kw">pub enum </span>GetIdentityError {
<span class="doccomment">/// The session has expired.
</span><span class="attr">#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"{_0}"</span>)]
</span>SessionExpiryError(SessionExpiryError),
<span class="doccomment">/// No identity is found in a session.
</span><span class="attr">#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"{_0}"</span>)]
</span>MissingIdentityError(MissingIdentityError),
<span class="doccomment">/// Failed to accessing the session store.
</span><span class="attr">#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"{_0}"</span>)]
</span>SessionGetError(SessionGetError),
<span class="doccomment">/// Identity info was lost after being validated.
///
/// Seeing this error indicates a bug in actix-identity.
</span><span class="attr">#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"{_0}"</span>)]
</span>LostIdentityError(LostIdentityError),
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/identity.rs`."><title>identity.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/identity.rs`."><title>identity.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -296,22 +296,22 @@
/// };
/// use actix_identity::Identity;
///
/// #[get(&quot;/&quot;)]
/// #[get("/")]
/// async fn index(user: Option&lt;Identity&gt;) -&gt; impl Responder {
/// if let Some(user) = user {
/// format!(&quot;Welcome! {}&quot;, user.id().unwrap())
/// format!("Welcome! {}", user.id().unwrap())
/// } else {
/// &quot;Welcome Anonymous!&quot;.to_owned()
/// "Welcome Anonymous!".to_owned()
/// }
/// }
///
/// #[post(&quot;/login&quot;)]
/// #[post("/login")]
/// async fn login(request: HttpRequest) -&gt; impl Responder {
/// Identity::login(&amp;request.extensions(), &quot;User1&quot;.into());
/// Identity::login(&amp;request.extensions(), "User1".into());
/// HttpResponse::Ok()
/// }
///
/// #[post(&quot;/logout&quot;)]
/// #[post("/logout")]
/// async fn logout(user: Identity) -&gt; impl Responder {
/// user.logout();
/// HttpResponse::Ok()
@@ -331,14 +331,14 @@
/// use actix_web::{http::header::LOCATION, get, HttpResponse, Responder};
/// use actix_identity::Identity;
///
/// #[get(&quot;/&quot;)]
/// #[get("/")]
/// async fn index(user: Option&lt;Identity&gt;) -&gt; impl Responder {
/// if let Some(user) = user {
/// HttpResponse::Ok().finish()
/// } else {
/// // Redirect to login page if unauthenticated
/// HttpResponse::TemporaryRedirect()
/// .insert_header((LOCATION, &quot;/login&quot;))
/// .insert_header((LOCATION, "/login"))
/// .finish()
/// }
/// }
@@ -357,12 +357,12 @@
<span class="kw">fn </span>extract(ext: <span class="kw-2">&amp;</span>Extensions) -&gt; <span class="self">Self </span>{
ext.get::&lt;<span class="self">Self</span>&gt;()
.expect(
<span class="string">&quot;No `IdentityInner` instance was found in the extensions attached to the \
<span class="string">"No `IdentityInner` instance was found in the extensions attached to the \
incoming request. This usually means that `IdentityMiddleware` has not been \
registered as an application middleware via `App::wrap`. `Identity` cannot be used \
unless the identity machine is properly mounted: register `IdentityMiddleware` as \
a middleware for your application to fix this panic. If the problem persists, \
please file an issue on GitHub.&quot;</span>,
please file an issue on GitHub."</span>,
)
.to_owned()
}
@@ -375,9 +375,9 @@
}
}
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>ID_KEY: <span class="kw-2">&amp;</span>str = <span class="string">&quot;actix_identity.user_id&quot;</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>LAST_VISIT_UNIX_TIMESTAMP_KEY: <span class="kw-2">&amp;</span>str = <span class="string">&quot;actix_identity.last_visited_at&quot;</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>LOGIN_UNIX_TIMESTAMP_KEY: <span class="kw-2">&amp;</span>str = <span class="string">&quot;actix_identity.logged_in_at&quot;</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>ID_KEY: <span class="kw-2">&amp;</span>str = <span class="string">"actix_identity.user_id"</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>LAST_VISIT_UNIX_TIMESTAMP_KEY: <span class="kw-2">&amp;</span>str = <span class="string">"actix_identity.last_visited_at"</span>;
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>LOGIN_UNIX_TIMESTAMP_KEY: <span class="kw-2">&amp;</span>str = <span class="string">"actix_identity.logged_in_at"</span>;
<span class="kw">impl </span>Identity {
<span class="doccomment">/// Return the user id associated to the current session.
@@ -387,12 +387,12 @@
/// use actix_web::{get, Responder};
/// use actix_identity::Identity;
///
/// #[get(&quot;/&quot;)]
/// #[get("/")]
/// async fn index(user: Option&lt;Identity&gt;) -&gt; impl Responder {
/// if let Some(user) = user {
/// format!(&quot;Welcome! {}&quot;, user.id().unwrap())
/// format!("Welcome! {}", user.id().unwrap())
/// } else {
/// &quot;Welcome Anonymous!&quot;.to_owned()
/// "Welcome Anonymous!".to_owned()
/// }
/// }
/// ```
@@ -414,9 +414,9 @@
/// use actix_web::{post, Responder, HttpRequest, HttpMessage, HttpResponse};
/// use actix_identity::Identity;
///
/// #[post(&quot;/login&quot;)]
/// #[post("/login")]
/// async fn login(request: HttpRequest) -&gt; impl Responder {
/// Identity::login(&amp;request.extensions(), &quot;User1&quot;.into());
/// Identity::login(&amp;request.extensions(), "User1".into());
/// HttpResponse::Ok()
/// }
/// ```
@@ -446,7 +446,7 @@
/// use actix_web::{post, Responder, HttpResponse};
/// use actix_identity::Identity;
///
/// #[post(&quot;/logout&quot;)]
/// #[post("/logout")]
/// async fn logout(user: Identity) -&gt; impl Responder {
/// user.logout();
/// HttpResponse::Ok()
@@ -511,12 +511,12 @@
/// use actix_web::{get, Responder};
/// use actix_identity::Identity;
///
/// #[get(&quot;/&quot;)]
/// #[get("/")]
/// async fn index(user: Option&lt;Identity&gt;) -&gt; impl Responder {
/// if let Some(user) = user {
/// format!(&quot;Welcome! {}&quot;, user.id().unwrap())
/// format!("Welcome! {}", user.id().unwrap())
/// } else {
/// &quot;Welcome Anonymous!&quot;.to_owned()
/// "Welcome Anonymous!".to_owned()
/// }
/// }
/// ```

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/identity_ext.rs`."><title>identity_ext.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/identity_ext.rs`."><title>identity_ext.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -29,7 +29,7 @@
<span class="kw">use crate</span>::{error::GetIdentityError, Identity};
<span class="doccomment">/// Helper trait to retrieve an [`Identity`] instance from various `actix-web`&#39;s types.
<span class="doccomment">/// Helper trait to retrieve an [`Identity`] instance from various `actix-web`'s types.
</span><span class="kw">pub trait </span>IdentityExt {
<span class="doccomment">/// Retrieve the identity attached to the current session, if available.
</span><span class="kw">fn </span>get_identity(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;Identity, GetIdentityError&gt;;
@@ -47,7 +47,7 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; IdentityExt <span class="kw">for </span>GuardContext&lt;<span class="lifetime">&#39;a</span>&gt; {
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; IdentityExt <span class="kw">for </span>GuardContext&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">fn </span>get_identity(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;Identity, GetIdentityError&gt; {
Identity::extract(<span class="kw-2">&amp;</span><span class="self">self</span>.req_data())
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -118,7 +118,7 @@
//! #[actix_web::main]
//! async fn main() {
//! let secret_key = Key::generate();
//! let redis_store = RedisSessionStore::new(&quot;redis://127.0.0.1:6379&quot;)
//! let redis_store = RedisSessionStore::new("redis://127.0.0.1:6379")
//! .await
//! .unwrap();
//!
@@ -149,28 +149,28 @@
//! use actix_identity::Identity;
//! use actix_session::storage::RedisSessionStore;
//!
//! #[get(&quot;/&quot;)]
//! #[get("/")]
//! async fn index(user: Option&lt;Identity&gt;) -&gt; impl Responder {
//! if let Some(user) = user {
//! format!(&quot;Welcome! {}&quot;, user.id().unwrap())
//! format!("Welcome! {}", user.id().unwrap())
//! } else {
//! &quot;Welcome Anonymous!&quot;.to_owned()
//! "Welcome Anonymous!".to_owned()
//! }
//! }
//!
//! #[post(&quot;/login&quot;)]
//! #[post("/login")]
//! async fn login(request: HttpRequest) -&gt; impl Responder {
//! // Some kind of authentication should happen here
//! // e.g. password-based, biometric, etc.
//! // [...]
//!
//! // attach a verified user identity to the active session
//! Identity::login(&amp;request.extensions(), &quot;User1&quot;.into()).unwrap();
//! Identity::login(&amp;request.extensions(), "User1".into()).unwrap();
//!
//! HttpResponse::Ok()
//! }
//!
//! #[post(&quot;/logout&quot;)]
//! #[post("/logout")]
//! async fn logout(user: Identity) -&gt; impl Responder {
//! user.logout();
//! HttpResponse::Ok()
@@ -191,8 +191,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style, missing_docs)]
#![warn(future_incompatible)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">pub mod </span>config;

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-identity/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-identity/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_identity" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_identity/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_identity"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -283,7 +283,7 @@
/// #[actix_web::main]
/// async fn main() {
/// let secret_key = Key::generate();
/// let redis_store = RedisSessionStore::new(&quot;redis://127.0.0.1:6379&quot;).await.unwrap();
/// let redis_store = RedisSessionStore::new("redis://127.0.0.1:6379").await.unwrap();
///
/// HttpServer::new(move || {
/// App::new()
@@ -316,9 +316,9 @@
<span class="kw">impl</span>&lt;S, B&gt; Transform&lt;S, ServiceRequest&gt; <span class="kw">for </span>IdentityMiddleware
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;B&gt;;
<span class="kw">type </span>Error = Error;
@@ -351,13 +351,13 @@
<span class="kw">impl</span>&lt;S, B&gt; Service&lt;ServiceRequest&gt; <span class="kw">for </span>InnerIdentityMiddleware&lt;S&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;B&gt;;
<span class="kw">type </span>Error = Error;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Response, <span class="self">Self</span>::Error&gt;&gt;;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Response, <span class="self">Self</span>::Error&gt;&gt;;
<span class="macro">actix_service::forward_ready!</span>(service);
@@ -395,7 +395,7 @@
<span class="macro">tracing::debug!</span>(
error.display = %err,
error.debug = <span class="question-mark">?</span>err,
<span class="string">&quot;Failed to extract an `Identity` from the incoming request.&quot;
<span class="string">"Failed to extract an `Identity` from the incoming request."
</span>);
<span class="kw">return</span>;
}
@@ -422,7 +422,7 @@
<span class="macro">tracing::warn!</span>(
error.display = %err,
error.debug = <span class="question-mark">?</span>err,
<span class="string">&quot;Failed to set the last visited timestamp on `Identity` for an incoming request.&quot;
<span class="string">"Failed to set the last visited timestamp on `Identity` for an incoming request."
</span>);
}
}
@@ -435,8 +435,8 @@
<span class="kw">match </span>identity.logged_at() {
<span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>) =&gt; {
<span class="macro">tracing::info!</span>(
<span class="string">&quot;Login deadline is enabled, but there is no login timestamp in the session \
state attached to the incoming request. Logging the user out.&quot;
<span class="string">"Login deadline is enabled, but there is no login timestamp in the session \
state attached to the incoming request. Logging the user out."
</span>);
PolicyDecision::LogOut
}
@@ -444,8 +444,8 @@
<span class="macro">tracing::info!</span>(
error.display = %err,
error.debug = <span class="question-mark">?</span>err,
<span class="string">&quot;Login deadline is enabled but we failed to extract the login timestamp from the \
session state attached to the incoming request. Logging the user out.&quot;
<span class="string">"Login deadline is enabled but we failed to extract the login timestamp from the \
session state attached to the incoming request. Logging the user out."
</span>);
PolicyDecision::LogOut
}
@@ -456,8 +456,8 @@
user.logged_in_at = %logged_in_at.format(<span class="kw-2">&amp;</span>Rfc3339).unwrap_or_default(),
identity.login_deadline_seconds = login_deadline.as_secs(),
identity.elapsed_since_login_seconds = elapsed.whole_seconds(),
<span class="string">&quot;Login deadline is enabled and too much time has passed since the user logged \
in. Logging the user out.&quot;
<span class="string">"Login deadline is enabled and too much time has passed since the user logged \
in. Logging the user out."
</span>);
PolicyDecision::LogOut
} <span class="kw">else </span>{
@@ -474,8 +474,8 @@
<span class="kw">match </span>identity.last_visited_at() {
<span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>) =&gt; {
<span class="macro">tracing::info!</span>(
<span class="string">&quot;Last visit deadline is enabled, but there is no last visit timestamp in the \
session state attached to the incoming request. Logging the user out.&quot;
<span class="string">"Last visit deadline is enabled, but there is no last visit timestamp in the \
session state attached to the incoming request. Logging the user out."
</span>);
PolicyDecision::LogOut
}
@@ -483,8 +483,8 @@
<span class="macro">tracing::info!</span>(
error.display = %err,
error.debug = <span class="question-mark">?</span>err,
<span class="string">&quot;Last visit deadline is enabled but we failed to extract the last visit timestamp \
from the session state attached to the incoming request. Logging the user out.&quot;
<span class="string">"Last visit deadline is enabled but we failed to extract the last visit timestamp \
from the session state attached to the incoming request. Logging the user out."
</span>);
PolicyDecision::LogOut
}
@@ -495,8 +495,8 @@
user.last_visited_at = %last_visited_at.format(<span class="kw-2">&amp;</span>Rfc3339).unwrap_or_default(),
identity.visit_deadline_seconds = visit_deadline.as_secs(),
identity.elapsed_since_last_visit_seconds = elapsed.whole_seconds(),
<span class="string">&quot;Last visit deadline is enabled and too much time has passed since the last \
time the user visited. Logging the user out.&quot;
<span class="string">"Last visit deadline is enabled and too much time has passed since the last \
time the user visited. Logging the user out."
</span>);
PolicyDecision::LogOut
} <span class="kw">else </span>{

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-limitation/src/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-limitation/src/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -171,7 +171,7 @@
<a href="#171" id="171">171</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>std::{borrow::Cow, sync::Arc, time::Duration};
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">use </span>actix_session::SessionExt <span class="kw">as _</span>;
<span class="kw">use </span>actix_web::dev::ServiceRequest;
<span class="kw">use </span>redis::Client;
@@ -185,9 +185,9 @@
<span class="kw">pub</span>(<span class="kw">crate</span>) limit: usize,
<span class="kw">pub</span>(<span class="kw">crate</span>) period: Duration,
<span class="kw">pub</span>(<span class="kw">crate</span>) get_key_fn: <span class="prelude-ty">Option</span>&lt;GetArcBoxKeyFn&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) cookie_name: Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;,
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) session_key: Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) cookie_name: Cow&lt;<span class="lifetime">'static</span>, str&gt;,
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) session_key: Cow&lt;<span class="lifetime">'static</span>, str&gt;,
}
<span class="kw">impl </span>Builder {
@@ -208,7 +208,7 @@
/// Should not be used in combination with `cookie_name` or `session_key` as they conflict.
</span><span class="kw">pub fn </span>key_by&lt;F&gt;(<span class="kw-2">&amp;mut </span><span class="self">self</span>, resolver: F) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self
</span><span class="kw">where
</span>F: Fn(<span class="kw-2">&amp;</span>ServiceRequest) -&gt; <span class="prelude-ty">Option</span>&lt;String&gt; + Send + Sync + <span class="lifetime">&#39;static</span>,
</span>F: Fn(<span class="kw-2">&amp;</span>ServiceRequest) -&gt; <span class="prelude-ty">Option</span>&lt;String&gt; + Send + Sync + <span class="lifetime">'static</span>,
{
<span class="self">self</span>.get_key_fn = <span class="prelude-val">Some</span>(Arc::new(resolver));
<span class="self">self
@@ -217,10 +217,10 @@
<span class="doccomment">/// Sets name of cookie to be sent.
///
/// This method should not be used in combination of `key_by` as they conflict.
</span><span class="attr">#[deprecated = <span class="string">&quot;Prefer `key_by`.&quot;</span>]
</span><span class="kw">pub fn </span>cookie_name(<span class="kw-2">&amp;mut </span><span class="self">self</span>, cookie_name: <span class="kw">impl </span>Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self </span>{
</span><span class="attr">#[deprecated = <span class="string">"Prefer `key_by`."</span>]
</span><span class="kw">pub fn </span>cookie_name(<span class="kw-2">&amp;mut </span><span class="self">self</span>, cookie_name: <span class="kw">impl </span>Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self </span>{
<span class="kw">if </span><span class="self">self</span>.get_key_fn.is_some() {
<span class="macro">panic!</span>(<span class="string">&quot;This method should not be used in combination of get_key as they overwrite each other&quot;</span>)
<span class="macro">panic!</span>(<span class="string">"This method should not be used in combination of get_key as they overwrite each other"</span>)
}
<span class="self">self</span>.cookie_name = cookie_name.into();
<span class="self">self
@@ -229,11 +229,11 @@
<span class="doccomment">/// Sets session key to be used in backend.
///
/// This method should not be used in combination of `key_by` as they conflict.
</span><span class="attr">#[deprecated = <span class="string">&quot;Prefer `key_by`.&quot;</span>]
#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span><span class="kw">pub fn </span>session_key(<span class="kw-2">&amp;mut </span><span class="self">self</span>, session_key: <span class="kw">impl </span>Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self </span>{
</span><span class="attr">#[deprecated = <span class="string">"Prefer `key_by`."</span>]
#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">pub fn </span>session_key(<span class="kw-2">&amp;mut </span><span class="self">self</span>, session_key: <span class="kw">impl </span>Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self </span>{
<span class="kw">if </span><span class="self">self</span>.get_key_fn.is_some() {
<span class="macro">panic!</span>(<span class="string">&quot;This method should not be used in combination of get_key as they overwrite each other&quot;</span>)
<span class="macro">panic!</span>(<span class="string">"This method should not be used in combination of get_key as they overwrite each other"</span>)
}
<span class="self">self</span>.session_key = session_key.into();
<span class="self">self
@@ -249,17 +249,17 @@
} <span class="kw">else </span>{
<span class="kw">let </span>cookie_name = <span class="self">self</span>.cookie_name.clone();
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">let </span>session_key = <span class="self">self</span>.session_key.clone();
<span class="kw">let </span>closure: GetArcBoxKeyFn = Arc::new(Box::new(<span class="kw">move </span>|req: <span class="kw-2">&amp;</span>ServiceRequest| {
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">let </span>res = req
.get_session()
.get(<span class="kw-2">&amp;</span>session_key)
.unwrap_or_else(|<span class="kw">_</span>| req.cookie(<span class="kw-2">&amp;</span>cookie_name).map(|c| c.to_string()));
<span class="attr">#[cfg(not(feature = <span class="string">&quot;session&quot;</span>))]
<span class="attr">#[cfg(not(feature = <span class="string">"session"</span>))]
</span><span class="kw">let </span>res = req.cookie(<span class="kw-2">&amp;</span>cookie_name).map(|c| c.to_string());
res
@@ -282,38 +282,38 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_create_builder() {
<span class="kw">let </span>redis_url = <span class="string">&quot;redis://127.0.0.1&quot;</span>;
<span class="kw">let </span>redis_url = <span class="string">"redis://127.0.0.1"</span>;
<span class="kw">let </span>period = Duration::from_secs(<span class="number">10</span>);
<span class="kw">let </span>builder = Builder {
redis_url: redis_url.to_owned(),
limit: <span class="number">100</span>,
period,
get_key_fn: <span class="prelude-val">Some</span>(Arc::new(|<span class="kw">_</span>| <span class="prelude-val">None</span>)),
cookie_name: Cow::Owned(<span class="string">&quot;session&quot;</span>.to_string()),
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span>session_key: Cow::Owned(<span class="string">&quot;rate-api&quot;</span>.to_string()),
cookie_name: Cow::Owned(<span class="string">"session"</span>.to_string()),
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span>session_key: Cow::Owned(<span class="string">"rate-api"</span>.to_string()),
};
<span class="macro">assert_eq!</span>(builder.redis_url, redis_url);
<span class="macro">assert_eq!</span>(builder.limit, <span class="number">100</span>);
<span class="macro">assert_eq!</span>(builder.period, period);
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span><span class="macro">assert_eq!</span>(builder.session_key, <span class="string">&quot;rate-api&quot;</span>);
<span class="macro">assert_eq!</span>(builder.cookie_name, <span class="string">&quot;session&quot;</span>);
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="macro">assert_eq!</span>(builder.session_key, <span class="string">"rate-api"</span>);
<span class="macro">assert_eq!</span>(builder.cookie_name, <span class="string">"session"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_create_limiter() {
<span class="kw">let </span>redis_url = <span class="string">&quot;redis://127.0.0.1&quot;</span>;
<span class="kw">let </span>redis_url = <span class="string">"redis://127.0.0.1"</span>;
<span class="kw">let </span>period = Duration::from_secs(<span class="number">20</span>);
<span class="kw">let </span><span class="kw-2">mut </span>builder = Builder {
redis_url: redis_url.to_owned(),
limit: <span class="number">100</span>,
period: Duration::from_secs(<span class="number">10</span>),
get_key_fn: <span class="prelude-val">Some</span>(Arc::new(|<span class="kw">_</span>| <span class="prelude-val">None</span>)),
cookie_name: Cow::Borrowed(<span class="string">&quot;sid&quot;</span>),
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span>session_key: Cow::Borrowed(<span class="string">&quot;key&quot;</span>),
cookie_name: Cow::Borrowed(<span class="string">"sid"</span>),
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span>session_key: Cow::Borrowed(<span class="string">"key"</span>),
};
<span class="kw">let </span>limiter = builder.limit(<span class="number">200</span>).period(period).build().unwrap();
@@ -323,18 +323,18 @@
}
<span class="attr">#[test]
#[should_panic = <span class="string">&quot;Redis URL did not parse&quot;</span>]
#[should_panic = <span class="string">"Redis URL did not parse"</span>]
</span><span class="kw">fn </span>test_create_limiter_error() {
<span class="kw">let </span>redis_url = <span class="string">&quot;127.0.0.1&quot;</span>;
<span class="kw">let </span>redis_url = <span class="string">"127.0.0.1"</span>;
<span class="kw">let </span>period = Duration::from_secs(<span class="number">20</span>);
<span class="kw">let </span><span class="kw-2">mut </span>builder = Builder {
redis_url: redis_url.to_owned(),
limit: <span class="number">100</span>,
period: Duration::from_secs(<span class="number">10</span>),
get_key_fn: <span class="prelude-val">Some</span>(Arc::new(|<span class="kw">_</span>| <span class="prelude-val">None</span>)),
cookie_name: Cow::Borrowed(<span class="string">&quot;sid&quot;</span>),
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span>session_key: Cow::Borrowed(<span class="string">&quot;key&quot;</span>),
cookie_name: Cow::Borrowed(<span class="string">"sid"</span>),
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span>session_key: Cow::Borrowed(<span class="string">"key"</span>),
};
builder.limit(<span class="number">200</span>).period(period).build().unwrap();

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-limitation/src/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-limitation/src/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -48,20 +48,20 @@
</span><span class="attr">#[derive(Debug, Display, Error, From)]
</span><span class="kw">pub enum </span>Error {
<span class="doccomment">/// Redis client failed to connect or run a query.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Redis client failed to connect or run a query&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Redis client failed to connect or run a query"</span>)]
</span>Client(redis::RedisError),
<span class="doccomment">/// Limit is exceeded for a key.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Limit is exceeded for a key&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Limit is exceeded for a key"</span>)]
#[from(ignore)]
</span>LimitExceeded(<span class="attr">#[error(not(source))] </span>Status),
<span class="doccomment">/// Time conversion failed.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Time conversion failed&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Time conversion failed"</span>)]
</span>Time(time::error::ComponentRange),
<span class="doccomment">/// Generic error.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Generic error&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Generic error"</span>)]
#[from(ignore)]
</span>Other(<span class="attr">#[error(not(source))] </span>String),
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-limitation/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-limitation/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -182,8 +182,8 @@
//!
//! ```toml
//! [dependencies]
//! actix-web = &quot;4&quot;
</span><span class="attr">#![doc = <span class="macro">concat!</span>(<span class="string">&quot;actix-limitation = \&quot;&quot;</span>, <span class="macro">env!</span>(<span class="string">&quot;CARGO_PKG_VERSION_MAJOR&quot;</span>), <span class="string">&quot;.&quot;</span>, <span class="macro">env!</span>(<span class="string">&quot;CARGO_PKG_VERSION_MINOR&quot;</span>),<span class="string">&quot;\&quot;&quot;</span>)]
//! actix-web = "4"
</span><span class="attr">#![doc = <span class="macro">concat!</span>(<span class="string">"actix-limitation = \""</span>, <span class="macro">env!</span>(<span class="string">"CARGO_PKG_VERSION_MAJOR"</span>), <span class="string">"."</span>, <span class="macro">env!</span>(<span class="string">"CARGO_PKG_VERSION_MINOR"</span>),<span class="string">"\""</span>)]
</span><span class="doccomment">//! ```
//!
//! ```no_run
@@ -192,19 +192,19 @@
//! use actix_session::SessionExt as _;
//! use actix_limitation::{Limiter, RateLimiter};
//!
//! #[get(&quot;/{id}/{name}&quot;)]
//! #[get("/{id}/{name}")]
//! async fn index(info: web::Path&lt;(u32, String)&gt;) -&gt; impl Responder {
//! format!(&quot;Hello {}! id:{}&quot;, info.1, info.0)
//! format!("Hello {}! id:{}", info.1, info.0)
//! }
//!
//! #[actix_web::main]
//! async fn main() -&gt; std::io::Result&lt;()&gt; {
//! let limiter = web::Data::new(
//! Limiter::builder(&quot;redis://127.0.0.1&quot;)
//! Limiter::builder("redis://127.0.0.1")
//! .key_by(|req: &amp;ServiceRequest| {
//! req.get_session()
//! .get(&amp;&quot;session-id&quot;)
//! .unwrap_or_else(|_| req.cookie(&amp;&quot;rate-api-id&quot;).map(|c| c.to_string()))
//! .get(&amp;"session-id")
//! .unwrap_or_else(|_| req.cookie(&amp;"rate-api-id").map(|c| c.to_string()))
//! })
//! .limit(5000)
//! .period(Duration::from_secs(3600)) // 60 minutes
@@ -218,7 +218,7 @@
//! .app_data(limiter.clone())
//! .service(index)
//! })
//! .bind((&quot;127.0.0.1&quot;, 8080))?
//! .bind(("127.0.0.1", 8080))?
//! .run()
//! .await
//! }
@@ -227,8 +227,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs, missing_debug_implementations)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">use </span>std::{borrow::Cow, fmt, sync::Arc, time::Duration};
@@ -250,11 +250,11 @@
</span><span class="kw">pub const </span>DEFAULT_PERIOD_SECS: u64 = <span class="number">3600</span>;
<span class="doccomment">/// Default cookie name.
</span><span class="kw">pub const </span>DEFAULT_COOKIE_NAME: <span class="kw-2">&amp;</span>str = <span class="string">&quot;sid&quot;</span>;
</span><span class="kw">pub const </span>DEFAULT_COOKIE_NAME: <span class="kw-2">&amp;</span>str = <span class="string">"sid"</span>;
<span class="doccomment">/// Default session key.
</span><span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
</span><span class="kw">pub const </span>DEFAULT_SESSION_KEY: <span class="kw-2">&amp;</span>str = <span class="string">&quot;rate-api-id&quot;</span>;
</span><span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span><span class="kw">pub const </span>DEFAULT_SESSION_KEY: <span class="kw-2">&amp;</span>str = <span class="string">"rate-api-id"</span>;
<span class="doccomment">/// Helper trait to impl Debug on GetKeyFn type
</span><span class="kw">trait </span>GetKeyFnT: Fn(<span class="kw-2">&amp;</span>ServiceRequest) -&gt; <span class="prelude-ty">Option</span>&lt;String&gt; {}
@@ -266,8 +266,8 @@
<span class="doccomment">/// Get key resolver function type
</span><span class="kw">impl </span>fmt::Debug <span class="kw">for </span>GetKeyFn {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="macro">write!</span>(f, <span class="string">&quot;GetKeyFn&quot;</span>)
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="macro">write!</span>(f, <span class="string">"GetKeyFn"</span>)
}
}
@@ -296,7 +296,7 @@
period: Duration::from_secs(DEFAULT_PERIOD_SECS),
get_key_fn: <span class="prelude-val">None</span>,
cookie_name: Cow::Borrowed(DEFAULT_COOKIE_NAME),
<span class="attr">#[cfg(feature = <span class="string">&quot;session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"session"</span>)]
</span>session_key: Cow::Borrowed(DEFAULT_SESSION_KEY),
}
}
@@ -324,16 +324,16 @@
// NodeJS and Redis. For more details, see https://blog.atulr.com/rate-limiter
</span><span class="kw">let </span><span class="kw-2">mut </span>pipe = redis::pipe();
pipe.atomic()
.cmd(<span class="string">&quot;SET&quot;</span>) <span class="comment">// Set key and value
.cmd(<span class="string">"SET"</span>) <span class="comment">// Set key and value
</span>.arg(<span class="kw-2">&amp;</span>key)
.arg(<span class="number">0</span>)
.arg(<span class="string">&quot;EX&quot;</span>) <span class="comment">// Set the specified expire time, in seconds.
.arg(<span class="string">"EX"</span>) <span class="comment">// Set the specified expire time, in seconds.
</span>.arg(expires)
.arg(<span class="string">&quot;NX&quot;</span>) <span class="comment">// Only set the key if it does not already exist.
.arg(<span class="string">"NX"</span>) <span class="comment">// Only set the key if it does not already exist.
</span>.ignore() <span class="comment">// --- ignore returned value of SET command ---
</span>.cmd(<span class="string">&quot;INCR&quot;</span>) <span class="comment">// Increment key
</span>.cmd(<span class="string">"INCR"</span>) <span class="comment">// Increment key
</span>.arg(<span class="kw-2">&amp;</span>key)
.cmd(<span class="string">&quot;TTL&quot;</span>) <span class="comment">// Return time-to-live of key
.cmd(<span class="string">"TTL"</span>) <span class="comment">// Return time-to-live of key
</span>.arg(<span class="kw-2">&amp;</span>key);
<span class="kw">let </span>(count, ttl) = pipe.query_async(<span class="kw-2">&amp;mut </span>connection).<span class="kw">await</span><span class="question-mark">?</span>;
@@ -349,7 +349,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_create_limiter() {
<span class="kw">let </span><span class="kw-2">mut </span>builder = Limiter::builder(<span class="string">&quot;redis://127.0.0.1:6379/1&quot;</span>);
<span class="kw">let </span><span class="kw-2">mut </span>builder = Limiter::builder(<span class="string">"redis://127.0.0.1:6379/1"</span>);
<span class="kw">let </span>limiter = builder.build();
<span class="macro">assert!</span>(limiter.is_ok());

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-limitation/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-limitation/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -132,9 +132,9 @@
<span class="kw">impl</span>&lt;S, B&gt; Transform&lt;S, ServiceRequest&gt; <span class="kw">for </span>RateLimiter
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = Error;
@@ -157,9 +157,9 @@
<span class="kw">impl</span>&lt;S, B&gt; Service&lt;ServiceRequest&gt; <span class="kw">for </span>RateLimiterMiddleware&lt;S&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = Error;
@@ -172,7 +172,7 @@
// method description is important context for the developer.
</span><span class="kw">let </span>limiter = req
.app_data::&lt;web::Data&lt;Limiter&gt;&gt;()
.expect(<span class="string">&quot;web::Data&lt;Limiter&gt; should be set in app data for RateLimiter middleware&quot;</span>)
.expect(<span class="string">"web::Data&lt;Limiter&gt; should be set in app data for RateLimiter middleware"</span>)
.clone();
<span class="kw">let </span>key = (limiter.get_key_fn)(<span class="kw-2">&amp;</span>req);
@@ -196,14 +196,14 @@
<span class="kw">if let </span><span class="prelude-val">Err</span>(err) = status {
<span class="kw">match </span>err {
LimitationError::LimitExceeded(<span class="kw">_</span>) =&gt; {
<span class="macro">log::warn!</span>(<span class="string">&quot;Rate limit exceed error for {}&quot;</span>, key);
<span class="macro">log::warn!</span>(<span class="string">"Rate limit exceed error for {}"</span>, key);
<span class="prelude-val">Ok</span>(req.into_response(
HttpResponse::new(StatusCode::TOO_MANY_REQUESTS).map_into_right_body(),
))
}
LimitationError::Client(e) =&gt; {
<span class="macro">log::error!</span>(<span class="string">&quot;Client request failed, redis error: {}&quot;</span>, e);
<span class="macro">log::error!</span>(<span class="string">"Client request failed, redis error: {}"</span>, e);
<span class="prelude-val">Ok</span>(req.into_response(
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)
@@ -211,7 +211,7 @@
))
}
<span class="kw">_ </span>=&gt; {
<span class="macro">log::error!</span>(<span class="string">&quot;Count failed: {}&quot;</span>, err);
<span class="macro">log::error!</span>(<span class="string">"Count failed: {}"</span>, err);
<span class="prelude-val">Ok</span>(req.into_response(
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR)

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-limitation/src/status.rs`."><title>status.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-limitation/src/status.rs`."><title>status.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_limitation/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_limitation"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -171,7 +171,7 @@
.unwrap_or(<span class="number">0</span>)),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">Err</span>(LimitationError::Other(
<span class="string">&quot;Source duration value is out of range for the target type&quot;</span>.to_string(),
<span class="string">"Source duration value is out of range for the target type"</span>.to_string(),
)),
}
}
@@ -228,7 +228,7 @@
}
<span class="attr">#[test]
#[should_panic = <span class="string">&quot;Source duration value is out of range for the target type&quot;</span>]
#[should_panic = <span class="string">"Source duration value is out of range for the target type"</span>]
</span><span class="kw">fn </span>test_epoch_utc_plus_overflow() {
<span class="kw">let </span>duration = Duration::from_secs(<span class="number">10000000000000000000</span>);
Status::epoch_utc_plus(duration).unwrap();

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-protobuf/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_protobuf" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_protobuf/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_protobuf"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-protobuf/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_protobuf" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_protobuf/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_protobuf"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -341,8 +341,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">use </span>std::{
@@ -372,23 +372,23 @@
<span class="attr">#[derive(Debug, Display)]
</span><span class="kw">pub enum </span>ProtoBufPayloadError {
<span class="doccomment">/// Payload size is bigger than 256k
</span><span class="attr">#[display(fmt = <span class="string">&quot;Payload size is bigger than 256k&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Payload size is bigger than 256k"</span>)]
</span>Overflow,
<span class="doccomment">/// Content type error
</span><span class="attr">#[display(fmt = <span class="string">&quot;Content type error&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Content type error"</span>)]
</span>ContentType,
<span class="doccomment">/// Serialize error
</span><span class="attr">#[display(fmt = <span class="string">&quot;ProtoBuf serialize error: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"ProtoBuf serialize error: {_0}"</span>)]
</span>Serialize(ProtoBufEncodeError),
<span class="doccomment">/// Deserialize error
</span><span class="attr">#[display(fmt = <span class="string">&quot;ProtoBuf deserialize error: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"ProtoBuf deserialize error: {_0}"</span>)]
</span>Deserialize(ProtoBufDecodeError),
<span class="doccomment">/// Payload error
</span><span class="attr">#[display(fmt = <span class="string">&quot;Error that occur during reading payload: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Error that occur during reading payload: {_0}"</span>)]
</span>Payload(PayloadError),
}
@@ -433,8 +433,8 @@
<span class="kw">where
</span>T: fmt::Debug,
{
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="macro">write!</span>(f, <span class="string">&quot;ProtoBuf: {:?}&quot;</span>, <span class="self">self</span>.<span class="number">0</span>)
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="macro">write!</span>(f, <span class="string">"ProtoBuf: {:?}"</span>, <span class="self">self</span>.<span class="number">0</span>)
}
}
@@ -442,7 +442,7 @@
<span class="kw">where
</span>T: fmt::Display,
{
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
fmt::Display::fmt(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, f)
}
}
@@ -467,10 +467,10 @@
<span class="kw">impl</span>&lt;T&gt; FromRequest <span class="kw">for </span>ProtoBuf&lt;T&gt;
<span class="kw">where
</span>T: Message + Default + <span class="lifetime">&#39;static</span>,
</span>T: Message + Default + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Error = Error;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, Error&gt;&gt;;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, Error&gt;&gt;;
<span class="attr">#[inline]
</span><span class="kw">fn </span>from_request(req: <span class="kw-2">&amp;</span>HttpRequest, payload: <span class="kw-2">&amp;mut </span>Payload) -&gt; <span class="self">Self</span>::Future {
@@ -495,7 +495,7 @@
<span class="kw">let </span><span class="kw-2">mut </span>buf = Vec::new();
<span class="kw">match </span><span class="self">self</span>.<span class="number">0</span>.encode(<span class="kw-2">&amp;mut </span>buf) {
<span class="prelude-val">Ok</span>(()) =&gt; HttpResponse::Ok()
.content_type(<span class="string">&quot;application/protobuf&quot;</span>)
.content_type(<span class="string">"application/protobuf"</span>)
.body(buf),
<span class="prelude-val">Err</span>(err) =&gt; HttpResponse::from_error(Error::from(ProtoBufPayloadError::Serialize(err))),
}
@@ -507,14 +507,14 @@
length: <span class="prelude-ty">Option</span>&lt;usize&gt;,
stream: <span class="prelude-ty">Option</span>&lt;Payload&gt;,
err: <span class="prelude-ty">Option</span>&lt;ProtoBufPayloadError&gt;,
fut: <span class="prelude-ty">Option</span>&lt;LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;T, ProtoBufPayloadError&gt;&gt;&gt;,
fut: <span class="prelude-ty">Option</span>&lt;LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;T, ProtoBufPayloadError&gt;&gt;&gt;,
}
<span class="kw">impl</span>&lt;T: Message + Default&gt; ProtoBufMessage&lt;T&gt; {
<span class="doccomment">/// Create `ProtoBufMessage` for request.
</span><span class="kw">pub fn </span>new(req: <span class="kw-2">&amp;</span>HttpRequest, payload: <span class="kw-2">&amp;mut </span>Payload) -&gt; <span class="self">Self </span>{
<span class="kw">if </span>req.content_type() != <span class="string">&quot;application/protobuf&quot;
</span>&amp;&amp; req.content_type() != <span class="string">&quot;application/x-protobuf&quot;
<span class="kw">if </span>req.content_type() != <span class="string">"application/protobuf"
</span>&amp;&amp; req.content_type() != <span class="string">"application/x-protobuf"
</span>{
<span class="kw">return </span>ProtoBufMessage {
limit: <span class="number">262_144</span>,
@@ -550,10 +550,10 @@
</span>}
}
<span class="kw">impl</span>&lt;T: Message + Default + <span class="lifetime">&#39;static</span>&gt; Future <span class="kw">for </span>ProtoBufMessage&lt;T&gt; {
<span class="kw">impl</span>&lt;T: Message + Default + <span class="lifetime">'static</span>&gt; Future <span class="kw">for </span>ProtoBufMessage&lt;T&gt; {
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;T, ProtoBufPayloadError&gt;;
<span class="kw">fn </span>poll(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, task: <span class="kw-2">&amp;mut </span>task::Context&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">fn </span>poll(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, task: <span class="kw-2">&amp;mut </span>task::Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref mut </span>fut) = <span class="self">self</span>.fut {
<span class="kw">return </span>Pin::new(fut).poll(task);
}
@@ -572,7 +572,7 @@
<span class="kw">let </span><span class="kw-2">mut </span>stream = <span class="self">self
</span>.stream
.take()
.expect(<span class="string">&quot;ProtoBufMessage could not be used second time&quot;</span>);
.expect(<span class="string">"ProtoBufMessage could not be used second time"</span>);
<span class="self">self</span>.fut = <span class="prelude-val">Some</span>(
<span class="kw">async move </span>{
@@ -601,7 +601,7 @@
<span class="kw">impl </span>ProtoBufResponseBuilder <span class="kw">for </span>HttpResponseBuilder {
<span class="kw">fn </span>protobuf&lt;T: Message&gt;(<span class="kw-2">&amp;mut </span><span class="self">self</span>, value: T) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse, Error&gt; {
<span class="self">self</span>.insert_header((CONTENT_TYPE, <span class="string">&quot;application/protobuf&quot;</span>));
<span class="self">self</span>.insert_header((CONTENT_TYPE, <span class="string">"application/protobuf"</span>));
<span class="kw">let </span><span class="kw-2">mut </span>body = Vec::new();
value
@@ -634,9 +634,9 @@
<span class="attr">#[derive(Clone, PartialEq, Eq, Message)]
</span><span class="kw">pub struct </span>MyObject {
<span class="attr">#[prost(int32, tag = <span class="string">&quot;1&quot;</span>)]
<span class="attr">#[prost(int32, tag = <span class="string">"1"</span>)]
</span><span class="kw">pub </span>number: i32,
<span class="attr">#[prost(string, tag = <span class="string">&quot;2&quot;</span>)]
<span class="attr">#[prost(string, tag = <span class="string">"2"</span>)]
</span><span class="kw">pub </span>name: String,
}
@@ -644,12 +644,12 @@
</span><span class="kw">async fn </span>test_protobuf() {
<span class="kw">let </span>protobuf = ProtoBuf(MyObject {
number: <span class="number">9</span>,
name: <span class="string">&quot;test&quot;</span>.to_owned(),
name: <span class="string">"test"</span>.to_owned(),
});
<span class="kw">let </span>req = TestRequest::default().to_http_request();
<span class="kw">let </span>resp = protobuf.respond_to(<span class="kw-2">&amp;</span>req);
<span class="kw">let </span>ct = resp.headers().get(header::CONTENT_TYPE).unwrap();
<span class="macro">assert_eq!</span>(ct, <span class="string">&quot;application/protobuf&quot;</span>);
<span class="macro">assert_eq!</span>(ct, <span class="string">"application/protobuf"</span>);
}
<span class="attr">#[actix_web::test]
@@ -659,14 +659,14 @@
<span class="macro">assert_eq!</span>(protobuf.err().unwrap(), ProtoBufPayloadError::ContentType);
<span class="kw">let </span>(req, <span class="kw-2">mut </span>pl) = TestRequest::get()
.insert_header((header::CONTENT_TYPE, <span class="string">&quot;application/text&quot;</span>))
.insert_header((header::CONTENT_TYPE, <span class="string">"application/text"</span>))
.to_http_parts();
<span class="kw">let </span>protobuf = ProtoBufMessage::&lt;MyObject&gt;::new(<span class="kw-2">&amp;</span>req, <span class="kw-2">&amp;mut </span>pl).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(protobuf.err().unwrap(), ProtoBufPayloadError::ContentType);
<span class="kw">let </span>(req, <span class="kw-2">mut </span>pl) = TestRequest::get()
.insert_header((header::CONTENT_TYPE, <span class="string">&quot;application/protobuf&quot;</span>))
.insert_header((header::CONTENT_LENGTH, <span class="string">&quot;10000&quot;</span>))
.insert_header((header::CONTENT_TYPE, <span class="string">"application/protobuf"</span>))
.insert_header((header::CONTENT_LENGTH, <span class="string">"10000"</span>))
.to_http_parts();
<span class="kw">let </span>protobuf = ProtoBufMessage::&lt;MyObject&gt;::new(<span class="kw-2">&amp;</span>req, <span class="kw-2">&amp;mut </span>pl)
.limit(<span class="number">100</span>)

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-redis/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_redis" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_redis/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_redis"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-redis/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_redis" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_redis/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_redis"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -35,8 +35,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">use </span>derive_more::{Display, Error, From};
@@ -48,18 +48,18 @@
<span class="doccomment">/// General purpose `actix-redis` error.
</span><span class="attr">#[derive(Debug, Display, Error, From)]
</span><span class="kw">pub enum </span>Error {
<span class="attr">#[display(fmt = <span class="string">&quot;Redis error: {_0}&quot;</span>)]
<span class="attr">#[display(fmt = <span class="string">"Redis error: {_0}"</span>)]
</span>Redis(redis_async::error::Error),
<span class="doccomment">/// Receiving message during reconnecting.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Redis: Not connected&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Redis: Not connected"</span>)]
</span>NotConnected,
<span class="doccomment">/// Cancel all waiters when connection is dropped.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Redis: Disconnected&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Redis: Disconnected"</span>)]
</span>Disconnected,
}
<span class="attr">#[cfg(feature = <span class="string">&quot;web&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"web"</span>)]
</span><span class="kw">impl </span>actix_web::ResponseError <span class="kw">for </span>Error {}
</code></pre></div></section></main></body></html>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-redis/src/redis.rs`."><title>redis.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_redis" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_redis/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_redis"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-redis/src/redis.rs`."><title>redis.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_redis" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_redis/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_redis"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -209,7 +209,7 @@
.map(|res, act, ctx| <span class="kw">match </span>res {
<span class="prelude-val">Ok</span>(conn) =&gt; {
<span class="kw">let </span>stream = conn.into_parts().<span class="number">0</span>;
<span class="macro">info!</span>(<span class="string">&quot;Connected to redis server: {}&quot;</span>, act.addr);
<span class="macro">info!</span>(<span class="string">"Connected to redis server: {}"</span>, act.addr);
<span class="kw">let </span>(r, w) = split(stream);
@@ -223,7 +223,7 @@
act.backoff.reset();
}
<span class="prelude-val">Err</span>(err) =&gt; {
<span class="macro">error!</span>(<span class="string">&quot;Can not connect to redis server: {}&quot;</span>, err);
<span class="macro">error!</span>(<span class="string">"Can not connect to redis server: {}"</span>, err);
<span class="comment">// re-connect with backoff time.
// we stop current context, supervisor will restart it.
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(timeout) = act.backoff.next_backoff() {
@@ -246,7 +246,7 @@
<span class="kw">impl </span>actix::io::WriteHandler&lt;io::Error&gt; <span class="kw">for </span>RedisActor {
<span class="kw">fn </span>error(<span class="kw-2">&amp;mut </span><span class="self">self</span>, err: io::Error, <span class="kw">_</span>: <span class="kw-2">&amp;mut </span><span class="self">Self</span>::Context) -&gt; Running {
<span class="macro">warn!</span>(<span class="string">&quot;Redis connection dropped: {} error: {}&quot;</span>, <span class="self">self</span>.addr, err);
<span class="macro">warn!</span>(<span class="string">"Redis connection dropped: {} error: {}"</span>, <span class="self">self</span>.addr, err);
Running::Stop
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -425,7 +425,7 @@
}
<span class="doccomment">/// A [session lifecycle](SessionLifecycle) strategy where the session cookie expires when the
/// browser&#39;s current session ends.
/// browser's current session ends.
///
/// When does a browser session end? It depends on the browser. Chrome, for example, will often
/// continue running in the background when the browser is closed—session cookies are not deleted
@@ -507,7 +507,7 @@
///
/// // a session lifecycle with the default time-to-live (expiry) and a custom extension policy
/// PersistentSession::default()
/// // this policy causes the session state&#39;s TTL to be refreshed on every request
/// // this policy causes the session state's TTL to be refreshed on every request
/// .session_ttl_extension_policy(TtlExtensionPolicy::OnEveryRequest);
/// ```
///
@@ -592,7 +592,7 @@
<span class="doccomment">/// The cookie content is signed when using `CookieContentSecurity::Signed`.
///
/// Signing guarantees integrity, but it doesn&#39;t ensure confidentiality: the client cannot
/// Signing guarantees integrity, but it doesn't ensure confidentiality: the client cannot
/// tamper with the cookie content, but they can read it.
</span>Signed,
}
@@ -640,7 +640,7 @@
</span>}
<span class="doccomment">/// Determines what type of session cookie should be used and how its lifecycle should be managed.
/// Check out [`SessionLifecycle`]&#39;s documentation for more details on the available options.
/// Check out [`SessionLifecycle`]'s documentation for more details on the available options.
///
/// Default is [`SessionLifecycle::BrowserSession`].
///
@@ -776,9 +776,9 @@
cookie: CookieConfiguration {
secure: <span class="bool-val">true</span>,
http_only: <span class="bool-val">true</span>,
name: <span class="string">&quot;id&quot;</span>.into(),
name: <span class="string">"id"</span>.into(),
same_site: SameSite::Lax,
path: <span class="string">&quot;/&quot;</span>.into(),
path: <span class="string">"/"</span>.into(),
domain: <span class="prelude-val">None</span>,
max_age: <span class="prelude-val">None</span>,
content_security: CookieContentSecurity::Private,

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -740,7 +740,7 @@
//!
//! Stateless systems are easier to reason about, but they are not quite as powerful as we need them
//! to be - e.g. how do you authenticate a user? The user would be forced to authenticate **for
//! every single request**. That is, for example, how &#39;Basic&#39; Authentication works. While it may
//! every single request**. That is, for example, how 'Basic' Authentication works. While it may
//! work for a machine user (i.e. an API client), it is impractical for a person—you do not want a
//! login prompt on every single page you navigate to!
//!
@@ -765,7 +765,7 @@
//!
//! Further reading on sessions:
//! - [RFC6265](https://datatracker.ietf.org/doc/html/rfc6265);
//! - [OWASP&#39;s session management cheat-sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html).
//! - [OWASP's session management cheat-sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html).
//!
//! # Getting started
//! To start using sessions in your Actix Web application you must register [`SessionMiddleware`]
@@ -780,7 +780,7 @@
//! async fn main() -&gt; std::io::Result&lt;()&gt; {
//! // The secret key would usually be read from a configuration file/environment variables.
//! let secret_key = Key::generate();
//! let redis_connection_string = &quot;127.0.0.1:6379&quot;;
//! let redis_connection_string = "127.0.0.1:6379";
//! HttpServer::new(move ||
//! App::new()
//! // Add session management to your application using Redis for session state storage
@@ -791,30 +791,30 @@
//! )
//! )
//! .default_service(web::to(|| HttpResponse::Ok())))
//! .bind((&quot;127.0.0.1&quot;, 8080))?
//! .bind(("127.0.0.1", 8080))?
//! .run()
//! .await
//! }
//! ```
//!
//! The session state can be accessed and modified by your request handlers using the [`Session`]
//! extractor. Note that this doesn&#39;t work in the stream of a streaming response.
//! extractor. Note that this doesn't work in the stream of a streaming response.
//!
//! ```no_run
//! use actix_web::Error;
//! use actix_session::Session;
//!
//! fn index(session: Session) -&gt; Result&lt;&amp;&#39;static str, Error&gt; {
//! fn index(session: Session) -&gt; Result&lt;&amp;'static str, Error&gt; {
//! // access the session state
//! if let Some(count) = session.get::&lt;i32&gt;(&quot;counter&quot;)? {
//! println!(&quot;SESSION value: {}&quot;, count);
//! if let Some(count) = session.get::&lt;i32&gt;("counter")? {
//! println!("SESSION value: {}", count);
//! // modify the session state
//! session.insert(&quot;counter&quot;, count + 1)?;
//! session.insert("counter", count + 1)?;
//! } else {
//! session.insert(&quot;counter&quot;, 1)?;
//! session.insert("counter", 1)?;
//! }
//!
//! Ok(&quot;Welcome!&quot;)
//! Ok("Welcome!")
//! }
//! ```
//!
@@ -823,13 +823,13 @@
//! By default, `actix-session` does not provide any storage backend to retrieve and save the state
//! attached to your sessions. You can enable:
//!
//! - a purely cookie-based &quot;backend&quot;, [`CookieSessionStore`], using the `cookie-session` feature
//! - a purely cookie-based "backend", [`CookieSessionStore`], using the `cookie-session` feature
//! flag.
//!
//! ```toml
//! [dependencies]
//! # ...
//! actix-session = { version = &quot;...&quot;, features = [&quot;cookie-session&quot;] }
//! actix-session = { version = "...", features = ["cookie-session"] }
//! ```
//!
//! - a Redis-based backend via [`actix-redis`](https://docs.rs/actix-redis),
@@ -838,7 +838,7 @@
//! ```toml
//! [dependencies]
//! # ...
//! actix-session = { version = &quot;...&quot;, features = [&quot;redis-actor-session&quot;] }
//! actix-session = { version = "...", features = ["redis-actor-session"] }
//! ```
//!
//! - a Redis-based backend via [`redis-rs`](https://docs.rs/redis-rs), [`RedisSessionStore`], using
@@ -847,7 +847,7 @@
//! ```toml
//! [dependencies]
//! # ...
//! actix-session = { version = &quot;...&quot;, features = [&quot;redis-rs-session&quot;] }
//! actix-session = { version = "...", features = ["redis-rs-session"] }
//! ```
//!
//! Add the `redis-rs-tls-session` feature flag if you want to connect to Redis using a secured
@@ -856,7 +856,7 @@
//! ```toml
//! [dependencies]
//! # ...
//! actix-session = { version = &quot;...&quot;, features = [&quot;redis-rs-session&quot;, &quot;redis-rs-tls-session&quot;] }
//! actix-session = { version = "...", features = ["redis-rs-session", "redis-rs-tls-session"] }
//! ```
//!
//! You can implement your own session storage backend using the [`SessionStore`] trait.
@@ -869,8 +869,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">pub mod </span>config;
@@ -900,19 +900,19 @@
/// regardless of the underlying session store.
///
/// `is_invalidation_supported` must be set to `true` if the backend supports
/// &quot;remembering&quot; that a session has been invalidated (e.g. by logging out).
/// "remembering" that a session has been invalidated (e.g. by logging out).
/// It should be to `false` if the backend allows multiple cookies to be active
/// at the same time (e.g. cookie store backend).
</span><span class="kw">pub async fn </span>acceptance_test_suite&lt;F, Store&gt;(store_builder: F, is_invalidation_supported: bool)
<span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">for </span>policy <span class="kw">in </span><span class="kw-2">&amp;</span>[
CookieContentSecurity::Signed,
CookieContentSecurity::Private,
] {
<span class="macro">println!</span>(<span class="string">&quot;Using {policy:?} as cookie content security policy.&quot;</span>);
<span class="macro">println!</span>(<span class="string">"Using {policy:?} as cookie content security policy."</span>);
acceptance_tests::basic_workflow(store_builder.clone(), <span class="kw-2">*</span>policy).<span class="kw">await</span>;
acceptance_tests::expiration_is_refreshed_on_changes(store_builder.clone(), <span class="kw-2">*</span>policy)
.<span class="kw">await</span>;
@@ -953,16 +953,16 @@
store_builder: F,
policy: CookieContentSecurity,
) <span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">let </span>app = test::init_service(
App::new()
.wrap(
SessionMiddleware::builder(store_builder(), key())
.cookie_path(<span class="string">&quot;/test/&quot;</span>.into())
.cookie_name(<span class="string">&quot;actix-test&quot;</span>.into())
.cookie_domain(<span class="prelude-val">Some</span>(<span class="string">&quot;localhost&quot;</span>.into()))
.cookie_path(<span class="string">"/test/"</span>.into())
.cookie_name(<span class="string">"actix-test"</span>.into())
.cookie_domain(<span class="prelude-val">Some</span>(<span class="string">"localhost"</span>.into()))
.cookie_content_security(policy)
.session_lifecycle(
PersistentSession::default()
@@ -970,27 +970,27 @@
)
.build(),
)
.service(web::resource(<span class="string">&quot;/&quot;</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;
.service(web::resource(<span class="string">"/"</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">"counter"</span>, <span class="number">100</span>);
<span class="string">"test"
</span>}))
.service(web::resource(<span class="string">&quot;/test/&quot;</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let </span>val: usize = ses.get(<span class="string">&quot;counter&quot;</span>).unwrap().unwrap();
<span class="macro">format!</span>(<span class="string">&quot;counter: {val}&quot;</span>)
.service(web::resource(<span class="string">"/test/"</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let </span>val: usize = ses.get(<span class="string">"counter"</span>).unwrap().unwrap();
<span class="macro">format!</span>(<span class="string">"counter: {val}"</span>)
})),
)
.<span class="kw">await</span>;
<span class="kw">let </span>request = test::TestRequest::get().to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie = response.get_cookie(<span class="string">&quot;actix-test&quot;</span>).unwrap().clone();
<span class="macro">assert_eq!</span>(cookie.path().unwrap(), <span class="string">&quot;/test/&quot;</span>);
<span class="kw">let </span>cookie = response.get_cookie(<span class="string">"actix-test"</span>).unwrap().clone();
<span class="macro">assert_eq!</span>(cookie.path().unwrap(), <span class="string">"/test/"</span>);
<span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">&quot;/test/&quot;</span>)
<span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">"/test/"</span>)
.cookie(cookie)
.to_request();
<span class="kw">let </span>body = test::call_and_read_body(<span class="kw-2">&amp;</span>app, request).<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(body, Bytes::from_static(<span class="string">b&quot;counter: 100&quot;</span>));
<span class="macro">assert_eq!</span>(body, Bytes::from_static(<span class="string">b"counter: 100"</span>));
}
<span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">async fn </span>expiration_is_always_refreshed_if_configured_to_refresh_on_every_request&lt;
@@ -1000,8 +1000,8 @@
store_builder: F,
policy: CookieContentSecurity,
) <span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">let </span>session_ttl = time::Duration::seconds(<span class="number">60</span>);
<span class="kw">let </span>app = test::init_service(
@@ -1018,27 +1018,27 @@
)
.build(),
)
.service(web::resource(<span class="string">&quot;/&quot;</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;
.service(web::resource(<span class="string">"/"</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">"counter"</span>, <span class="number">100</span>);
<span class="string">"test"
</span>}))
.service(web::resource(<span class="string">&quot;/test/&quot;</span>).to(|| <span class="kw">async move </span>{ <span class="string">&quot;no-changes-in-session&quot; </span>})),
.service(web::resource(<span class="string">"/test/"</span>).to(|| <span class="kw">async move </span>{ <span class="string">"no-changes-in-session" </span>})),
)
.<span class="kw">await</span>;
<span class="comment">// Create session
</span><span class="kw">let </span>request = test::TestRequest::get().to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_1 = response.get_cookie(<span class="string">&quot;id&quot;</span>).expect(<span class="string">&quot;Cookie is set&quot;</span>);
<span class="kw">let </span>cookie_1 = response.get_cookie(<span class="string">"id"</span>).expect(<span class="string">"Cookie is set"</span>);
<span class="macro">assert_eq!</span>(cookie_1.max_age(), <span class="prelude-val">Some</span>(session_ttl));
<span class="comment">// Fire a request that doesn&#39;t touch the session state, check
<span class="comment">// Fire a request that doesn't touch the session state, check
// that the session cookie is present and its expiry is set to the maximum we configured.
</span><span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">&quot;/test/&quot;</span>)
</span><span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">"/test/"</span>)
.cookie(cookie_1)
.to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_2 = response.get_cookie(<span class="string">&quot;id&quot;</span>).expect(<span class="string">&quot;Cookie is set&quot;</span>);
<span class="kw">let </span>cookie_2 = response.get_cookie(<span class="string">"id"</span>).expect(<span class="string">"Cookie is set"</span>);
<span class="macro">assert_eq!</span>(cookie_2.max_age(), <span class="prelude-val">Some</span>(session_ttl));
}
@@ -1046,8 +1046,8 @@
store_builder: F,
policy: CookieContentSecurity,
) <span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">let </span>session_ttl = time::Duration::seconds(<span class="number">60</span>);
<span class="kw">let </span>app = test::init_service(
@@ -1060,20 +1060,20 @@
)
.build(),
)
.service(web::resource(<span class="string">&quot;/&quot;</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">&quot;counter&quot;</span>, <span class="number">100</span>);
<span class="string">&quot;test&quot;
.service(web::resource(<span class="string">"/"</span>).to(|ses: Session| <span class="kw">async move </span>{
<span class="kw">let _ </span>= ses.insert(<span class="string">"counter"</span>, <span class="number">100</span>);
<span class="string">"test"
</span>}))
.service(web::resource(<span class="string">&quot;/test/&quot;</span>).to(|| <span class="kw">async move </span>{ <span class="string">&quot;no-changes-in-session&quot; </span>})),
.service(web::resource(<span class="string">"/test/"</span>).to(|| <span class="kw">async move </span>{ <span class="string">"no-changes-in-session" </span>})),
)
.<span class="kw">await</span>;
<span class="kw">let </span>request = test::TestRequest::get().to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_1 = response.get_cookie(<span class="string">&quot;id&quot;</span>).expect(<span class="string">&quot;Cookie is set&quot;</span>);
<span class="kw">let </span>cookie_1 = response.get_cookie(<span class="string">"id"</span>).expect(<span class="string">"Cookie is set"</span>);
<span class="macro">assert_eq!</span>(cookie_1.max_age(), <span class="prelude-val">Some</span>(session_ttl));
<span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">&quot;/test/&quot;</span>)
<span class="kw">let </span>request = test::TestRequest::with_uri(<span class="string">"/test/"</span>)
.cookie(cookie_1.clone())
.to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
@@ -1081,20 +1081,20 @@
<span class="kw">let </span>request = test::TestRequest::get().cookie(cookie_1).to_request();
<span class="kw">let </span>response = app.call(request).<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_2 = response.get_cookie(<span class="string">&quot;id&quot;</span>).expect(<span class="string">&quot;Cookie is set&quot;</span>);
<span class="kw">let </span>cookie_2 = response.get_cookie(<span class="string">"id"</span>).expect(<span class="string">"Cookie is set"</span>);
<span class="macro">assert_eq!</span>(cookie_2.max_age(), <span class="prelude-val">Some</span>(session_ttl));
}
<span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">async fn </span>guard&lt;F, Store&gt;(store_builder: F, policy: CookieContentSecurity)
<span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">let </span>srv = actix_test::start(<span class="kw">move </span>|| {
App::new()
.wrap(
SessionMiddleware::builder(store_builder(), key())
.cookie_name(<span class="string">&quot;test-session&quot;</span>.into())
.cookie_name(<span class="string">"test-session"</span>.into())
.cookie_content_security(policy)
.session_lifecycle(
PersistentSession::default().session_ttl(time::Duration::days(<span class="number">7</span>)),
@@ -1102,49 +1102,49 @@
.build(),
)
.wrap(middleware::Logger::default())
.service(resource(<span class="string">&quot;/&quot;</span>).route(get().to(index)))
.service(resource(<span class="string">&quot;/do_something&quot;</span>).route(post().to(do_something)))
.service(resource(<span class="string">&quot;/login&quot;</span>).route(post().to(login)))
.service(resource(<span class="string">&quot;/logout&quot;</span>).route(post().to(logout)))
.service(resource(<span class="string">"/"</span>).route(get().to(index)))
.service(resource(<span class="string">"/do_something"</span>).route(post().to(do_something)))
.service(resource(<span class="string">"/login"</span>).route(post().to(login)))
.service(resource(<span class="string">"/logout"</span>).route(post().to(logout)))
.service(
web::scope(<span class="string">&quot;/protected&quot;</span>)
web::scope(<span class="string">"/protected"</span>)
.guard(guard::fn_guard(|g| {
g.get_session().get::&lt;String&gt;(<span class="string">&quot;user_id&quot;</span>).unwrap().is_some()
g.get_session().get::&lt;String&gt;(<span class="string">"user_id"</span>).unwrap().is_some()
}))
.service(resource(<span class="string">&quot;/count&quot;</span>).route(get().to(count))),
.service(resource(<span class="string">"/count"</span>).route(get().to(count))),
)
});
<span class="comment">// Step 1: GET without session info
// - response should be a unsuccessful status
</span><span class="kw">let </span>req_1 = srv.get(<span class="string">&quot;/protected/count&quot;</span>).send();
</span><span class="kw">let </span>req_1 = srv.get(<span class="string">"/protected/count"</span>).send();
<span class="kw">let </span>resp_1 = req_1.<span class="kw">await</span>.unwrap();
<span class="macro">assert!</span>(!resp_1.status().is_success());
<span class="comment">// Step 2: POST to login
// - set-cookie actix-session will be in response (session cookie #1)
// - updates session state: {&quot;counter&quot;: 0, &quot;user_id&quot;: &quot;ferris&quot;}
</span><span class="kw">let </span>req_2 = srv.post(<span class="string">&quot;/login&quot;</span>).send_json(<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>}));
// - updates session state: {"counter": 0, "user_id": "ferris"}
</span><span class="kw">let </span>req_2 = srv.post(<span class="string">"/login"</span>).send_json(<span class="kw-2">&amp;</span><span class="macro">json!</span>({<span class="string">"user_id"</span>: <span class="string">"ferris"</span>}));
<span class="kw">let </span>resp_2 = req_2.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_1 = resp_2
.cookies()
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="comment">// Step 3: POST to do_something
// - adds new session state: {&quot;counter&quot;: 1, &quot;user_id&quot;: &quot;ferris&quot; }
// - adds new session state: {"counter": 1, "user_id": "ferris" }
// - set-cookie actix-session should be in response (session cookie #2)
// - response should be: {&quot;counter&quot;: 1, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_3 = srv.post(<span class="string">&quot;/do_something&quot;</span>).cookie(cookie_1.clone()).send();
// - response should be: {"counter": 1, "user_id": None}
</span><span class="kw">let </span>req_3 = srv.post(<span class="string">"/do_something"</span>).cookie(cookie_1.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_3 = req_3.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_3 = resp_3.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
result_3,
IndexResponse {
user_id: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.into()),
user_id: <span class="prelude-val">Some</span>(<span class="string">"ferris"</span>.into()),
counter: <span class="number">1
</span>}
);
@@ -1153,18 +1153,18 @@
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="comment">// Step 4: GET using a existing user id
// - response should be: {&quot;counter&quot;: 3, &quot;user_id&quot;: &quot;ferris&quot;}
</span><span class="kw">let </span>req_4 = srv.get(<span class="string">&quot;/protected/count&quot;</span>).cookie(cookie_2.clone()).send();
// - response should be: {"counter": 3, "user_id": "ferris"}
</span><span class="kw">let </span>req_4 = srv.get(<span class="string">"/protected/count"</span>).cookie(cookie_2.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_4 = req_4.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_4 = resp_4.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
result_4,
IndexResponse {
user_id: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.into()),
user_id: <span class="prelude-val">Some</span>(<span class="string">"ferris"</span>.into()),
counter: <span class="number">1
</span>}
);
@@ -1175,15 +1175,15 @@
is_invalidation_supported: bool,
policy: CookieContentSecurity,
) <span class="kw">where
</span>Store: SessionStore + <span class="lifetime">&#39;static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">&#39;static</span>,
</span>Store: SessionStore + <span class="lifetime">'static</span>,
F: Fn() -&gt; Store + Clone + Send + <span class="lifetime">'static</span>,
{
<span class="kw">let </span>session_ttl = time::Duration::days(<span class="number">7</span>);
<span class="kw">let </span>srv = actix_test::start(<span class="kw">move </span>|| {
App::new()
.wrap(
SessionMiddleware::builder(store_builder(), key())
.cookie_name(<span class="string">&quot;test-session&quot;</span>.into())
.cookie_name(<span class="string">"test-session"</span>.into())
.cookie_content_security(policy)
.session_lifecycle(
PersistentSession::default().session_ttl(session_ttl),
@@ -1191,16 +1191,16 @@
.build(),
)
.wrap(middleware::Logger::default())
.service(resource(<span class="string">&quot;/&quot;</span>).route(get().to(index)))
.service(resource(<span class="string">&quot;/do_something&quot;</span>).route(post().to(do_something)))
.service(resource(<span class="string">&quot;/login&quot;</span>).route(post().to(login)))
.service(resource(<span class="string">&quot;/logout&quot;</span>).route(post().to(logout)))
.service(resource(<span class="string">"/"</span>).route(get().to(index)))
.service(resource(<span class="string">"/do_something"</span>).route(post().to(do_something)))
.service(resource(<span class="string">"/login"</span>).route(post().to(login)))
.service(resource(<span class="string">"/logout"</span>).route(post().to(logout)))
});
<span class="comment">// Step 1: GET index
// - set-cookie actix-session should NOT be in response (session data is empty)
// - response should be: {&quot;counter&quot;: 0, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_1a = srv.get(<span class="string">&quot;/&quot;</span>).send();
// - response should be: {"counter": 0, "user_id": None}
</span><span class="kw">let </span>req_1a = srv.get(<span class="string">"/"</span>).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_1 = req_1a.<span class="kw">await</span>.unwrap();
<span class="macro">assert!</span>(resp_1.cookies().unwrap().is_empty());
<span class="kw">let </span>result_1 = resp_1.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
@@ -1213,10 +1213,10 @@
);
<span class="comment">// Step 2: POST to do_something
// - adds new session state in redis: {&quot;counter&quot;: 1}
// - adds new session state in redis: {"counter": 1}
// - set-cookie actix-session should be in response (session cookie #1)
// - response should be: {&quot;counter&quot;: 1, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_2 = srv.post(<span class="string">&quot;/do_something&quot;</span>).send();
// - response should be: {"counter": 1, "user_id": None}
</span><span class="kw">let </span>req_2 = srv.post(<span class="string">"/do_something"</span>).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_2 = req_2.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_2 = resp_2.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
@@ -1231,14 +1231,14 @@
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="macro">assert_eq!</span>(cookie_1.max_age(), <span class="prelude-val">Some</span>(session_ttl));
<span class="comment">// Step 3: GET index, including session cookie #1 in request
// - set-cookie will *not* be in response
// - response should be: {&quot;counter&quot;: 1, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_3 = srv.get(<span class="string">&quot;/&quot;</span>).cookie(cookie_1.clone()).send();
// - response should be: {"counter": 1, "user_id": None}
</span><span class="kw">let </span>req_3 = srv.get(<span class="string">"/"</span>).cookie(cookie_1.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_3 = req_3.<span class="kw">await</span>.unwrap();
<span class="macro">assert!</span>(resp_3.cookies().unwrap().is_empty());
<span class="kw">let </span>result_3 = resp_3.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
@@ -1252,9 +1252,9 @@
<span class="comment">// Step 4: POST again to do_something, including session cookie #1 in request
// - set-cookie will be in response (session cookie #2)
// - updates session state: {&quot;counter&quot;: 2}
// - response should be: {&quot;counter&quot;: 2, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_4 = srv.post(<span class="string">&quot;/do_something&quot;</span>).cookie(cookie_1.clone()).send();
// - updates session state: {"counter": 2}
// - response should be: {"counter": 2, "user_id": None}
</span><span class="kw">let </span>req_4 = srv.post(<span class="string">"/do_something"</span>).cookie(cookie_1.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_4 = req_4.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_4 = resp_4.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
@@ -1269,24 +1269,24 @@
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="macro">assert_eq!</span>(cookie_2.max_age(), cookie_1.max_age());
<span class="comment">// Step 5: POST to login, including session cookie #2 in request
// - set-cookie actix-session will be in response (session cookie #3)
// - updates session state: {&quot;counter&quot;: 2, &quot;user_id&quot;: &quot;ferris&quot;}
// - updates session state: {"counter": 2, "user_id": "ferris"}
</span><span class="kw">let </span>req_5 = srv
.post(<span class="string">&quot;/login&quot;</span>)
.post(<span class="string">"/login"</span>)
.cookie(cookie_2.clone())
.send_json(<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>}));
.send_json(<span class="kw-2">&amp;</span><span class="macro">json!</span>({<span class="string">"user_id"</span>: <span class="string">"ferris"</span>}));
<span class="kw">let </span><span class="kw-2">mut </span>resp_5 = req_5.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_3 = resp_5
.cookies()
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="macro">assert_ne!</span>(cookie_2.value(), cookie_3.value());
@@ -1294,34 +1294,34 @@
<span class="macro">assert_eq!</span>(
result_5,
IndexResponse {
user_id: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.into()),
user_id: <span class="prelude-val">Some</span>(<span class="string">"ferris"</span>.into()),
counter: <span class="number">2
</span>}
);
<span class="comment">// Step 6: GET index, including session cookie #3 in request
// - response should be: {&quot;counter&quot;: 2, &quot;user_id&quot;: &quot;ferris&quot;}
</span><span class="kw">let </span>req_6 = srv.get(<span class="string">&quot;/&quot;</span>).cookie(cookie_3.clone()).send();
// - response should be: {"counter": 2, "user_id": "ferris"}
</span><span class="kw">let </span>req_6 = srv.get(<span class="string">"/"</span>).cookie(cookie_3.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_6 = req_6.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_6 = resp_6.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
result_6,
IndexResponse {
user_id: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.into()),
user_id: <span class="prelude-val">Some</span>(<span class="string">"ferris"</span>.into()),
counter: <span class="number">2
</span>}
);
<span class="comment">// Step 7: POST again to do_something, including session cookie #3 in request
// - updates session state: {&quot;counter&quot;: 3, &quot;user_id&quot;: &quot;ferris&quot;}
// - response should be: {&quot;counter&quot;: 3, &quot;user_id&quot;: &quot;ferris&quot;}
</span><span class="kw">let </span>req_7 = srv.post(<span class="string">&quot;/do_something&quot;</span>).cookie(cookie_3.clone()).send();
// - updates session state: {"counter": 3, "user_id": "ferris"}
// - response should be: {"counter": 3, "user_id": "ferris"}
</span><span class="kw">let </span>req_7 = srv.post(<span class="string">"/do_something"</span>).cookie(cookie_3.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_7 = req_7.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>result_7 = resp_7.json::&lt;IndexResponse&gt;().<span class="kw">await</span>.unwrap();
<span class="macro">assert_eq!</span>(
result_7,
IndexResponse {
user_id: <span class="prelude-val">Some</span>(<span class="string">&quot;ferris&quot;</span>.into()),
user_id: <span class="prelude-val">Some</span>(<span class="string">"ferris"</span>.into()),
counter: <span class="number">3
</span>}
);
@@ -1329,7 +1329,7 @@
<span class="comment">// Step 8: GET index, including session cookie #2 in request
// If invalidation is supported, no state will be found associated to this session.
// If invalidation is not supported, the old state will still be retrieved.
</span><span class="kw">let </span>req_8 = srv.get(<span class="string">&quot;/&quot;</span>).cookie(cookie_2.clone()).send();
</span><span class="kw">let </span>req_8 = srv.get(<span class="string">"/"</span>).cookie(cookie_2.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_8 = req_8.<span class="kw">await</span>.unwrap();
<span class="kw">if </span>is_invalidation_supported {
<span class="macro">assert!</span>(resp_8.cookies().unwrap().is_empty());
@@ -1355,22 +1355,22 @@
<span class="comment">// Step 9: POST to logout, including session cookie #3
// - set-cookie actix-session will be in response with session cookie #3
// invalidation logic
</span><span class="kw">let </span>req_9 = srv.post(<span class="string">&quot;/logout&quot;</span>).cookie(cookie_3.clone()).send();
</span><span class="kw">let </span>req_9 = srv.post(<span class="string">"/logout"</span>).cookie(cookie_3.clone()).send();
<span class="kw">let </span>resp_9 = req_9.<span class="kw">await</span>.unwrap();
<span class="kw">let </span>cookie_3 = resp_9
.cookies()
.unwrap()
.clone()
.into_iter()
.find(|c| c.name() == <span class="string">&quot;test-session&quot;</span>)
.find(|c| c.name() == <span class="string">"test-session"</span>)
.unwrap();
<span class="macro">assert_eq!</span>(<span class="number">0</span>, cookie_3.max_age().map(|t| t.whole_seconds()).unwrap());
<span class="macro">assert_eq!</span>(<span class="string">&quot;/&quot;</span>, cookie_3.path().unwrap());
<span class="macro">assert_eq!</span>(<span class="string">"/"</span>, cookie_3.path().unwrap());
<span class="comment">// Step 10: GET index, including session cookie #3 in request
// - set-cookie actix-session should NOT be in response if invalidation is supported
// - response should be: {&quot;counter&quot;: 0, &quot;user_id&quot;: None}
</span><span class="kw">let </span>req_10 = srv.get(<span class="string">&quot;/&quot;</span>).cookie(cookie_3.clone()).send();
// - response should be: {"counter": 0, "user_id": None}
</span><span class="kw">let </span>req_10 = srv.get(<span class="string">"/"</span>).cookie(cookie_3.clone()).send();
<span class="kw">let </span><span class="kw-2">mut </span>resp_10 = req_10.<span class="kw">await</span>.unwrap();
<span class="kw">if </span>is_invalidation_supported {
<span class="macro">assert!</span>(resp_10.cookies().unwrap().is_empty());
@@ -1392,9 +1392,9 @@
}
<span class="kw">async fn </span>index(session: Session) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse&gt; {
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">&quot;user_id&quot;</span>).unwrap();
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">"user_id"</span>).unwrap();
<span class="kw">let </span>counter: i32 = session
.get::&lt;i32&gt;(<span class="string">&quot;counter&quot;</span>)
.get::&lt;i32&gt;(<span class="string">"counter"</span>)
.unwrap_or(<span class="prelude-val">Some</span>(<span class="number">0</span>))
.unwrap_or(<span class="number">0</span>);
@@ -1402,19 +1402,19 @@
}
<span class="kw">async fn </span>do_something(session: Session) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse&gt; {
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">&quot;user_id&quot;</span>).unwrap();
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">"user_id"</span>).unwrap();
<span class="kw">let </span>counter: i32 = session
.get::&lt;i32&gt;(<span class="string">&quot;counter&quot;</span>)
.get::&lt;i32&gt;(<span class="string">"counter"</span>)
.unwrap_or(<span class="prelude-val">Some</span>(<span class="number">0</span>))
.map_or(<span class="number">1</span>, |inner| inner + <span class="number">1</span>);
session.insert(<span class="string">&quot;counter&quot;</span>, counter)<span class="question-mark">?</span>;
session.insert(<span class="string">"counter"</span>, counter)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(HttpResponse::Ok().json(<span class="kw-2">&amp;</span>IndexResponse { user_id, counter }))
}
<span class="kw">async fn </span>count(session: Session) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse&gt; {
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">&quot;user_id&quot;</span>).unwrap();
<span class="kw">let </span>counter: i32 = session.get::&lt;i32&gt;(<span class="string">&quot;counter&quot;</span>).unwrap().unwrap();
<span class="kw">let </span>user_id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get::&lt;String&gt;(<span class="string">"user_id"</span>).unwrap();
<span class="kw">let </span>counter: i32 = session.get::&lt;i32&gt;(<span class="string">"counter"</span>).unwrap().unwrap();
<span class="prelude-val">Ok</span>(HttpResponse::Ok().json(<span class="kw-2">&amp;</span>IndexResponse { user_id, counter }))
}
@@ -1426,11 +1426,11 @@
<span class="kw">async fn </span>login(user_id: web::Json&lt;Identity&gt;, session: Session) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse&gt; {
<span class="kw">let </span>id = user_id.into_inner().user_id;
session.insert(<span class="string">&quot;user_id&quot;</span>, <span class="kw-2">&amp;</span>id)<span class="question-mark">?</span>;
session.insert(<span class="string">"user_id"</span>, <span class="kw-2">&amp;</span>id)<span class="question-mark">?</span>;
session.renew();
<span class="kw">let </span>counter: i32 = session
.get::&lt;i32&gt;(<span class="string">&quot;counter&quot;</span>)
.get::&lt;i32&gt;(<span class="string">"counter"</span>)
.unwrap_or(<span class="prelude-val">Some</span>(<span class="number">0</span>))
.unwrap_or(<span class="number">0</span>);
@@ -1441,24 +1441,24 @@
}
<span class="kw">async fn </span>logout(session: Session) -&gt; <span class="prelude-ty">Result</span>&lt;HttpResponse&gt; {
<span class="kw">let </span>id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get(<span class="string">&quot;user_id&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>id: <span class="prelude-ty">Option</span>&lt;String&gt; = session.get(<span class="string">"user_id"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>body = <span class="kw">if let </span><span class="prelude-val">Some</span>(id) = id {
session.purge();
<span class="macro">format!</span>(<span class="string">&quot;Logged out: {id}&quot;</span>)
<span class="macro">format!</span>(<span class="string">"Logged out: {id}"</span>)
} <span class="kw">else </span>{
<span class="string">&quot;Could not log out anonymous user&quot;</span>.to_owned()
<span class="string">"Could not log out anonymous user"</span>.to_owned()
};
<span class="prelude-val">Ok</span>(HttpResponse::Ok().body(body))
}
<span class="kw">trait </span>ServiceResponseExt {
<span class="kw">fn </span>get_cookie(<span class="kw-2">&amp;</span><span class="self">self</span>, cookie_name: <span class="kw-2">&amp;</span>str) -&gt; <span class="prelude-ty">Option</span>&lt;actix_web::cookie::Cookie&lt;<span class="lifetime">&#39;_</span>&gt;&gt;;
<span class="kw">fn </span>get_cookie(<span class="kw-2">&amp;</span><span class="self">self</span>, cookie_name: <span class="kw-2">&amp;</span>str) -&gt; <span class="prelude-ty">Option</span>&lt;actix_web::cookie::Cookie&lt;<span class="lifetime">'_</span>&gt;&gt;;
}
<span class="kw">impl </span>ServiceResponseExt <span class="kw">for </span>ServiceResponse {
<span class="kw">fn </span>get_cookie(<span class="kw-2">&amp;</span><span class="self">self</span>, cookie_name: <span class="kw-2">&amp;</span>str) -&gt; <span class="prelude-ty">Option</span>&lt;actix_web::cookie::Cookie&lt;<span class="lifetime">&#39;_</span>&gt;&gt; {
<span class="kw">fn </span>get_cookie(<span class="kw-2">&amp;</span><span class="self">self</span>, cookie_name: <span class="kw-2">&amp;</span>str) -&gt; <span class="prelude-ty">Option</span>&lt;actix_web::cookie::Cookie&lt;<span class="lifetime">'_</span>&gt;&gt; {
<span class="self">self</span>.response().cookies().find(|c| c.name() == cookie_name)
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -524,7 +524,7 @@
/// #[actix_web::main]
/// async fn main() -&gt; std::io::Result&lt;()&gt; {
/// let secret_key = get_secret_key();
/// let redis_connection_string = &quot;127.0.0.1:6379&quot;;
/// let redis_connection_string = "127.0.0.1:6379";
/// HttpServer::new(move ||
/// App::new()
/// // Add session management to your application using Redis for session state storage
@@ -535,7 +535,7 @@
/// )
/// )
/// .default_service(web::to(|| HttpResponse::Ok())))
/// .bind((&quot;127.0.0.1&quot;, 8080))?
/// .bind(("127.0.0.1", 8080))?
/// .run()
/// .await
/// }
@@ -557,7 +557,7 @@
/// #[actix_web::main]
/// async fn main() -&gt; std::io::Result&lt;()&gt; {
/// let secret_key = get_secret_key();
/// let redis_connection_string = &quot;127.0.0.1:6379&quot;;
/// let redis_connection_string = "127.0.0.1:6379";
/// HttpServer::new(move ||
/// App::new()
/// // Customise session length!
@@ -573,7 +573,7 @@
/// .build(),
/// )
/// .default_service(web::to(|| HttpResponse::Ok())))
/// .bind((&quot;127.0.0.1&quot;, 8080))?
/// .bind(("127.0.0.1", 8080))?
/// .run()
/// .await
/// }
@@ -616,10 +616,10 @@
<span class="kw">impl</span>&lt;S, B, Store&gt; Transform&lt;S, ServiceRequest&gt; <span class="kw">for </span>SessionMiddleware&lt;Store&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = actix_web::Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
Store: SessionStore + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = actix_web::Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
Store: SessionStore + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;B&gt;;
<span class="kw">type </span>Error = actix_web::Error;
@@ -638,13 +638,13 @@
<span class="doccomment">/// Short-hand to create an `actix_web::Error` instance that will result in an `Internal Server
/// Error` response while preserving the error root cause (e.g. in logs).
</span><span class="kw">fn </span>e500&lt;E: fmt::Debug + fmt::Display + <span class="lifetime">&#39;static</span>&gt;(err: E) -&gt; actix_web::Error {
</span><span class="kw">fn </span>e500&lt;E: fmt::Debug + fmt::Display + <span class="lifetime">'static</span>&gt;(err: E) -&gt; actix_web::Error {
<span class="comment">// We do not use `actix_web::error::ErrorInternalServerError` because we do not want to
// leak internal implementation details to the caller.
//
// `actix_web::error::ErrorInternalServerError` includes the error Display representation
// as body of the error responses, leading to messages like &quot;There was an issue persisting
// the session state&quot; reaching API clients. We don&#39;t want that, we want opaque 500s.
// as body of the error responses, leading to messages like "There was an issue persisting
// the session state" reaching API clients. We don't want that, we want opaque 500s.
</span>actix_web::error::InternalError::from_response(
err,
HttpResponse::InternalServerError().finish(),
@@ -654,7 +654,7 @@
<span class="attr">#[doc(hidden)]
#[non_exhaustive]
</span><span class="kw">pub struct </span>InnerSessionMiddleware&lt;S, Store: SessionStore + <span class="lifetime">&#39;static</span>&gt; {
</span><span class="kw">pub struct </span>InnerSessionMiddleware&lt;S, Store: SessionStore + <span class="lifetime">'static</span>&gt; {
service: Rc&lt;S&gt;,
configuration: Rc&lt;Configuration&gt;,
storage_backend: Rc&lt;Store&gt;,
@@ -662,9 +662,9 @@
<span class="kw">impl</span>&lt;S, B, Store&gt; Service&lt;ServiceRequest&gt; <span class="kw">for </span>InnerSessionMiddleware&lt;S, Store&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = actix_web::Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
Store: SessionStore + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = actix_web::Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
Store: SessionStore + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;B&gt;;
<span class="kw">type </span>Error = actix_web::Error;
@@ -803,8 +803,8 @@
<span class="kw">if </span>verification_result.is_none() {
<span class="macro">tracing::warn!</span>(
<span class="string">&quot;The session cookie attached to the incoming request failed to pass cryptographic \
checks (signature verification/decryption).&quot;
<span class="string">"The session cookie attached to the incoming request failed to pass cryptographic \
checks (signature verification/decryption)."
</span>);
}
@@ -814,7 +814,7 @@
<span class="macro">tracing::warn!</span>(
error.message = %err,
error.cause_chain = <span class="question-mark">?</span>err,
<span class="string">&quot;Invalid session key, ignoring.&quot;
<span class="string">"Invalid session key, ignoring."
</span>);
<span class="prelude-val">None
@@ -839,8 +839,8 @@
// lifecycle of the current request.
</span><span class="macro">tracing::info!</span>(
<span class="string">&quot;No session state has been found for a valid session key, creating a new \
empty session.&quot;
<span class="string">"No session state has been found for a valid session key, creating a new \
empty session."
</span>);
<span class="prelude-val">Ok</span>((<span class="prelude-val">None</span>, HashMap::new()))
@@ -852,7 +852,7 @@
<span class="macro">tracing::warn!</span>(
error.message = %err,
error.cause_chain = <span class="question-mark">?</span>err,
<span class="string">&quot;Invalid session state, creating a new empty session.&quot;
<span class="string">"Invalid session state, creating a new empty session."
</span>);
<span class="prelude-val">Ok</span>((<span class="prelude-val">Some</span>(session_key), HashMap::new()))
@@ -896,7 +896,7 @@
<span class="comment">// set cookie
</span><span class="kw">let </span>cookie = jar.delta().next().unwrap();
<span class="kw">let </span>val = HeaderValue::from_str(<span class="kw-2">&amp;</span>cookie.encoded().to_string())
.context(<span class="string">&quot;Failed to attach a session cookie to the outgoing response&quot;</span>)<span class="question-mark">?</span>;
.context(<span class="string">"Failed to attach a session cookie to the outgoing response"</span>)<span class="question-mark">?</span>;
response.headers_mut().append(SET_COOKIE, val);
@@ -907,7 +907,7 @@
response: <span class="kw-2">&amp;mut </span>ResponseHead,
config: <span class="kw-2">&amp;</span>CookieConfiguration,
) -&gt; <span class="prelude-ty">Result</span>&lt;(), anyhow::Error&gt; {
<span class="kw">let </span>removal_cookie = Cookie::build(config.name.clone(), <span class="string">&quot;&quot;</span>)
<span class="kw">let </span>removal_cookie = Cookie::build(config.name.clone(), <span class="string">""</span>)
.path(config.path.clone())
.secure(config.secure)
.http_only(config.http_only)
@@ -923,7 +923,7 @@
removal_cookie.make_removal();
<span class="kw">let </span>val = HeaderValue::from_str(<span class="kw-2">&amp;</span>removal_cookie.to_string())
.context(<span class="string">&quot;Failed to attach a session removal cookie to the outgoing response&quot;</span>)<span class="question-mark">?</span>;
.context(<span class="string">"Failed to attach a session removal cookie to the outgoing response"</span>)<span class="question-mark">?</span>;
response.headers_mut().append(SET_COOKIE, val);
<span class="prelude-val">Ok</span>(())

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/session.rs`."><title>session.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/session.rs`."><title>session.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -346,15 +346,15 @@
/// ```
/// use actix_session::Session;
///
/// async fn index(session: Session) -&gt; actix_web::Result&lt;&amp;&#39;static str&gt; {
/// async fn index(session: Session) -&gt; actix_web::Result&lt;&amp;'static str&gt; {
/// // access session data
/// if let Some(count) = session.get::&lt;i32&gt;(&quot;counter&quot;)? {
/// session.insert(&quot;counter&quot;, count + 1)?;
/// if let Some(count) = session.get::&lt;i32&gt;("counter")? {
/// session.insert("counter", count + 1)?;
/// } else {
/// session.insert(&quot;counter&quot;, 1)?;
/// session.insert("counter", 1)?;
/// }
///
/// Ok(&quot;Welcome!&quot;)
/// Ok("Welcome!")
/// }
/// # actix_web::web::to(index);
/// ```
@@ -405,8 +405,8 @@
serde_json::from_str(val_str)
.with_context(|| {
<span class="macro">format!</span>(
<span class="string">&quot;Failed to deserialize the JSON-encoded session data attached to key \
`{}` as a `{}` type&quot;</span>,
<span class="string">"Failed to deserialize the JSON-encoded session data attached to key \
`{}` as a `{}` type"</span>,
key,
std::any::type_name::&lt;T&gt;()
)
@@ -421,7 +421,7 @@
<span class="doccomment">/// Get all raw key-value data from the session.
///
/// Note that values are JSON encoded.
</span><span class="kw">pub fn </span>entries(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Ref&lt;<span class="lifetime">&#39;_</span>, HashMap&lt;String, String&gt;&gt; {
</span><span class="kw">pub fn </span>entries(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Ref&lt;<span class="lifetime">'_</span>, HashMap&lt;String, String&gt;&gt; {
Ref::map(<span class="self">self</span>.<span class="number">0</span>.borrow(), |inner| <span class="kw-2">&amp;</span>inner.state)
}
@@ -452,8 +452,8 @@
<span class="kw">let </span>val = serde_json::to_string(<span class="kw-2">&amp;</span>value)
.with_context(|| {
<span class="macro">format!</span>(
<span class="string">&quot;Failed to serialize the provided `{}` type instance as JSON in order to \
attach as session data to the `{}` key&quot;</span>,
<span class="string">"Failed to serialize the provided `{}` type instance as JSON in order to \
attach as session data to the `{}` key"</span>,
std::any::type_name::&lt;T&gt;(),
<span class="kw-2">&amp;</span>key
)
@@ -492,7 +492,7 @@
<span class="prelude-val">Ok</span>(val) =&gt; <span class="prelude-val">Ok</span>(val),
<span class="prelude-val">Err</span>(_err) =&gt; {
<span class="macro">tracing::debug!</span>(
<span class="string">&quot;Removed value (key: {}) could not be deserialized as {}&quot;</span>,
<span class="string">"Removed value (key: {}) could not be deserialized as {}"</span>,
key,
std::any::type_name::&lt;T&gt;()
);
@@ -584,17 +584,17 @@
/// # use actix_web::*;
/// use actix_session::Session;
///
/// #[get(&quot;/&quot;)]
/// #[get("/")]
/// async fn index(session: Session) -&gt; Result&lt;impl Responder&gt; {
/// // access session data
/// if let Some(count) = session.get::&lt;i32&gt;(&quot;counter&quot;)? {
/// session.insert(&quot;counter&quot;, count + 1)?;
/// if let Some(count) = session.get::&lt;i32&gt;("counter")? {
/// session.insert("counter", count + 1)?;
/// } else {
/// session.insert(&quot;counter&quot;, 1)?;
/// session.insert("counter", 1)?;
/// }
///
/// let count = session.get::&lt;i32&gt;(&quot;counter&quot;)?.unwrap();
/// Ok(format!(&quot;Counter: {}&quot;, count))
/// let count = session.get::&lt;i32&gt;("counter")?.unwrap();
/// Ok(format!("Counter: {}", count))
/// }
/// ```
</span><span class="kw">impl </span>FromRequest <span class="kw">for </span>Session {
@@ -609,11 +609,11 @@
<span class="doccomment">/// Error returned by [`Session::get`].
</span><span class="attr">#[derive(Debug, Display, From)]
#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
#[display(fmt = <span class="string">"{_0}"</span>)]
</span><span class="kw">pub struct </span>SessionGetError(anyhow::Error);
<span class="kw">impl </span>StdError <span class="kw">for </span>SessionGetError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>StdError + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>StdError + <span class="lifetime">'static</span>)&gt; {
<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="number">0</span>.as_ref())
}
}
@@ -626,11 +626,11 @@
<span class="doccomment">/// Error returned by [`Session::insert`].
</span><span class="attr">#[derive(Debug, Display, From)]
#[display(fmt = <span class="string">&quot;{_0}&quot;</span>)]
#[display(fmt = <span class="string">"{_0}"</span>)]
</span><span class="kw">pub struct </span>SessionInsertError(anyhow::Error);
<span class="kw">impl </span>StdError <span class="kw">for </span>SessionInsertError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>StdError + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>StdError + <span class="lifetime">'static</span>)&gt; {
<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="number">0</span>.as_ref())
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/session_ext.rs`."><title>session_ext.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/session_ext.rs`."><title>session_ext.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -69,7 +69,7 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; SessionExt <span class="kw">for </span>GuardContext&lt;<span class="lifetime">&#39;a</span>&gt; {
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; SessionExt <span class="kw">for </span>GuardContext&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">fn </span>get_session(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Session {
Session::get_session(<span class="kw-2">&amp;mut </span><span class="self">self</span>.req_data_mut())
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/cookie.rs`."><title>cookie.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/cookie.rs`."><title>cookie.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -148,7 +148,7 @@
/// App::new()
/// .wrap(SessionMiddleware::new(CookieSessionStore::default(), secret_key.clone()))
/// .default_service(web::to(|| HttpResponse::Ok())))
/// .bind((&quot;127.0.0.1&quot;, 8080))?
/// .bind(("127.0.0.1", 8080))?
/// .run()
/// .await
/// }

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/interface.rs`."><title>interface.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/interface.rs`."><title>interface.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -126,7 +126,7 @@
///
/// You can provide your own custom session store backend by implementing this trait.
///
/// [`async-trait`](https://docs.rs/async-trait) is used for this trait&#39;s definition. Therefore, it
/// [`async-trait`](https://docs.rs/async-trait) is used for this trait's definition. Therefore, it
/// is required for implementations, too. In particular, we use the send-optional variant:
/// `#[async_trait(?Send)]`.
</span><span class="attr">#[async_trait::async_trait(<span class="question-mark">?</span>Send)]
@@ -163,23 +163,23 @@
}
<span class="comment">// We cannot derive the `Error` implementation using `derive_more` for our custom errors:
// `derive_more`&#39;s `#[error(source)]` attribute requires the source implement the `Error` trait,
// while it&#39;s actually enough for it to be able to produce a reference to a dyn Error.
// `derive_more`'s `#[error(source)]` attribute requires the source implement the `Error` trait,
// while it's actually enough for it to be able to produce a reference to a dyn Error.
</span><span class="doccomment">/// Possible failures modes for [`SessionStore::load`].
</span><span class="attr">#[derive(Debug, Display)]
</span><span class="kw">pub enum </span>LoadError {
<span class="doccomment">/// Failed to deserialize session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to deserialize session state&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to deserialize session state"</span>)]
</span>Deserialization(anyhow::Error),
<span class="doccomment">/// Something went wrong when retrieving the session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Something went wrong when retrieving the session state&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Something went wrong when retrieving the session state"</span>)]
</span>Other(anyhow::Error),
}
<span class="kw">impl </span>std::error::Error <span class="kw">for </span>LoadError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">'static</span>)&gt; {
<span class="kw">match </span><span class="self">self </span>{
<span class="self">Self</span>::Deserialization(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),
<span class="self">Self</span>::Other(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),
@@ -191,16 +191,16 @@
</span><span class="attr">#[derive(Debug, Display)]
</span><span class="kw">pub enum </span>SaveError {
<span class="doccomment">/// Failed to serialize session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to serialize session state&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to serialize session state"</span>)]
</span>Serialization(anyhow::Error),
<span class="doccomment">/// Something went wrong when persisting the session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Something went wrong when persisting the session state&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Something went wrong when persisting the session state"</span>)]
</span>Other(anyhow::Error),
}
<span class="kw">impl </span>std::error::Error <span class="kw">for </span>SaveError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">'static</span>)&gt; {
<span class="kw">match </span><span class="self">self </span>{
<span class="self">Self</span>::Serialization(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),
<span class="self">Self</span>::Other(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),
@@ -212,16 +212,16 @@
</span><span class="doccomment">/// Possible failures modes for [`SessionStore::update`].
</span><span class="kw">pub enum </span>UpdateError {
<span class="doccomment">/// Failed to serialize session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to serialize session state&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to serialize session state"</span>)]
</span>Serialization(anyhow::Error),
<span class="doccomment">/// Something went wrong when updating the session state.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Something went wrong when updating the session state.&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Something went wrong when updating the session state."</span>)]
</span>Other(anyhow::Error),
}
<span class="kw">impl </span>std::error::Error <span class="kw">for </span>UpdateError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">'static</span>)&gt; {
<span class="kw">match </span><span class="self">self </span>{
<span class="self">Self</span>::Serialization(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),
<span class="self">Self</span>::Other(err) =&gt; <span class="prelude-val">Some</span>(err.as_ref()),

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -36,22 +36,22 @@
session_key::SessionKey,
};
<span class="attr">#[cfg(feature = <span class="string">&quot;cookie-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"cookie-session"</span>)]
</span><span class="kw">mod </span>cookie;
<span class="attr">#[cfg(feature = <span class="string">&quot;redis-actor-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"redis-actor-session"</span>)]
</span><span class="kw">mod </span>redis_actor;
<span class="attr">#[cfg(feature = <span class="string">&quot;redis-rs-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"redis-rs-session"</span>)]
</span><span class="kw">mod </span>redis_rs;
<span class="attr">#[cfg(any(feature = <span class="string">&quot;redis-actor-session&quot;</span>, feature = <span class="string">&quot;redis-rs-session&quot;</span>))]
<span class="attr">#[cfg(any(feature = <span class="string">"redis-actor-session"</span>, feature = <span class="string">"redis-rs-session"</span>))]
</span><span class="kw">mod </span>utils;
<span class="attr">#[cfg(feature = <span class="string">&quot;cookie-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"cookie-session"</span>)]
</span><span class="kw">pub use </span>cookie::CookieSessionStore;
<span class="attr">#[cfg(feature = <span class="string">&quot;redis-actor-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"redis-actor-session"</span>)]
</span><span class="kw">pub use </span>redis_actor::{RedisActorSessionStore, RedisActorSessionStoreBuilder};
<span class="attr">#[cfg(feature = <span class="string">&quot;redis-rs-session&quot;</span>)]
<span class="attr">#[cfg(feature = <span class="string">"redis-rs-session"</span>)]
</span><span class="kw">pub use </span>redis_rs::{RedisSessionStore, RedisSessionStoreBuilder};
</code></pre></div></section></main></body></html>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/redis_actor.rs`."><title>redis_actor.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/redis_actor.rs`."><title>redis_actor.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -339,7 +339,7 @@
/// #[actix_web::main]
/// async fn main() -&gt; std::io::Result&lt;()&gt; {
/// let secret_key = get_secret_key();
/// let redis_connection_string = &quot;127.0.0.1:6379&quot;;
/// let redis_connection_string = "127.0.0.1:6379";
/// HttpServer::new(move ||
/// App::new()
/// .wrap(
@@ -349,7 +349,7 @@
/// )
/// )
/// .default_service(web::to(|| HttpResponse::Ok())))
/// .bind((&quot;127.0.0.1&quot;, 8080))?
/// .bind(("127.0.0.1", 8080))?
/// .run()
/// .await
/// }
@@ -357,7 +357,7 @@
///
/// # Implementation notes
///
/// `RedisActorSessionStore` leverages `actix-redis`&#39;s `RedisActor` implementation - each thread
/// `RedisActorSessionStore` leverages `actix-redis`'s `RedisActor` implementation - each thread
/// worker gets its own connection to Redis.
///
/// ## Limitations
@@ -415,7 +415,7 @@
<span class="doccomment">/// Set a custom cache key generation strategy, expecting a session key as input.
</span><span class="kw">pub fn </span>cache_keygen&lt;F&gt;(<span class="kw-2">mut </span><span class="self">self</span>, keygen: F) -&gt; <span class="self">Self
</span><span class="kw">where
</span>F: Fn(<span class="kw-2">&amp;</span>str) -&gt; String + <span class="lifetime">&#39;static</span>,
</span>F: Fn(<span class="kw-2">&amp;</span>str) -&gt; String + <span class="lifetime">'static</span>,
{
<span class="self">self</span>.configuration.cache_keygen = Box::new(keygen);
<span class="self">self
@@ -437,7 +437,7 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>val = <span class="self">self
</span>.addr
.send(Command(<span class="macro">resp_array!</span>[<span class="string">&quot;GET&quot;</span>, cache_key]))
.send(Command(<span class="macro">resp_array!</span>[<span class="string">"GET"</span>, cache_key]))
.<span class="kw">await
</span>.map_err(Into::into)
.map_err(LoadError::Other)<span class="question-mark">?
@@ -471,12 +471,12 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>cmd = Command(<span class="macro">resp_array!</span>[
<span class="string">&quot;SET&quot;</span>,
<span class="string">"SET"</span>,
cache_key,
body,
<span class="string">&quot;NX&quot;</span>, <span class="comment">// NX: only set the key if it does not already exist
</span><span class="string">&quot;EX&quot;</span>, <span class="comment">// EX: set expiry
</span><span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, ttl.whole_seconds())
<span class="string">"NX"</span>, <span class="comment">// NX: only set the key if it does not already exist
</span><span class="string">"EX"</span>, <span class="comment">// EX: set expiry
</span><span class="macro">format!</span>(<span class="string">"{}"</span>, ttl.whole_seconds())
]);
<span class="kw">let </span>result = <span class="self">self
@@ -491,10 +491,10 @@
<span class="kw">match </span>result {
RespValue::SimpleString(<span class="kw">_</span>) =&gt; <span class="prelude-val">Ok</span>(session_key),
RespValue::Nil =&gt; <span class="prelude-val">Err</span>(SaveError::Other(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to save session state. A record with the same key already existed in Redis&quot;
<span class="string">"Failed to save session state. A record with the same key already existed in Redis"
</span>))),
err =&gt; <span class="prelude-val">Err</span>(SaveError::Other(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to save session state. {:?}&quot;</span>,
<span class="string">"Failed to save session state. {:?}"</span>,
err
))),
}
@@ -512,12 +512,12 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>cmd = Command(<span class="macro">resp_array!</span>[
<span class="string">&quot;SET&quot;</span>,
<span class="string">"SET"</span>,
cache_key,
body,
<span class="string">&quot;XX&quot;</span>, <span class="comment">// XX: Only set the key if it already exist.
</span><span class="string">&quot;EX&quot;</span>, <span class="comment">// EX: set expiry
</span><span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, ttl.whole_seconds())
<span class="string">"XX"</span>, <span class="comment">// XX: Only set the key if it already exist.
</span><span class="string">"EX"</span>, <span class="comment">// EX: set expiry
</span><span class="macro">format!</span>(<span class="string">"{}"</span>, ttl.whole_seconds())
]);
<span class="kw">let </span>result = <span class="self">self
@@ -544,7 +544,7 @@
}
RespValue::SimpleString(<span class="kw">_</span>) =&gt; <span class="prelude-val">Ok</span>(session_key),
val =&gt; <span class="prelude-val">Err</span>(UpdateError::Other(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to update session state. {:?}&quot;</span>,
<span class="string">"Failed to update session state. {:?}"</span>,
val
))),
}
@@ -554,7 +554,7 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>cmd = Command(<span class="macro">resp_array!</span>[
<span class="string">&quot;EXPIRE&quot;</span>,
<span class="string">"EXPIRE"</span>,
cache_key,
ttl.whole_seconds().to_string()
]);
@@ -562,7 +562,7 @@
<span class="kw">match </span><span class="self">self</span>.addr.send(cmd).<span class="kw">await</span><span class="question-mark">? </span>{
<span class="prelude-val">Ok</span>(RespValue::Integer(<span class="kw">_</span>)) =&gt; <span class="prelude-val">Ok</span>(()),
val =&gt; <span class="prelude-val">Err</span>(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to update the session state TTL: {:?}&quot;</span>,
<span class="string">"Failed to update the session state TTL: {:?}"</span>,
val
)),
}
@@ -573,14 +573,14 @@
<span class="kw">let </span>res = <span class="self">self
</span>.addr
.send(Command(<span class="macro">resp_array!</span>[<span class="string">&quot;DEL&quot;</span>, cache_key]))
.send(Command(<span class="macro">resp_array!</span>[<span class="string">"DEL"</span>, cache_key]))
.<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">match </span>res {
<span class="comment">// Redis returns the number of deleted records
</span><span class="prelude-val">Ok</span>(RespValue::Integer(<span class="kw">_</span>)) =&gt; <span class="prelude-val">Ok</span>(()),
val =&gt; <span class="prelude-val">Err</span>(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to remove session from cache. {:?}&quot;</span>,
<span class="string">"Failed to remove session from cache. {:?}"</span>,
val
)),
}
@@ -597,7 +597,7 @@
<span class="kw">use </span><span class="kw">crate</span>::test_helpers::acceptance_test_suite;
<span class="kw">fn </span>redis_actor_store() -&gt; RedisActorSessionStore {
RedisActorSessionStore::new(<span class="string">&quot;127.0.0.1:6379&quot;</span>)
RedisActorSessionStore::new(<span class="string">"127.0.0.1:6379"</span>)
}
<span class="attr">#[actix_web::test]

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/redis_rs.rs`."><title>redis_rs.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/redis_rs.rs`."><title>redis_rs.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -373,7 +373,7 @@
/// #[actix_web::main]
/// async fn main() -&gt; std::io::Result&lt;()&gt; {
/// let secret_key = get_secret_key();
/// let redis_connection_string = &quot;redis://127.0.0.1:6379&quot;;
/// let redis_connection_string = "redis://127.0.0.1:6379";
/// let store = RedisSessionStore::new(redis_connection_string).await.unwrap();
///
/// HttpServer::new(move ||
@@ -383,7 +383,7 @@
/// secret_key.clone()
/// ))
/// .default_service(web::to(|| HttpResponse::Ok())))
/// .bind((&quot;127.0.0.1&quot;, 8080))?
/// .bind(("127.0.0.1", 8080))?
/// .run()
/// .await
/// }
@@ -397,7 +397,7 @@
/// use actix_session::{storage::RedisSessionStore};
///
/// # actix_web::rt::System::new().block_on(async {
/// let redis_connection_string = &quot;rediss://127.0.0.1:6379&quot;;
/// let redis_connection_string = "rediss://127.0.0.1:6379";
/// let store = RedisSessionStore::new(redis_connection_string).await.unwrap();
/// # })
/// ```
@@ -460,7 +460,7 @@
<span class="doccomment">/// Set a custom cache key generation strategy, expecting a session key as input.
</span><span class="kw">pub fn </span>cache_keygen&lt;F&gt;(<span class="kw-2">mut </span><span class="self">self</span>, keygen: F) -&gt; <span class="self">Self
</span><span class="kw">where
</span>F: Fn(<span class="kw-2">&amp;</span>str) -&gt; String + <span class="lifetime">&#39;static </span>+ Send + Sync,
</span>F: Fn(<span class="kw-2">&amp;</span>str) -&gt; String + <span class="lifetime">'static </span>+ Send + Sync,
{
<span class="self">self</span>.configuration.cache_keygen = Arc::new(keygen);
<span class="self">self
@@ -484,7 +484,7 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>value: <span class="prelude-ty">Option</span>&lt;String&gt; = <span class="self">self
</span>.execute_command(redis::cmd(<span class="string">&quot;GET&quot;</span>).arg(<span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span>cache_key]))
</span>.execute_command(redis::cmd(<span class="string">"GET"</span>).arg(<span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span>cache_key]))
.<span class="kw">await
</span>.map_err(Into::into)
.map_err(LoadError::Other)<span class="question-mark">?</span>;
@@ -508,12 +508,12 @@
<span class="kw">let </span>session_key = generate_session_key();
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="self">self</span>.execute_command(redis::cmd(<span class="string">&quot;SET&quot;</span>).arg(<span class="kw-2">&amp;</span>[
<span class="self">self</span>.execute_command(redis::cmd(<span class="string">"SET"</span>).arg(<span class="kw-2">&amp;</span>[
<span class="kw-2">&amp;</span>cache_key,
<span class="kw-2">&amp;</span>body,
<span class="string">&quot;NX&quot;</span>, <span class="comment">// NX: only set the key if it does not already exist
</span><span class="string">&quot;EX&quot;</span>, <span class="comment">// EX: set expiry
</span><span class="kw-2">&amp;</span><span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, ttl.whole_seconds()),
<span class="string">"NX"</span>, <span class="comment">// NX: only set the key if it does not already exist
</span><span class="string">"EX"</span>, <span class="comment">// EX: set expiry
</span><span class="kw-2">&amp;</span><span class="macro">format!</span>(<span class="string">"{}"</span>, ttl.whole_seconds()),
]))
.<span class="kw">await
</span>.map_err(Into::into)
@@ -535,12 +535,12 @@
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="kw">let </span>v: redis::Value = <span class="self">self
</span>.execute_command(redis::cmd(<span class="string">&quot;SET&quot;</span>).arg(<span class="kw-2">&amp;</span>[
</span>.execute_command(redis::cmd(<span class="string">"SET"</span>).arg(<span class="kw-2">&amp;</span>[
<span class="kw-2">&amp;</span>cache_key,
<span class="kw-2">&amp;</span>body,
<span class="string">&quot;XX&quot;</span>, <span class="comment">// XX: Only set the key if it already exist.
</span><span class="string">&quot;EX&quot;</span>, <span class="comment">// EX: set expiry
</span><span class="kw-2">&amp;</span><span class="macro">format!</span>(<span class="string">&quot;{}&quot;</span>, ttl.whole_seconds()),
<span class="string">"XX"</span>, <span class="comment">// XX: Only set the key if it already exist.
</span><span class="string">"EX"</span>, <span class="comment">// EX: set expiry
</span><span class="kw-2">&amp;</span><span class="macro">format!</span>(<span class="string">"{}"</span>, ttl.whole_seconds()),
]))
.<span class="kw">await
</span>.map_err(Into::into)
@@ -561,7 +561,7 @@
}
Value::Int(<span class="kw">_</span>) | Value::Okay | Value::Status(<span class="kw">_</span>) =&gt; <span class="prelude-val">Ok</span>(session_key),
val =&gt; <span class="prelude-val">Err</span>(UpdateError::Other(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;Failed to update session state. {:?}&quot;</span>,
<span class="string">"Failed to update session state. {:?}"</span>,
val
))),
}
@@ -575,7 +575,7 @@
.expire(
<span class="kw-2">&amp;</span>cache_key,
ttl.whole_seconds().try_into().context(
<span class="string">&quot;Failed to convert the state TTL into the number of whole seconds remaining&quot;</span>,
<span class="string">"Failed to convert the state TTL into the number of whole seconds remaining"</span>,
)<span class="question-mark">?</span>,
)
.<span class="kw">await</span><span class="question-mark">?</span>;
@@ -584,7 +584,7 @@
<span class="kw">async fn </span>delete(<span class="kw-2">&amp;</span><span class="self">self</span>, session_key: <span class="kw-2">&amp;</span>SessionKey) -&gt; <span class="prelude-ty">Result</span>&lt;(), anyhow::Error&gt; {
<span class="kw">let </span>cache_key = (<span class="self">self</span>.configuration.cache_keygen)(session_key.as_ref());
<span class="self">self</span>.execute_command(redis::cmd(<span class="string">&quot;DEL&quot;</span>).arg(<span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span>cache_key]))
<span class="self">self</span>.execute_command(redis::cmd(<span class="string">"DEL"</span>).arg(<span class="kw-2">&amp;</span>[<span class="kw-2">&amp;</span>cache_key]))
.<span class="kw">await
</span>.map_err(Into::into)
.map_err(UpdateError::Other)<span class="question-mark">?</span>;
@@ -617,7 +617,7 @@
<span class="prelude-val">Err</span>(err) =&gt; {
<span class="kw">if </span>can_retry &amp;&amp; err.is_connection_dropped() {
<span class="macro">tracing::debug!</span>(
<span class="string">&quot;Connection dropped while trying to talk to Redis. Retrying.&quot;
<span class="string">"Connection dropped while trying to talk to Redis. Retrying."
</span>);
<span class="comment">// Retry at most once
@@ -644,7 +644,7 @@
<span class="kw">use </span><span class="kw">crate</span>::test_helpers::acceptance_test_suite;
<span class="kw">async fn </span>redis_store() -&gt; RedisSessionStore {
RedisSessionStore::new(<span class="string">&quot;redis://127.0.0.1:6379&quot;</span>)
RedisSessionStore::new(<span class="string">"redis://127.0.0.1:6379"</span>)
.<span class="kw">await
</span>.unwrap()
}
@@ -669,7 +669,7 @@
store
.client
.clone()
.set::&lt;<span class="kw">_</span>, <span class="kw">_</span>, ()&gt;(session_key.as_ref(), <span class="string">&quot;random-thing-which-is-not-json&quot;</span>)
.set::&lt;<span class="kw">_</span>, <span class="kw">_</span>, ()&gt;(session_key.as_ref(), <span class="string">"random-thing-which-is-not-json"</span>)
.<span class="kw">await
</span>.unwrap();
<span class="macro">assert!</span>(<span class="macro">matches!</span>(

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/session_key.rs`."><title>session_key.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/session_key.rs`."><title>session_key.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -71,7 +71,7 @@
/// # use std::convert::TryInto;
/// use actix_session::storage::SessionKey;
///
/// let key: String = std::iter::repeat(&#39;a&#39;).take(4065).collect();
/// let key: String = std::iter::repeat('a').take(4065).collect();
/// let session_key: Result&lt;SessionKey, _&gt; = key.try_into();
/// assert!(session_key.is_err());
/// ```
@@ -84,7 +84,7 @@
<span class="kw">fn </span>try_from(val: String) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, <span class="self">Self</span>::Error&gt; {
<span class="kw">if </span>val.len() &gt; <span class="number">4064 </span>{
<span class="kw">return </span><span class="prelude-val">Err</span>(<span class="macro">anyhow::anyhow!</span>(
<span class="string">&quot;The session key is bigger than 4064 bytes, the upper limit on cookie content.&quot;
<span class="string">"The session key is bigger than 4064 bytes, the upper limit on cookie content."
</span>)
.into());
}
@@ -106,11 +106,11 @@
}
<span class="attr">#[derive(Debug, Display, From)]
#[display(fmt = <span class="string">&quot;The provided string is not a valid session key&quot;</span>)]
#[display(fmt = <span class="string">"The provided string is not a valid session key"</span>)]
</span><span class="kw">pub struct </span>InvalidSessionKeyError(anyhow::Error);
<span class="kw">impl </span>std::error::Error <span class="kw">for </span>InvalidSessionKeyError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>std::error::Error + <span class="lifetime">'static</span>)&gt; {
<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="number">0</span>.as_ref())
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-session/src/storage/utils.rs`."><title>utils.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-session/src/storage/utils.rs`."><title>utils.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_session"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/error.rs`."><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -124,42 +124,42 @@
</span><span class="attr">#[derive(Debug, Display, Error)]
</span><span class="kw">pub enum </span>Error {
<span class="doccomment">/// Environment variable does not exists or is invalid.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Env var error: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Env var error: {_0}"</span>)]
</span>EnvVarError(VarError),
<span class="doccomment">/// File already exists on disk.
</span><span class="attr">#[display(fmt = <span class="string">&quot;File exists: {}&quot;</span>, <span class="string">&quot;_0.display()&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"File exists: {}"</span>, <span class="string">"_0.display()"</span>)]
</span>FileExists(<span class="attr">#[error(not(source))] </span>PathBuf),
<span class="doccomment">/// Invalid value.
</span><span class="attr">#[allow(missing_docs)]
#[display(fmt = <span class="string">&quot;Expected {expected}, got {got} (@ {file}:{line}:{column})&quot;</span>)]
#[display(fmt = <span class="string">"Expected {expected}, got {got} (@ {file}:{line}:{column})"</span>)]
</span>InvalidValue {
expected: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str,
expected: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str,
got: String,
file: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str,
file: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str,
line: u32,
column: u32,
},
<span class="doccomment">/// I/O error.
</span><span class="attr">#[display(fmt = <span class="string">&quot;&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">""</span>)]
</span>IoError(io::Error),
<span class="doccomment">/// Value is not a boolean.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to parse boolean: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to parse boolean: {_0}"</span>)]
</span>ParseBoolError(ParseBoolError),
<span class="doccomment">/// Value is not an integer.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to parse integer: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to parse integer: {_0}"</span>)]
</span>ParseIntError(ParseIntError),
<span class="doccomment">/// Value is not an address.
</span><span class="attr">#[display(fmt = <span class="string">&quot;Failed to parse address: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"Failed to parse address: {_0}"</span>)]
</span>ParseAddressError(<span class="attr">#[error(not(source))] </span>String),
<span class="doccomment">/// Error deserializing as TOML.
</span><span class="attr">#[display(fmt = <span class="string">&quot;TOML error: {_0}&quot;</span>)]
</span><span class="attr">#[display(fmt = <span class="string">"TOML error: {_0}"</span>)]
</span>TomlError(TomlError),
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -818,9 +818,9 @@
<a href="#818" id="818">818</a>
<a href="#819" id="819">819</a>
<a href="#820" id="820">820</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Easily manage Actix Web&#39;s settings from a TOML file and environment variables.
</pre></div><pre class="rust"><code><span class="doccomment">//! Easily manage Actix Web's settings from a TOML file and environment variables.
//!
//! To get started add a [`Settings::parse_toml(&quot;./Server.toml&quot;)`](Settings::parse_toml) call to the
//! To get started add a [`Settings::parse_toml("./Server.toml")`](Settings::parse_toml) call to the
//! top of your main function. This will create a template file with descriptions of all the
//! configurable settings. You can change or remove anything in that file and it will be picked up
//! the next time you run your application.
@@ -842,12 +842,12 @@
//!
//! #[actix_web::main]
//! async fn main() -&gt; std::io::Result&lt;()&gt; {
//! let mut settings = Settings::parse_toml(&quot;./Server.toml&quot;)
//! .expect(&quot;Failed to parse `Settings` from Server.toml&quot;);
//! let mut settings = Settings::parse_toml("./Server.toml")
//! .expect("Failed to parse `Settings` from Server.toml");
//!
//! // If the environment variable `$APPLICATION__HOSTS` is set,
//! // have its value override the `settings.actix.hosts` setting:
//! Settings::override_field_with_env_var(&amp;mut settings.actix.hosts, &quot;APPLICATION__HOSTS&quot;)?;
//! Settings::override_field_with_env_var(&amp;mut settings.actix.hosts, "APPLICATION__HOSTS")?;
//!
//! init_logger(&amp;settings);
//!
@@ -873,7 +873,7 @@
//! .service(index)
//! }
//! })
//! // apply the `Settings` to Actix Web&#39;s `HttpServer`
//! // apply the `Settings` to Actix Web's `HttpServer`
//! .apply_settings(&amp;settings)
//! .run()
//! .await
@@ -883,8 +883,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs, missing_debug_implementations)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">use </span>std::{
@@ -924,7 +924,7 @@
<span class="doccomment">/// Wrapper for server and application-specific settings.
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(bound = <span class="string">&quot;A: Deserialize&lt;&#39;de&gt;&quot;</span>)]
#[serde(bound = <span class="string">"A: Deserialize&lt;'de&gt;"</span>)]
</span><span class="kw">pub struct </span>BasicSettings&lt;A&gt; {
<span class="doccomment">/// Actix Web server settings.
</span><span class="kw">pub </span>actix: ActixSettings,
@@ -949,11 +949,11 @@
// Especially the `[application]` table needs to be last in order
// for some tests to keep working.
</span><span class="doccomment">/// Default settings file contents.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>DEFAULT_TOML_TEMPLATE: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str = <span class="macro">include_str!</span>(<span class="string">&quot;./defaults.toml&quot;</span>);
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>DEFAULT_TOML_TEMPLATE: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str = <span class="macro">include_str!</span>(<span class="string">"./defaults.toml"</span>);
<span class="doccomment">/// Parse an instance of `Self` from a TOML file located at `filepath`.
///
/// If the file doesn&#39;t exist, it is generated from the default TOML template, after which the
/// If the file doesn't exist, it is generated from the default TOML template, after which the
/// newly generated file is read in and parsed.
</span><span class="kw">pub fn </span>parse_toml&lt;P&gt;(filepath: P) -&gt; AsResult&lt;<span class="self">Self</span>&gt;
<span class="kw">where
@@ -1017,7 +1017,7 @@
/// let mut settings = Settings::from_default_template();
/// assert_eq!(settings.actix.mode, Mode::Development);
///
/// Settings::override_field(&amp;mut settings.actix.mode, &quot;production&quot;)?;
/// Settings::override_field(&amp;mut settings.actix.mode, "production")?;
/// assert_eq!(settings.actix.mode, Mode::Production);
/// # Ok(()) }
/// ```
@@ -1036,13 +1036,13 @@
/// ```
/// use actix_settings::{Settings, Mode};
///
/// std::env::set_var(&quot;OVERRIDE__MODE&quot;, &quot;production&quot;);
/// std::env::set_var("OVERRIDE__MODE", "production");
///
/// # fn inner() -&gt; Result&lt;(), actix_settings::Error&gt; {
/// let mut settings = Settings::from_default_template();
/// assert_eq!(settings.actix.mode, Mode::Development);
///
/// Settings::override_field_with_env_var(&amp;mut settings.actix.mode, &quot;OVERRIDE__MODE&quot;)?;
/// Settings::override_field_with_env_var(&amp;mut settings.actix.mode, "OVERRIDE__MODE")?;
/// assert_eq!(settings.actix.mode, Mode::Production);
/// # Ok(()) }
/// ```
@@ -1068,25 +1068,25 @@
<span class="kw">impl</span>&lt;F, I, S, B&gt; ApplySettings&lt;ActixSettings&gt; <span class="kw">for </span>HttpServer&lt;F, I, S, B&gt;
<span class="kw">where
</span>F: Fn() -&gt; I + Send + Clone + <span class="lifetime">&#39;static</span>,
</span>F: Fn() -&gt; I + Send + Clone + <span class="lifetime">'static</span>,
I: IntoServiceFactory&lt;S, Request&gt;,
S: ServiceFactory&lt;Request, Config = AppConfig&gt; + <span class="lifetime">&#39;static</span>,
S::Error: Into&lt;WebError&gt; + <span class="lifetime">&#39;static</span>,
S: ServiceFactory&lt;Request, Config = AppConfig&gt; + <span class="lifetime">'static</span>,
S::Error: Into&lt;WebError&gt; + <span class="lifetime">'static</span>,
S::InitError: fmt::Debug,
S::Response: Into&lt;Response&lt;B&gt;&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
S::Response: Into&lt;Response&lt;B&gt;&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">fn </span>apply_settings(<span class="kw-2">mut </span><span class="self">self</span>, settings: <span class="kw-2">&amp;</span>ActixSettings) -&gt; <span class="self">Self </span>{
<span class="kw">if </span>settings.tls.enabled {
<span class="comment">// for Address { host, port } in &amp;settings.actix.hosts {
// self = self.bind(format!(&quot;{}:{}&quot;, host, port))
// self = self.bind(format!("{}:{}", host, port))
// .unwrap(/*TODO*/);
// }
</span><span class="macro">unimplemented!</span>(<span class="string">&quot;[ApplySettings] TLS support has not been implemented yet.&quot;</span>);
</span><span class="macro">unimplemented!</span>(<span class="string">"[ApplySettings] TLS support has not been implemented yet."</span>);
} <span class="kw">else </span>{
<span class="kw">for </span>Address { host, port } <span class="kw">in </span><span class="kw-2">&amp;</span>settings.hosts {
<span class="self">self </span>= <span class="self">self</span>.bind(<span class="macro">format!</span>(<span class="string">&quot;{host}:{port}&quot;</span>))
<span class="self">self </span>= <span class="self">self</span>.bind(<span class="macro">format!</span>(<span class="string">"{host}:{port}"</span>))
.unwrap(<span class="comment">/*TODO*/</span>);
}
}
@@ -1146,14 +1146,14 @@
<span class="kw">impl</span>&lt;F, I, S, B, A&gt; ApplySettings&lt;BasicSettings&lt;A&gt;&gt; <span class="kw">for </span>HttpServer&lt;F, I, S, B&gt;
<span class="kw">where
</span>F: Fn() -&gt; I + Send + Clone + <span class="lifetime">&#39;static</span>,
</span>F: Fn() -&gt; I + Send + Clone + <span class="lifetime">'static</span>,
I: IntoServiceFactory&lt;S, Request&gt;,
S: ServiceFactory&lt;Request, Config = AppConfig&gt; + <span class="lifetime">&#39;static</span>,
S::Error: Into&lt;WebError&gt; + <span class="lifetime">&#39;static</span>,
S: ServiceFactory&lt;Request, Config = AppConfig&gt; + <span class="lifetime">'static</span>,
S::Error: Into&lt;WebError&gt; + <span class="lifetime">'static</span>,
S::InitError: fmt::Debug,
S::Response: Into&lt;Response&lt;B&gt;&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
S::Response: Into&lt;Response&lt;B&gt;&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
A: de::DeserializeOwned,
{
<span class="kw">fn </span>apply_settings(<span class="self">self</span>, settings: <span class="kw-2">&amp;</span>BasicSettings&lt;A&gt;) -&gt; <span class="self">Self </span>{
@@ -1169,7 +1169,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>apply_settings() {
<span class="kw">let </span>settings = Settings::parse_toml(<span class="string">&quot;Server.toml&quot;</span>).unwrap();
<span class="kw">let </span>settings = Settings::parse_toml(<span class="string">"Server.toml"</span>).unwrap();
<span class="kw">let _ </span>= HttpServer::new(App::new).apply_settings(<span class="kw-2">&amp;</span>settings);
}
@@ -1180,17 +1180,17 @@
<span class="macro">assert_eq!</span>(
settings.actix.hosts,
<span class="macro">vec!</span>[Address {
host: <span class="string">&quot;0.0.0.0&quot;</span>.into(),
host: <span class="string">"0.0.0.0"</span>.into(),
port: <span class="number">9000
</span>},]
);
Settings::override_field(
<span class="kw-2">&amp;mut </span>settings.actix.hosts,
<span class="string">r#&quot;[
[&quot;0.0.0.0&quot;, 1234],
[&quot;localhost&quot;, 2345]
]&quot;#</span>,
<span class="string">r#"[
["0.0.0.0", 1234],
["localhost", 2345]
]"#</span>,
)
.unwrap();
@@ -1198,11 +1198,11 @@
settings.actix.hosts,
<span class="macro">vec!</span>[
Address {
host: <span class="string">&quot;0.0.0.0&quot;</span>.into(),
host: <span class="string">"0.0.0.0"</span>.into(),
port: <span class="number">1234
</span>},
Address {
host: <span class="string">&quot;localhost&quot;</span>.into(),
host: <span class="string">"localhost"</span>.into(),
port: <span class="number">2345
</span>},
]
@@ -1216,31 +1216,31 @@
<span class="macro">assert_eq!</span>(
settings.actix.hosts,
<span class="macro">vec!</span>[Address {
host: <span class="string">&quot;0.0.0.0&quot;</span>.into(),
host: <span class="string">"0.0.0.0"</span>.into(),
port: <span class="number">9000
</span>},]
);
std::env::set_var(
<span class="string">&quot;OVERRIDE__HOSTS&quot;</span>,
<span class="string">r#&quot;[
[&quot;0.0.0.0&quot;, 1234],
[&quot;localhost&quot;, 2345]
]&quot;#</span>,
<span class="string">"OVERRIDE__HOSTS"</span>,
<span class="string">r#"[
["0.0.0.0", 1234],
["localhost", 2345]
]"#</span>,
);
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.hosts, <span class="string">&quot;OVERRIDE__HOSTS&quot;</span>)
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.hosts, <span class="string">"OVERRIDE__HOSTS"</span>)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.hosts,
<span class="macro">vec!</span>[
Address {
host: <span class="string">&quot;0.0.0.0&quot;</span>.into(),
host: <span class="string">"0.0.0.0"</span>.into(),
port: <span class="number">1234
</span>},
Address {
host: <span class="string">&quot;localhost&quot;</span>.into(),
host: <span class="string">"localhost"</span>.into(),
port: <span class="number">2345
</span>},
]
@@ -1251,7 +1251,7 @@
</span><span class="kw">fn </span>override_field_mode() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.mode, Mode::Development);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.mode, <span class="string">&quot;production&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.mode, <span class="string">"production"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.mode, Mode::Production);
}
@@ -1259,8 +1259,8 @@
</span><span class="kw">fn </span>override_field_with_env_var_mode() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.mode, Mode::Development);
std::env::set_var(<span class="string">&quot;OVERRIDE__MODE&quot;</span>, <span class="string">&quot;production&quot;</span>);
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.mode, <span class="string">&quot;OVERRIDE__MODE&quot;</span>).unwrap();
std::env::set_var(<span class="string">"OVERRIDE__MODE"</span>, <span class="string">"production"</span>);
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.mode, <span class="string">"OVERRIDE__MODE"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.mode, Mode::Production);
}
@@ -1268,7 +1268,7 @@
</span><span class="kw">fn </span>override_field_enable_compression() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(settings.actix.enable_compression);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.enable_compression, <span class="string">&quot;false&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.enable_compression, <span class="string">"false"</span>).unwrap();
<span class="macro">assert!</span>(!settings.actix.enable_compression);
}
@@ -1276,10 +1276,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_enable_compression() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(settings.actix.enable_compression);
std::env::set_var(<span class="string">&quot;OVERRIDE__ENABLE_COMPRESSION&quot;</span>, <span class="string">&quot;false&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__ENABLE_COMPRESSION"</span>, <span class="string">"false"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.enable_compression,
<span class="string">&quot;OVERRIDE__ENABLE_COMPRESSION&quot;</span>,
<span class="string">"OVERRIDE__ENABLE_COMPRESSION"</span>,
)
.unwrap();
<span class="macro">assert!</span>(!settings.actix.enable_compression);
@@ -1289,7 +1289,7 @@
</span><span class="kw">fn </span>override_field_enable_log() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(settings.actix.enable_log);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.enable_log, <span class="string">&quot;false&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.enable_log, <span class="string">"false"</span>).unwrap();
<span class="macro">assert!</span>(!settings.actix.enable_log);
}
@@ -1297,10 +1297,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_enable_log() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(settings.actix.enable_log);
std::env::set_var(<span class="string">&quot;OVERRIDE__ENABLE_LOG&quot;</span>, <span class="string">&quot;false&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__ENABLE_LOG"</span>, <span class="string">"false"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.enable_log,
<span class="string">&quot;OVERRIDE__ENABLE_LOG&quot;</span>,
<span class="string">"OVERRIDE__ENABLE_LOG"</span>,
)
.unwrap();
<span class="macro">assert!</span>(!settings.actix.enable_log);
@@ -1310,7 +1310,7 @@
</span><span class="kw">fn </span>override_field_num_workers() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.num_workers, NumWorkers::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.num_workers, <span class="string">&quot;42&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.num_workers, <span class="string">"42"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.num_workers, NumWorkers::Manual(<span class="number">42</span>));
}
@@ -1318,10 +1318,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_num_workers() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.num_workers, NumWorkers::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__NUM_WORKERS&quot;</span>, <span class="string">&quot;42&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__NUM_WORKERS"</span>, <span class="string">"42"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.num_workers,
<span class="string">&quot;OVERRIDE__NUM_WORKERS&quot;</span>,
<span class="string">"OVERRIDE__NUM_WORKERS"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.num_workers, NumWorkers::Manual(<span class="number">42</span>));
@@ -1331,7 +1331,7 @@
</span><span class="kw">fn </span>override_field_backlog() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.backlog, Backlog::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.backlog, <span class="string">&quot;42&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.backlog, <span class="string">"42"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.backlog, Backlog::Manual(<span class="number">42</span>));
}
@@ -1339,8 +1339,8 @@
</span><span class="kw">fn </span>override_field_with_env_var_backlog() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.backlog, Backlog::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__BACKLOG&quot;</span>, <span class="string">&quot;42&quot;</span>);
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.backlog, <span class="string">&quot;OVERRIDE__BACKLOG&quot;</span>)
std::env::set_var(<span class="string">"OVERRIDE__BACKLOG"</span>, <span class="string">"42"</span>);
Settings::override_field_with_env_var(<span class="kw-2">&amp;mut </span>settings.actix.backlog, <span class="string">"OVERRIDE__BACKLOG"</span>)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.backlog, Backlog::Manual(<span class="number">42</span>));
}
@@ -1349,7 +1349,7 @@
</span><span class="kw">fn </span>override_field_max_connections() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.max_connections, MaxConnections::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.max_connections, <span class="string">&quot;42&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.max_connections, <span class="string">"42"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.max_connections, MaxConnections::Manual(<span class="number">42</span>));
}
@@ -1357,10 +1357,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_max_connections() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.max_connections, MaxConnections::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__MAX_CONNECTIONS&quot;</span>, <span class="string">&quot;42&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__MAX_CONNECTIONS"</span>, <span class="string">"42"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.max_connections,
<span class="string">&quot;OVERRIDE__MAX_CONNECTIONS&quot;</span>,
<span class="string">"OVERRIDE__MAX_CONNECTIONS"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.max_connections, MaxConnections::Manual(<span class="number">42</span>));
@@ -1373,7 +1373,7 @@
settings.actix.max_connection_rate,
MaxConnectionRate::Default
);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.max_connection_rate, <span class="string">&quot;42&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.max_connection_rate, <span class="string">"42"</span>).unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.max_connection_rate,
MaxConnectionRate::Manual(<span class="number">42</span>)
@@ -1387,10 +1387,10 @@
settings.actix.max_connection_rate,
MaxConnectionRate::Default
);
std::env::set_var(<span class="string">&quot;OVERRIDE__MAX_CONNECTION_RATE&quot;</span>, <span class="string">&quot;42&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__MAX_CONNECTION_RATE"</span>, <span class="string">"42"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.max_connection_rate,
<span class="string">&quot;OVERRIDE__MAX_CONNECTION_RATE&quot;</span>,
<span class="string">"OVERRIDE__MAX_CONNECTION_RATE"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
@@ -1403,7 +1403,7 @@
</span><span class="kw">fn </span>override_field_keep_alive() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.keep_alive, KeepAlive::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.keep_alive, <span class="string">&quot;42 seconds&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.keep_alive, <span class="string">"42 seconds"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.keep_alive, KeepAlive::Seconds(<span class="number">42</span>));
}
@@ -1411,10 +1411,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_keep_alive() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.keep_alive, KeepAlive::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__KEEP_ALIVE&quot;</span>, <span class="string">&quot;42 seconds&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__KEEP_ALIVE"</span>, <span class="string">"42 seconds"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.keep_alive,
<span class="string">&quot;OVERRIDE__KEEP_ALIVE&quot;</span>,
<span class="string">"OVERRIDE__KEEP_ALIVE"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.keep_alive, KeepAlive::Seconds(<span class="number">42</span>));
@@ -1424,7 +1424,7 @@
</span><span class="kw">fn </span>override_field_client_timeout() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.client_timeout, Timeout::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.client_timeout, <span class="string">&quot;42 seconds&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.client_timeout, <span class="string">"42 seconds"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.client_timeout, Timeout::Seconds(<span class="number">42</span>));
}
@@ -1432,10 +1432,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_client_timeout() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.client_timeout, Timeout::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__CLIENT_TIMEOUT&quot;</span>, <span class="string">&quot;42 seconds&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__CLIENT_TIMEOUT"</span>, <span class="string">"42 seconds"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.client_timeout,
<span class="string">&quot;OVERRIDE__CLIENT_TIMEOUT&quot;</span>,
<span class="string">"OVERRIDE__CLIENT_TIMEOUT"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.client_timeout, Timeout::Seconds(<span class="number">42</span>));
@@ -1445,7 +1445,7 @@
</span><span class="kw">fn </span>override_field_client_shutdown() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.client_shutdown, Timeout::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.client_shutdown, <span class="string">&quot;42 seconds&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.client_shutdown, <span class="string">"42 seconds"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.client_shutdown, Timeout::Seconds(<span class="number">42</span>));
}
@@ -1453,10 +1453,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_client_shutdown() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.client_shutdown, Timeout::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__CLIENT_SHUTDOWN&quot;</span>, <span class="string">&quot;42 seconds&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__CLIENT_SHUTDOWN"</span>, <span class="string">"42 seconds"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.client_shutdown,
<span class="string">&quot;OVERRIDE__CLIENT_SHUTDOWN&quot;</span>,
<span class="string">"OVERRIDE__CLIENT_SHUTDOWN"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.client_shutdown, Timeout::Seconds(<span class="number">42</span>));
@@ -1466,7 +1466,7 @@
</span><span class="kw">fn </span>override_field_shutdown_timeout() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.shutdown_timeout, Timeout::Default);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.shutdown_timeout, <span class="string">&quot;42 seconds&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.shutdown_timeout, <span class="string">"42 seconds"</span>).unwrap();
<span class="macro">assert_eq!</span>(settings.actix.shutdown_timeout, Timeout::Seconds(<span class="number">42</span>));
}
@@ -1474,10 +1474,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_shutdown_timeout() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(settings.actix.shutdown_timeout, Timeout::Default);
std::env::set_var(<span class="string">&quot;OVERRIDE__SHUTDOWN_TIMEOUT&quot;</span>, <span class="string">&quot;42 seconds&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__SHUTDOWN_TIMEOUT"</span>, <span class="string">"42 seconds"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.shutdown_timeout,
<span class="string">&quot;OVERRIDE__SHUTDOWN_TIMEOUT&quot;</span>,
<span class="string">"OVERRIDE__SHUTDOWN_TIMEOUT"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(settings.actix.shutdown_timeout, Timeout::Seconds(<span class="number">42</span>));
@@ -1487,7 +1487,7 @@
</span><span class="kw">fn </span>override_field_tls_enabled() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(!settings.actix.tls.enabled);
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.tls.enabled, <span class="string">&quot;true&quot;</span>).unwrap();
Settings::override_field(<span class="kw-2">&amp;mut </span>settings.actix.tls.enabled, <span class="string">"true"</span>).unwrap();
<span class="macro">assert!</span>(settings.actix.tls.enabled);
}
@@ -1495,10 +1495,10 @@
</span><span class="kw">fn </span>override_field_with_env_var_tls_enabled() {
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert!</span>(!settings.actix.tls.enabled);
std::env::set_var(<span class="string">&quot;OVERRIDE__TLS_ENABLED&quot;</span>, <span class="string">&quot;true&quot;</span>);
std::env::set_var(<span class="string">"OVERRIDE__TLS_ENABLED"</span>, <span class="string">"true"</span>);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.tls.enabled,
<span class="string">&quot;OVERRIDE__TLS_ENABLED&quot;</span>,
<span class="string">"OVERRIDE__TLS_ENABLED"</span>,
)
.unwrap();
<span class="macro">assert!</span>(settings.actix.tls.enabled);
@@ -1509,16 +1509,16 @@
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(
settings.actix.tls.certificate,
Path::new(<span class="string">&quot;path/to/cert/cert.pem&quot;</span>)
Path::new(<span class="string">"path/to/cert/cert.pem"</span>)
);
Settings::override_field(
<span class="kw-2">&amp;mut </span>settings.actix.tls.certificate,
<span class="string">&quot;/overridden/path/to/cert/cert.pem&quot;</span>,
<span class="string">"/overridden/path/to/cert/cert.pem"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.tls.certificate,
Path::new(<span class="string">&quot;/overridden/path/to/cert/cert.pem&quot;</span>)
Path::new(<span class="string">"/overridden/path/to/cert/cert.pem"</span>)
);
}
@@ -1527,20 +1527,20 @@
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(
settings.actix.tls.certificate,
Path::new(<span class="string">&quot;path/to/cert/cert.pem&quot;</span>)
Path::new(<span class="string">"path/to/cert/cert.pem"</span>)
);
std::env::set_var(
<span class="string">&quot;OVERRIDE__TLS_CERTIFICATE&quot;</span>,
<span class="string">&quot;/overridden/path/to/cert/cert.pem&quot;</span>,
<span class="string">"OVERRIDE__TLS_CERTIFICATE"</span>,
<span class="string">"/overridden/path/to/cert/cert.pem"</span>,
);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.tls.certificate,
<span class="string">&quot;OVERRIDE__TLS_CERTIFICATE&quot;</span>,
<span class="string">"OVERRIDE__TLS_CERTIFICATE"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.tls.certificate,
Path::new(<span class="string">&quot;/overridden/path/to/cert/cert.pem&quot;</span>)
Path::new(<span class="string">"/overridden/path/to/cert/cert.pem"</span>)
);
}
@@ -1549,16 +1549,16 @@
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(
settings.actix.tls.private_key,
Path::new(<span class="string">&quot;path/to/cert/key.pem&quot;</span>)
Path::new(<span class="string">"path/to/cert/key.pem"</span>)
);
Settings::override_field(
<span class="kw-2">&amp;mut </span>settings.actix.tls.private_key,
<span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>,
<span class="string">"/overridden/path/to/cert/key.pem"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.tls.private_key,
Path::new(<span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>)
Path::new(<span class="string">"/overridden/path/to/cert/key.pem"</span>)
);
}
@@ -1567,20 +1567,20 @@
<span class="kw">let </span><span class="kw-2">mut </span>settings = Settings::from_default_template();
<span class="macro">assert_eq!</span>(
settings.actix.tls.private_key,
Path::new(<span class="string">&quot;path/to/cert/key.pem&quot;</span>)
Path::new(<span class="string">"path/to/cert/key.pem"</span>)
);
std::env::set_var(
<span class="string">&quot;OVERRIDE__TLS_PRIVATE_KEY&quot;</span>,
<span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>,
<span class="string">"OVERRIDE__TLS_PRIVATE_KEY"</span>,
<span class="string">"/overridden/path/to/cert/key.pem"</span>,
);
Settings::override_field_with_env_var(
<span class="kw-2">&amp;mut </span>settings.actix.tls.private_key,
<span class="string">&quot;OVERRIDE__TLS_PRIVATE_KEY&quot;</span>,
<span class="string">"OVERRIDE__TLS_PRIVATE_KEY"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.actix.tls.private_key,
Path::new(<span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>)
Path::new(<span class="string">"/overridden/path/to/cert/key.pem"</span>)
);
}
@@ -1593,7 +1593,7 @@
}
<span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = <span class="string">&quot;kebab-case&quot;</span>)]
#[serde(rename_all = <span class="string">"kebab-case"</span>)]
</span><span class="kw">struct </span>AppSettings {
example_name: String,
nested_field: NestedSetting,
@@ -1604,17 +1604,17 @@
<span class="kw">let </span><span class="kw-2">mut </span>settings = CustomSettings::from_template(
<span class="kw-2">&amp;</span>(CustomSettings::DEFAULT_TOML_TEMPLATE.to_string()
<span class="comment">// NOTE: Add these entries to the `[application]` table:
</span>+ <span class="string">&quot;\nexample-name = \&quot;example value\&quot;&quot;
</span>+ <span class="string">&quot;\nnested-field = { foo = \&quot;foo\&quot;, bar = false }&quot;</span>),
</span>+ <span class="string">"\nexample-name = \"example value\""
</span>+ <span class="string">"\nnested-field = { foo = \"foo\", bar = false }"</span>),
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.application,
AppSettings {
example_name: <span class="string">&quot;example value&quot;</span>.into(),
example_name: <span class="string">"example value"</span>.into(),
nested_field: NestedSetting {
foo: <span class="string">&quot;foo&quot;</span>.into(),
foo: <span class="string">"foo"</span>.into(),
bar: <span class="bool-val">false</span>,
},
}
@@ -1622,16 +1622,16 @@
CustomSettings::override_field(
<span class="kw-2">&amp;mut </span>settings.application.example_name,
<span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>,
<span class="string">"/overridden/path/to/cert/key.pem"</span>,
)
.unwrap();
<span class="macro">assert_eq!</span>(
settings.application,
AppSettings {
example_name: <span class="string">&quot;/overridden/path/to/cert/key.pem&quot;</span>.into(),
example_name: <span class="string">"/overridden/path/to/cert/key.pem"</span>.into(),
nested_field: NestedSetting {
foo: <span class="string">&quot;foo&quot;</span>.into(),
foo: <span class="string">"foo"</span>.into(),
bar: <span class="bool-val">false</span>,
},
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/parse.rs`."><title>parse.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/parse.rs`."><title>parse.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/address.rs`."><title>address.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/address.rs`."><title>address.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -99,35 +99,35 @@
<span class="kw">static </span>ADDR_REGEX: Lazy&lt;Regex&gt; = Lazy::new(|| {
Regex::new(
<span class="string">r#&quot;(?x)
<span class="string">r#"(?x)
\[ # opening square bracket
(\s)* # optional whitespace
&quot;(?P&lt;host&gt;[^&quot;]+)&quot; # host name (string)
"(?P&lt;host&gt;[^"]+)" # host name (string)
, # separating comma
(\s)* # optional whitespace
(?P&lt;port&gt;\d+) # port number (integer)
(\s)* # optional whitespace
\] # closing square bracket
&quot;#</span>,
"#</span>,
)
.expect(<span class="string">&quot;Failed to compile regex: ADDR_REGEX&quot;</span>)
.expect(<span class="string">"Failed to compile regex: ADDR_REGEX"</span>)
});
<span class="kw">static </span>ADDR_LIST_REGEX: Lazy&lt;Regex&gt; = Lazy::new(|| {
Regex::new(
<span class="string">r#&quot;(?x)
<span class="string">r#"(?x)
\[ # opening square bracket (list)
(\s)* # optional whitespace
(?P&lt;elements&gt;(
\[&quot;.*&quot;, (\s)* \d+\] # element
\[".*", (\s)* \d+\] # element
(,)? # element separator
(\s)* # optional whitespace
)*)
(\s)* # optional whitespace
\] # closing square bracket (list)
&quot;#</span>,
"#</span>,
)
.expect(<span class="string">&quot;Failed to compile regex: ADDRS_REGEX&quot;</span>)
.expect(<span class="string">"Failed to compile regex: ADDRS_REGEX"</span>)
});
<span class="doccomment">/// A host/port pair for the server to bind to.
@@ -144,9 +144,9 @@
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, Error&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>items = string
.trim()
.trim_start_matches(<span class="string">&#39;[&#39;</span>)
.trim_end_matches(<span class="string">&#39;]&#39;</span>)
.split(<span class="string">&#39;,&#39;</span>);
.trim_start_matches(<span class="string">'['</span>)
.trim_end_matches(<span class="string">']'</span>)
.split(<span class="string">','</span>);
<span class="kw">let </span>parse_error = || Error::ParseAddressError(string.to_string());
@@ -172,11 +172,11 @@
<span class="kw">let </span><span class="kw-2">mut </span>addrs = <span class="macro">vec!</span>[];
<span class="kw">for </span>list_caps <span class="kw">in </span>ADDR_LIST_REGEX.captures_iter(string) {
<span class="kw">let </span>elements = <span class="kw-2">&amp;</span>list_caps[<span class="string">&quot;elements&quot;</span>].trim();
<span class="kw">let </span>elements = <span class="kw-2">&amp;</span>list_caps[<span class="string">"elements"</span>].trim();
<span class="kw">for </span>elt_caps <span class="kw">in </span>ADDR_REGEX.captures_iter(elements) {
addrs.push(Address {
host: elt_caps[<span class="string">&quot;host&quot;</span>].to_string(),
port: elt_caps[<span class="string">&quot;port&quot;</span>].parse()<span class="question-mark">?</span>,
host: elt_caps[<span class="string">"host"</span>].to_string(),
port: elt_caps[<span class="string">"port"</span>].parse()<span class="question-mark">?</span>,
});
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/backlog.rs`."><title>backlog.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/backlog.rs`."><title>backlog.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -81,7 +81,7 @@
/// under significant load.
///
/// Generally set in the 642048 range. The default value is 2048. Takes a string value: Either
/// &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.
/// "default", or an integer N &gt; 0 e.g. "6".
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash)]
</span><span class="kw">pub enum </span>Backlog {
<span class="doccomment">/// The default number of connections. See struct docs.
@@ -94,11 +94,11 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>Backlog {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(Backlog::Default),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(Backlog::Default),
string =&gt; <span class="kw">match </span>string.parse::&lt;usize&gt;() {
<span class="prelude-val">Ok</span>(val) =&gt; <span class="prelude-val">Ok</span>(Backlog::Manual(val)),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;an integer &gt; 0&quot;</span>,
expected: <span class="string">"an integer &gt; 0"</span>,
got: string,
}),
},
@@ -106,18 +106,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>Backlog {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>Backlog {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>BacklogVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>BacklogVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>BacklogVisitor {
<span class="kw">type </span>Value = Backlog;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot; or a string containing an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\" or a string containing an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/keep_alive.rs`."><title>keep_alive.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/keep_alive.rs`."><title>keep_alive.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -103,8 +103,8 @@
<span class="doccomment">/// The server keep-alive preference.
///
/// By default keep alive is set to 5 seconds. Takes a string value: Either &quot;default&quot;, &quot;disabled&quot;,
/// &quot;os&quot;, or a string of the format &quot;N seconds&quot; where N is an integer &gt; 0 e.g. &quot;6 seconds&quot;.
/// By default keep alive is set to 5 seconds. Takes a string value: Either "default", "disabled",
/// "os", or a string of the format "N seconds" where N is an integer &gt; 0 e.g. "6 seconds".
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash)]
</span><span class="kw">pub enum </span>KeepAlive {
<span class="doccomment">/// The default keep-alive as defined by Actix Web.
@@ -125,25 +125,25 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>KeepAlive {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">static </span>FMT: Lazy&lt;Regex&gt; =
Lazy::new(|| Regex::new(<span class="string">r&quot;^\d+ seconds$&quot;</span>).expect(<span class="string">&quot;Failed to compile regex: FMT&quot;</span>));
Lazy::new(|| Regex::new(<span class="string">r"^\d+ seconds$"</span>).expect(<span class="string">"Failed to compile regex: FMT"</span>));
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">static </span>DIGITS: Lazy&lt;Regex&gt; =
Lazy::new(|| Regex::new(<span class="string">r&quot;^\d+&quot;</span>).expect(<span class="string">&quot;Failed to compile regex: FMT&quot;</span>));
Lazy::new(|| Regex::new(<span class="string">r"^\d+"</span>).expect(<span class="string">"Failed to compile regex: FMT"</span>));
<span class="macro">macro_rules! </span>invalid_value {
(<span class="macro-nonterminal">$got</span>:expr) =&gt; {
<span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;a string of the format \&quot;N seconds\&quot; where N is an integer &gt; 0&quot;</span>,
expected: <span class="string">"a string of the format \"N seconds\" where N is an integer &gt; 0"</span>,
got: <span class="macro-nonterminal">$got</span>,
})
};
}
<span class="kw">let </span>digits_in = |m: regex::Match&lt;<span class="lifetime">&#39;_</span>&gt;| <span class="kw-2">&amp;</span>string[m.start()..m.end()];
<span class="kw">let </span>digits_in = |m: regex::Match&lt;<span class="lifetime">'_</span>&gt;| <span class="kw-2">&amp;</span>string[m.start()..m.end()];
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Default),
<span class="string">&quot;disabled&quot; </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Disabled),
<span class="string">&quot;OS&quot; </span>| <span class="string">&quot;os&quot; </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Os),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Default),
<span class="string">"disabled" </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Disabled),
<span class="string">"OS" </span>| <span class="string">"os" </span>=&gt; <span class="prelude-val">Ok</span>(KeepAlive::Os),
string <span class="kw">if </span>!FMT.is_match(string) =&gt; <span class="macro">invalid_value!</span>(string),
string =&gt; <span class="kw">match </span>DIGITS.find(string) {
<span class="prelude-val">None </span>=&gt; <span class="macro">invalid_value!</span>(string),
@@ -156,18 +156,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>KeepAlive {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>KeepAlive {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>KeepAliveVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>KeepAliveVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>KeepAliveVisitor {
<span class="kw">type </span>Value = KeepAlive;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot;, \&quot;disabled\&quot;, \&quot;os\&quot;, or a string of the format \&quot;N seconds\&quot; where N is an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\", \"disabled\", \"os\", or a string of the format \"N seconds\" where N is an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/max_connection_rate.rs`."><title>max_connection_rate.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/max_connection_rate.rs`."><title>max_connection_rate.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -75,7 +75,7 @@
///
/// All listeners will stop accepting connections when this limit is reached. It can be used to
/// limit the global TLS CPU usage. By default max connections is set to a 256. Takes a string
/// value: Either &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.
/// value: Either "default", or an integer N &gt; 0 e.g. "6".
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash)]
</span><span class="kw">pub enum </span>MaxConnectionRate {
<span class="doccomment">/// The default connection limit. See struct docs.
@@ -88,11 +88,11 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>MaxConnectionRate {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(MaxConnectionRate::Default),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(MaxConnectionRate::Default),
string =&gt; <span class="kw">match </span>string.parse::&lt;usize&gt;() {
<span class="prelude-val">Ok</span>(val) =&gt; <span class="prelude-val">Ok</span>(MaxConnectionRate::Manual(val)),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;an integer &gt; 0&quot;</span>,
expected: <span class="string">"an integer &gt; 0"</span>,
got: string,
}),
},
@@ -100,18 +100,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>MaxConnectionRate {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>MaxConnectionRate {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>MaxConnectionRateVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>MaxConnectionRateVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>MaxConnectionRateVisitor {
<span class="kw">type </span>Value = MaxConnectionRate;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot; or a string containing an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\" or a string containing an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/max_connections.rs`."><title>max_connections.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/max_connections.rs`."><title>max_connections.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -74,8 +74,8 @@
<span class="doccomment">/// The maximum per-worker number of concurrent connections.
///
/// All socket listeners will stop accepting connections when this limit is reached for each worker.
/// By default max connections is set to a 25k. Takes a string value: Either &quot;default&quot;, or an
/// integer N &gt; 0 e.g. &quot;6&quot;.
/// By default max connections is set to a 25k. Takes a string value: Either "default", or an
/// integer N &gt; 0 e.g. "6".
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash)]
</span><span class="kw">pub enum </span>MaxConnections {
<span class="doccomment">/// The default number of connections. See struct docs.
@@ -88,11 +88,11 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>MaxConnections {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(MaxConnections::Default),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(MaxConnections::Default),
string =&gt; <span class="kw">match </span>string.parse::&lt;usize&gt;() {
<span class="prelude-val">Ok</span>(val) =&gt; <span class="prelude-val">Ok</span>(MaxConnections::Manual(val)),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;an integer &gt; 0&quot;</span>,
expected: <span class="string">"an integer &gt; 0"</span>,
got: string,
}),
},
@@ -100,18 +100,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>MaxConnections {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>MaxConnections {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>MaxConnectionsVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>MaxConnectionsVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>MaxConnectionsVisitor {
<span class="kw">type </span>Value = MaxConnections;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot; or a string containing an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\" or a string containing an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -79,7 +79,7 @@
<span class="doccomment">/// Settings types for Actix Web.
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(rename_all = <span class="string">&quot;kebab-case&quot;</span>)]
#[serde(rename_all = <span class="string">"kebab-case"</span>)]
</span><span class="kw">pub struct </span>ActixSettings {
<span class="doccomment">/// List of addresses for the server to bind to.
</span><span class="kw">pub </span>hosts: Vec&lt;Address&gt;,

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/mode.rs`."><title>mode.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/mode.rs`."><title>mode.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -31,7 +31,7 @@
<span class="doccomment">/// Marker of intended deployment environment.
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(rename_all = <span class="string">&quot;lowercase&quot;</span>)]
#[serde(rename_all = <span class="string">"lowercase"</span>)]
</span><span class="kw">pub enum </span>Mode {
<span class="doccomment">/// Marks development environment.
</span>Development,
@@ -43,10 +43,10 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>Mode {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">match </span>string {
<span class="string">&quot;development&quot; </span>=&gt; <span class="prelude-val">Ok</span>(<span class="self">Self</span>::Development),
<span class="string">&quot;production&quot; </span>=&gt; <span class="prelude-val">Ok</span>(<span class="self">Self</span>::Production),
<span class="string">"development" </span>=&gt; <span class="prelude-val">Ok</span>(<span class="self">Self</span>::Development),
<span class="string">"production" </span>=&gt; <span class="prelude-val">Ok</span>(<span class="self">Self</span>::Production),
<span class="kw">_ </span>=&gt; <span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;\&quot;development\&quot; | \&quot;production\&quot;.&quot;</span>,
expected: <span class="string">"\"development\" | \"production\"."</span>,
got: string,
}),
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/num_workers.rs`."><title>num_workers.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/num_workers.rs`."><title>num_workers.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -73,7 +73,7 @@
<span class="doccomment">/// The number of workers that the server should start.
///
/// By default the number of available logical cpu cores is used. Takes a string value: Either
/// &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.
/// "default", or an integer N &gt; 0 e.g. "6".
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash)]
</span><span class="kw">pub enum </span>NumWorkers {
<span class="doccomment">/// The default number of workers. See struct docs.
@@ -86,11 +86,11 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>NumWorkers {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(NumWorkers::Default),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(NumWorkers::Default),
string =&gt; <span class="kw">match </span>string.parse::&lt;usize&gt;() {
<span class="prelude-val">Ok</span>(val) =&gt; <span class="prelude-val">Ok</span>(NumWorkers::Manual(val)),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;a positive integer&quot;</span>,
expected: <span class="string">"a positive integer"</span>,
got: string,
}),
},
@@ -98,18 +98,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>NumWorkers {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>NumWorkers {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>NumWorkersVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>NumWorkersVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>NumWorkersVisitor {
<span class="kw">type </span>Value = NumWorkers;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot; or a string containing an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\" or a string containing an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/timeout.rs`."><title>timeout.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/timeout.rs`."><title>timeout.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -120,27 +120,27 @@
<span class="kw">impl </span>Parse <span class="kw">for </span>Timeout {
<span class="kw">fn </span>parse(string: <span class="kw-2">&amp;</span>str) -&gt; AsResult&lt;<span class="self">Self</span>&gt; {
<span class="kw">pub static </span>FMT: Lazy&lt;Regex&gt; = Lazy::new(|| {
Regex::new(<span class="string">r&quot;^\d+ (milliseconds|seconds)$&quot;</span>).expect(<span class="string">&quot;Failed to compile regex: FMT&quot;</span>)
Regex::new(<span class="string">r"^\d+ (milliseconds|seconds)$"</span>).expect(<span class="string">"Failed to compile regex: FMT"</span>)
});
<span class="kw">pub static </span>DIGITS: Lazy&lt;Regex&gt; =
Lazy::new(|| Regex::new(<span class="string">r&quot;^\d+&quot;</span>).expect(<span class="string">&quot;Failed to compile regex: DIGITS&quot;</span>));
Lazy::new(|| Regex::new(<span class="string">r"^\d+"</span>).expect(<span class="string">"Failed to compile regex: DIGITS"</span>));
<span class="kw">pub static </span>UNIT: Lazy&lt;Regex&gt; = Lazy::new(|| {
Regex::new(<span class="string">r&quot;(milliseconds|seconds)$&quot;</span>).expect(<span class="string">&quot;Failed to compile regex: UNIT&quot;</span>)
Regex::new(<span class="string">r"(milliseconds|seconds)$"</span>).expect(<span class="string">"Failed to compile regex: UNIT"</span>)
});
<span class="macro">macro_rules! </span>invalid_value {
(<span class="macro-nonterminal">$got</span>:expr) =&gt; {
<span class="prelude-val">Err</span>(<span class="macro">InvalidValue! </span>{
expected: <span class="string">&quot;a string of the format \&quot;N seconds\&quot; or \&quot;N milliseconds\&quot; where N is an integer &gt; 0&quot;</span>,
expected: <span class="string">"a string of the format \"N seconds\" or \"N milliseconds\" where N is an integer &gt; 0"</span>,
got: <span class="macro-nonterminal">$got</span>,
})
}
}
<span class="kw">match </span>string {
<span class="string">&quot;default&quot; </span>=&gt; <span class="prelude-val">Ok</span>(Timeout::Default),
<span class="string">"default" </span>=&gt; <span class="prelude-val">Ok</span>(Timeout::Default),
string <span class="kw">if </span>!FMT.is_match(string) =&gt; <span class="macro">invalid_value!</span>(string),
@@ -152,8 +152,8 @@
<span class="kw">let </span>unit = <span class="kw-2">&amp;</span>string[unit.range()];
<span class="kw">match </span>(digits.parse(), unit) {
(<span class="prelude-val">Ok</span>(n), <span class="string">&quot;milliseconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(Timeout::Milliseconds(n)),
(<span class="prelude-val">Ok</span>(n), <span class="string">&quot;seconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(Timeout::Seconds(n)),
(<span class="prelude-val">Ok</span>(n), <span class="string">"milliseconds"</span>) =&gt; <span class="prelude-val">Ok</span>(Timeout::Milliseconds(n)),
(<span class="prelude-val">Ok</span>(n), <span class="string">"seconds"</span>) =&gt; <span class="prelude-val">Ok</span>(Timeout::Seconds(n)),
<span class="kw">_ </span>=&gt; <span class="macro">invalid_value!</span>(string),
}
}
@@ -162,18 +162,18 @@
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Deserialize&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>Timeout {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Deserialize&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>Timeout {
<span class="kw">fn </span>deserialize&lt;D&gt;(deserializer: D) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, D::Error&gt;
<span class="kw">where
</span>D: de::Deserializer&lt;<span class="lifetime">&#39;de</span>&gt;,
</span>D: de::Deserializer&lt;<span class="lifetime">'de</span>&gt;,
{
<span class="kw">struct </span>TimeoutVisitor;
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;de</span>&gt; de::Visitor&lt;<span class="lifetime">&#39;de</span>&gt; <span class="kw">for </span>TimeoutVisitor {
<span class="kw">impl</span>&lt;<span class="lifetime">'de</span>&gt; de::Visitor&lt;<span class="lifetime">'de</span>&gt; <span class="kw">for </span>TimeoutVisitor {
<span class="kw">type </span>Value = Timeout;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">&quot;Either \&quot;default\&quot;, \&quot;disabled\&quot;, \&quot;os\&quot;, or a string of the format \&quot;N seconds\&quot; where N is an integer &gt; 0&quot;</span>;
<span class="kw">fn </span>expecting(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">let </span>msg = <span class="string">"Either \"default\", \"disabled\", \"os\", or a string of the format \"N seconds\" where N is an integer &gt; 0"</span>;
f.write_str(msg)
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-settings/src/settings/tls.rs`."><title>tls.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-settings/src/settings/tls.rs`."><title>tls.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_settings" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_settings/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_settings"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -22,8 +22,8 @@
<span class="doccomment">/// TLS (HTTPS) configuration.
</span><span class="attr">#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(rename_all = <span class="string">&quot;kebab-case&quot;</span>)]
#[doc(alias = <span class="string">&quot;ssl&quot;</span>, alias = <span class="string">&quot;https&quot;</span>)]
#[serde(rename_all = <span class="string">"kebab-case"</span>)]
#[doc(alias = <span class="string">"ssl"</span>, alias = <span class="string">"https"</span>)]
</span><span class="kw">pub struct </span>Tls {
<span class="doccomment">/// Tru if accepting TLS connections should be enabled.
</span><span class="kw">pub </span>enabled: bool,

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -116,7 +116,7 @@
<a href="#116" id="116">116</a>
<a href="#117" id="117">117</a>
<a href="#118" id="118">118</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Basic&quot; HTTP Authentication Scheme.
</pre></div><pre class="rust"><code><span class="doccomment">//! Extractor for the "Basic" HTTP Authentication Scheme.
</span><span class="kw">use </span>std::borrow::Cow;
@@ -138,11 +138,11 @@
<span class="kw">impl </span>Config {
<span class="doccomment">/// Set challenge `realm` attribute.
///
/// The &quot;realm&quot; attribute indicates the scope of protection in the manner described in HTTP/1.1
/// The "realm" attribute indicates the scope of protection in the manner described in HTTP/1.1
/// [RFC 2617 §1.2](https://tools.ietf.org/html/rfc2617#section-1.2).
</span><span class="kw">pub fn </span>realm&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; Config
<span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.<span class="number">0</span>.realm = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
@@ -170,7 +170,7 @@
/// use actix_web_httpauth::extractors::basic::BasicAuth;
///
/// async fn index(auth: BasicAuth) -&gt; String {
/// format!(&quot;Hello, {}!&quot;, auth.user_id())
/// format!("Hello, {}!", auth.user_id())
/// }
/// ```
///
@@ -183,12 +183,12 @@
/// use actix_web_httpauth::extractors::basic::{self, BasicAuth};
///
/// async fn index(auth: BasicAuth) -&gt; String {
/// format!(&quot;Hello, {}!&quot;, auth.user_id())
/// format!("Hello, {}!", auth.user_id())
/// }
///
/// App::new()
/// .app_data(basic::Config::default().realm(&quot;Restricted area&quot;))
/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));
/// .app_data(basic::Config::default().realm("Restricted area"))
/// .service(web::resource("/index.html").route(web::get().to(index)));
/// ```
///
/// [app data]: https://docs.rs/actix-web/4/actix_web/struct.App.html#method.app_data
@@ -196,12 +196,12 @@
</span><span class="kw">pub struct </span>BasicAuth(Basic);
<span class="kw">impl </span>BasicAuth {
<span class="doccomment">/// Returns client&#39;s user-ID.
<span class="doccomment">/// Returns client's user-ID.
</span><span class="kw">pub fn </span>user_id(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>str {
<span class="self">self</span>.<span class="number">0</span>.user_id()
}
<span class="doccomment">/// Returns client&#39;s password.
<span class="doccomment">/// Returns client's password.
</span><span class="kw">pub fn </span>password(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>str&gt; {
<span class="self">self</span>.<span class="number">0</span>.password()
}
@@ -222,7 +222,7 @@
Authorization::&lt;Basic&gt;::parse(req)
.map(|auth| BasicAuth(auth.into_scheme()))
.map_err(|err| {
<span class="macro">log::debug!</span>(<span class="string">&quot;`BasicAuth` extract error: {}&quot;</span>, err);
<span class="macro">log::debug!</span>(<span class="string">"`BasicAuth` extract error: {}"</span>, err);
<span class="kw">let </span>challenge = req
.app_data::&lt;Config&gt;()

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/bearer.rs`."><title>bearer.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/bearer.rs`."><title>bearer.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -142,7 +142,7 @@
<a href="#142" id="142">142</a>
<a href="#143" id="143">143</a>
<a href="#144" id="144">144</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Extractor for the &quot;Bearer&quot; HTTP Authentication Scheme.
</pre></div><pre class="rust"><code><span class="doccomment">//! Extractor for the "Bearer" HTTP Authentication Scheme.
</span><span class="kw">use </span>std::{borrow::Cow, default::Default};
@@ -160,19 +160,19 @@
<span class="kw">impl </span>Config {
<span class="doccomment">/// Set challenge `scope` attribute.
///
/// The `&quot;scope&quot;` attribute is a space-delimited list of case-sensitive
/// The `"scope"` attribute is a space-delimited list of case-sensitive
/// scope values indicating the required scope of the access token for
/// accessing the requested resource.
</span><span class="kw">pub fn </span>scope&lt;T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; Config {
</span><span class="kw">pub fn </span>scope&lt;T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; Config {
<span class="self">self</span>.<span class="number">0</span>.scope = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
</span>}
<span class="doccomment">/// Set challenge `realm` attribute.
///
/// The &quot;realm&quot; attribute indicates the scope of protection in the manner
/// The "realm" attribute indicates the scope of protection in the manner
/// described in HTTP/1.1 [RFC 2617](https://tools.ietf.org/html/rfc2617#section-1.2).
</span><span class="kw">pub fn </span>realm&lt;T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; Config {
</span><span class="kw">pub fn </span>realm&lt;T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; Config {
<span class="self">self</span>.<span class="number">0</span>.realm = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
</span>}
@@ -199,7 +199,7 @@
/// use actix_web_httpauth::extractors::bearer::BearerAuth;
///
/// async fn index(auth: BearerAuth) -&gt; String {
/// format!(&quot;Hello, user with token {}!&quot;, auth.token())
/// format!("Hello, user with token {}!", auth.token())
/// }
/// ```
///
@@ -213,16 +213,16 @@
/// use actix_web_httpauth::extractors::bearer::{self, BearerAuth};
///
/// async fn index(auth: BearerAuth) -&gt; String {
/// format!(&quot;Hello, {}!&quot;, auth.token())
/// format!("Hello, {}!", auth.token())
/// }
///
/// App::new()
/// .app_data(
/// bearer::Config::default()
/// .realm(&quot;Restricted area&quot;)
/// .scope(&quot;email photo&quot;),
/// .realm("Restricted area")
/// .scope("email photo"),
/// )
/// .service(web::resource(&quot;/index.html&quot;).route(web::get().to(index)));
/// .service(web::resource("/index.html").route(web::get().to(index)));
/// ```
</span><span class="attr">#[derive(Debug, Clone)]
</span><span class="kw">pub struct </span>BearerAuth(authorization::Bearer);
@@ -269,7 +269,7 @@
<span class="doccomment">/// Attach error description to the current Authentication error.
</span><span class="kw">pub fn </span>with_error_description&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, desc: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.challenge_mut().error_description = <span class="prelude-val">Some</span>(desc.into());
<span class="self">self
@@ -280,7 +280,7 @@
/// It is up to implementor to provide properly formed absolute URI.
</span><span class="kw">pub fn </span>with_error_uri&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, uri: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.challenge_mut().error_uri = <span class="prelude-val">Some</span>(uri.into());
<span class="self">self

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/config.rs`."><title>config.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -119,14 +119,14 @@
}
<span class="kw">impl</span>&lt;C: Challenge&gt; fmt::Display <span class="kw">for </span>AuthenticationError&lt;C&gt; {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
fmt::Display::fmt(<span class="kw-2">&amp;</span><span class="self">self</span>.status_code, f)
}
}
<span class="kw">impl</span>&lt;C: Challenge + <span class="lifetime">&#39;static</span>&gt; Error <span class="kw">for </span>AuthenticationError&lt;C&gt; {}
<span class="kw">impl</span>&lt;C: Challenge + <span class="lifetime">'static</span>&gt; Error <span class="kw">for </span>AuthenticationError&lt;C&gt; {}
<span class="kw">impl</span>&lt;C: Challenge + <span class="lifetime">&#39;static</span>&gt; ResponseError <span class="kw">for </span>AuthenticationError&lt;C&gt; {
<span class="kw">impl</span>&lt;C: Challenge + <span class="lifetime">'static</span>&gt; ResponseError <span class="kw">for </span>AuthenticationError&lt;C&gt; {
<span class="kw">fn </span>status_code(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; StatusCode {
<span class="self">self</span>.status_code
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/extractors/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -87,7 +87,7 @@
</span>MissingScheme,
<span class="doccomment">/// Required authentication field is missing.
</span>MissingField(<span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str),
</span>MissingField(<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str),
<span class="doccomment">/// Unable to convert header into the str.
</span>ToStrError(header::ToStrError),
@@ -100,11 +100,11 @@
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>ParseError {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
<span class="kw">match </span><span class="self">self </span>{
ParseError::Invalid =&gt; f.write_str(<span class="string">&quot;Invalid header value&quot;</span>),
ParseError::MissingScheme =&gt; f.write_str(<span class="string">&quot;Missing authorization scheme&quot;</span>),
ParseError::MissingField(field) =&gt; <span class="macro">write!</span>(f, <span class="string">&quot;Missing header field ({field})&quot;</span>),
ParseError::Invalid =&gt; f.write_str(<span class="string">"Invalid header value"</span>),
ParseError::MissingScheme =&gt; f.write_str(<span class="string">"Missing authorization scheme"</span>),
ParseError::MissingField(field) =&gt; <span class="macro">write!</span>(f, <span class="string">"Missing header field ({field})"</span>),
ParseError::ToStrError(err) =&gt; fmt::Display::fmt(err, f),
ParseError::Base64DecodeError(err) =&gt; fmt::Display::fmt(err, f),
ParseError::Utf8Error(err) =&gt; fmt::Display::fmt(err, f),
@@ -113,7 +113,7 @@
}
<span class="kw">impl </span>Error <span class="kw">for </span>ParseError {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>Error + <span class="lifetime">&#39;static</span>)&gt; {
<span class="kw">fn </span>source(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>(<span class="kw">dyn </span>Error + <span class="lifetime">'static</span>)&gt; {
<span class="kw">match </span><span class="self">self </span>{
ParseError::Invalid =&gt; <span class="prelude-val">None</span>,
ParseError::MissingScheme =&gt; <span class="prelude-val">None</span>,

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/header.rs`."><title>header.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/header.rs`."><title>header.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -94,7 +94,7 @@
<span class="doccomment">/// `Authorization` header, defined in [RFC 7235](https://tools.ietf.org/html/rfc7235#section-4.2)
///
/// The &quot;Authorization&quot; header field allows a user agent to authenticate itself with an origin
/// The "Authorization" header field allows a user agent to authenticate itself with an origin
/// server—usually, but not necessarily, after receiving a 401 (Unauthorized) response. Its value
/// consists of credentials containing the authentication information of the user agent for the
/// realm of the resource being requested.
@@ -108,7 +108,7 @@
/// fn handler(req: HttpRequest) -&gt; Result&lt;String&gt; {
/// let auth = Authorization::&lt;Basic&gt;::parse(&amp;req)?;
///
/// Ok(format!(&quot;Hello, {}!&quot;, auth.as_ref().user_id()))
/// Ok(format!("Hello, {}!", auth.as_ref().user_id()))
/// }
/// ```
</span><span class="attr">#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -140,7 +140,7 @@
}
<span class="kw">impl</span>&lt;S: Scheme&gt; fmt::Display <span class="kw">for </span>Authorization&lt;S&gt; {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
fmt::Display::fmt(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>, f)
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -205,8 +205,8 @@
<span class="doccomment">/// Credentials for `Basic` authentication scheme, defined in [RFC 7617](https://tools.ietf.org/html/rfc7617)
</span><span class="attr">#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
</span><span class="kw">pub struct </span>Basic {
user_id: Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;,
password: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
user_id: Cow&lt;<span class="lifetime">'static</span>, str&gt;,
password: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
}
<span class="kw">impl </span>Basic {
@@ -216,12 +216,12 @@
/// # Examples
/// ```
/// # use actix_web_httpauth::headers::authorization::Basic;
/// let credentials = Basic::new(&quot;Alladin&quot;, Some(&quot;open sesame&quot;));
/// let credentials = Basic::new("Alladin", Some("open sesame"));
/// ```
</span><span class="kw">pub fn </span>new&lt;U, P&gt;(user_id: U, password: <span class="prelude-ty">Option</span>&lt;P&gt;) -&gt; Basic
<span class="kw">where
</span>U: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
P: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>U: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
P: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
Basic {
user_id: user_id.into(),
@@ -229,12 +229,12 @@
}
}
<span class="doccomment">/// Returns client&#39;s user-ID.
<span class="doccomment">/// Returns client's user-ID.
</span><span class="kw">pub fn </span>user_id(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>str {
<span class="self">self</span>.user_id.as_ref()
}
<span class="doccomment">/// Returns client&#39;s password if provided.
<span class="doccomment">/// Returns client's password if provided.
</span><span class="kw">pub fn </span>password(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>str&gt; {
<span class="self">self</span>.password.as_deref()
}
@@ -242,28 +242,28 @@
<span class="kw">impl </span>Scheme <span class="kw">for </span>Basic {
<span class="kw">fn </span>parse(header: <span class="kw-2">&amp;</span>HeaderValue) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, ParseError&gt; {
<span class="comment">// &quot;Basic *&quot; length
<span class="comment">// "Basic *" length
</span><span class="kw">if </span>header.len() &lt; <span class="number">7 </span>{
<span class="kw">return </span><span class="prelude-val">Err</span>(ParseError::Invalid);
}
<span class="kw">let </span><span class="kw-2">mut </span>parts = header.to_str()<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">&#39; &#39;</span>);
<span class="kw">let </span><span class="kw-2">mut </span>parts = header.to_str()<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">' '</span>);
<span class="kw">match </span>parts.next() {
<span class="prelude-val">Some</span>(<span class="string">&quot;Basic&quot;</span>) =&gt; (),
<span class="prelude-val">Some</span>(<span class="string">"Basic"</span>) =&gt; (),
<span class="kw">_ </span>=&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(ParseError::MissingScheme),
}
<span class="kw">let </span>decoded = BASE64_STANDARD.decode(parts.next().ok_or(ParseError::Invalid)<span class="question-mark">?</span>)<span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>credentials = str::from_utf8(<span class="kw-2">&amp;</span>decoded)<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">&#39;:&#39;</span>);
<span class="kw">let </span><span class="kw-2">mut </span>credentials = str::from_utf8(<span class="kw-2">&amp;</span>decoded)<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">':'</span>);
<span class="kw">let </span>user_id = credentials
.next()
.ok_or(ParseError::MissingField(<span class="string">&quot;user_id&quot;</span>))
.ok_or(ParseError::MissingField(<span class="string">"user_id"</span>))
.map(|user_id| user_id.to_string().into())<span class="question-mark">?</span>;
<span class="kw">let </span>password = credentials
.next()
.ok_or(ParseError::MissingField(<span class="string">&quot;password&quot;</span>))
.ok_or(ParseError::MissingField(<span class="string">"password"</span>))
.map(|password| {
<span class="kw">if </span>password.is_empty() {
<span class="prelude-val">None
@@ -277,14 +277,14 @@
}
<span class="kw">impl </span>fmt::Debug <span class="kw">for </span>Basic {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">&quot;Basic {}:******&quot;</span>, <span class="self">self</span>.user_id))
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">"Basic {}:******"</span>, <span class="self">self</span>.user_id))
}
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>Basic {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">&quot;Basic {}:******&quot;</span>, <span class="self">self</span>.user_id))
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">"Basic {}:******"</span>, <span class="self">self</span>.user_id))
}
}
@@ -301,12 +301,12 @@
<span class="kw">let </span><span class="kw-2">mut </span>credentials = BytesMut::with_capacity(credential_length);
credentials.extend_from_slice(<span class="self">self</span>.user_id.as_bytes());
credentials.put_u8(<span class="string">b&#39;:&#39;</span>);
credentials.put_u8(<span class="string">b':'</span>);
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>password) = <span class="self">self</span>.password {
credentials.extend_from_slice(password.as_bytes());
}
value.push_str(<span class="string">&quot;Basic &quot;</span>);
value.push_str(<span class="string">"Basic "</span>);
BASE64_STANDARD.encode_string(<span class="kw-2">&amp;</span>credentials, <span class="kw-2">&amp;mut </span>value);
HeaderValue::from_maybe_shared(value)
@@ -319,29 +319,29 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_parse_header() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_ok());
<span class="kw">let </span>scheme = scheme.unwrap();
<span class="macro">assert_eq!</span>(scheme.user_id, <span class="string">&quot;Aladdin&quot;</span>);
<span class="macro">assert_eq!</span>(scheme.password, <span class="prelude-val">Some</span>(<span class="string">&quot;open sesame&quot;</span>.into()));
<span class="macro">assert_eq!</span>(scheme.user_id, <span class="string">"Aladdin"</span>);
<span class="macro">assert_eq!</span>(scheme.password, <span class="prelude-val">Some</span>(<span class="string">"open sesame"</span>.into()));
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_empty_password() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Basic QWxhZGRpbjo=&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Basic QWxhZGRpbjo="</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_ok());
<span class="kw">let </span>scheme = scheme.unwrap();
<span class="macro">assert_eq!</span>(scheme.user_id, <span class="string">&quot;Aladdin&quot;</span>);
<span class="macro">assert_eq!</span>(scheme.user_id, <span class="string">"Aladdin"</span>);
<span class="macro">assert_eq!</span>(scheme.password, <span class="prelude-val">None</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_empty_header() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">""</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -349,7 +349,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_wrong_scheme() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;THOUSHALLNOTPASS please?&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"THOUSHALLNOTPASS please?"</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -357,7 +357,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_missing_credentials() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Basic &quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Basic "</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -365,7 +365,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_missing_credentials_colon() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Basic QWxsYWRpbg==&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Basic QWxsYWRpbg=="</span>);
<span class="kw">let </span>scheme = Basic::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -374,15 +374,15 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_into_header_value() {
<span class="kw">let </span>basic = Basic {
user_id: <span class="string">&quot;Aladdin&quot;</span>.into(),
password: <span class="prelude-val">Some</span>(<span class="string">&quot;open sesame&quot;</span>.into()),
user_id: <span class="string">"Aladdin"</span>.into(),
password: <span class="prelude-val">Some</span>(<span class="string">"open sesame"</span>.into()),
};
<span class="kw">let </span>result = basic.try_into_value();
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(
result.unwrap(),
HeaderValue::from_static(<span class="string">&quot;Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==&quot;</span>)
HeaderValue::from_static(<span class="string">"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="</span>)
);
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/bearer.rs`."><title>bearer.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/bearer.rs`."><title>bearer.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -154,7 +154,7 @@
/// [`Authorization`]: crate::headers::authorization::Authorization
</span><span class="attr">#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
</span><span class="kw">pub struct </span>Bearer {
token: Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;,
token: Cow&lt;<span class="lifetime">'static</span>, str&gt;,
}
<span class="kw">impl </span>Bearer {
@@ -163,11 +163,11 @@
/// # Example
/// ```
/// # use actix_web_httpauth::headers::authorization::Bearer;
/// let credentials = Bearer::new(&quot;mF_9.B5f-4.1JqM&quot;);
/// let credentials = Bearer::new("mF_9.B5f-4.1JqM");
/// ```
</span><span class="kw">pub fn </span>new&lt;T&gt;(token: T) -&gt; Bearer
<span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
Bearer {
token: token.into(),
@@ -182,15 +182,15 @@
<span class="kw">impl </span>Scheme <span class="kw">for </span>Bearer {
<span class="kw">fn </span>parse(header: <span class="kw-2">&amp;</span>HeaderValue) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, ParseError&gt; {
<span class="comment">// &quot;Bearer *&quot; length
<span class="comment">// "Bearer *" length
</span><span class="kw">if </span>header.len() &lt; <span class="number">8 </span>{
<span class="kw">return </span><span class="prelude-val">Err</span>(ParseError::Invalid);
}
<span class="kw">let </span><span class="kw-2">mut </span>parts = header.to_str()<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">&#39; &#39;</span>);
<span class="kw">let </span><span class="kw-2">mut </span>parts = header.to_str()<span class="question-mark">?</span>.splitn(<span class="number">2</span>, <span class="string">' '</span>);
<span class="kw">match </span>parts.next() {
<span class="prelude-val">Some</span>(<span class="string">&quot;Bearer&quot;</span>) =&gt; {}
<span class="prelude-val">Some</span>(<span class="string">"Bearer"</span>) =&gt; {}
<span class="kw">_ </span>=&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(ParseError::MissingScheme),
}
@@ -203,14 +203,14 @@
}
<span class="kw">impl </span>fmt::Debug <span class="kw">for </span>Bearer {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">&quot;Bearer ******&quot;</span>))
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">"Bearer ******"</span>))
}
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>Bearer {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">&quot;Bearer {}&quot;</span>, <span class="self">self</span>.token))
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_fmt(<span class="macro">format_args!</span>(<span class="string">"Bearer {}"</span>, <span class="self">self</span>.token))
}
}
@@ -219,7 +219,7 @@
<span class="kw">fn </span>try_into_value(<span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;HeaderValue, <span class="self">Self</span>::Error&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>buffer = BytesMut::with_capacity(<span class="number">7 </span>+ <span class="self">self</span>.token.len());
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot;Bearer &quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b"Bearer "</span>[..]);
buffer.extend_from_slice(<span class="self">self</span>.token.as_bytes());
HeaderValue::from_maybe_shared(buffer.freeze())
@@ -232,17 +232,17 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_parse_header() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Bearer mF_9.B5f-4.1JqM&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Bearer mF_9.B5f-4.1JqM"</span>);
<span class="kw">let </span>scheme = Bearer::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_ok());
<span class="kw">let </span>scheme = scheme.unwrap();
<span class="macro">assert_eq!</span>(scheme.token, <span class="string">&quot;mF_9.B5f-4.1JqM&quot;</span>);
<span class="macro">assert_eq!</span>(scheme.token, <span class="string">"mF_9.B5f-4.1JqM"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_empty_header() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">""</span>);
<span class="kw">let </span>scheme = Bearer::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -250,7 +250,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_wrong_scheme() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;OAuthToken foo&quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"OAuthToken foo"</span>);
<span class="kw">let </span>scheme = Bearer::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -258,7 +258,7 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_missing_token() {
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">&quot;Bearer &quot;</span>);
<span class="kw">let </span>value = HeaderValue::from_static(<span class="string">"Bearer "</span>);
<span class="kw">let </span>scheme = Bearer::parse(<span class="kw-2">&amp;</span>value);
<span class="macro">assert!</span>(scheme.is_err());
@@ -266,13 +266,13 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_into_header_value() {
<span class="kw">let </span>bearer = Bearer::new(<span class="string">&quot;mF_9.B5f-4.1JqM&quot;</span>);
<span class="kw">let </span>bearer = Bearer::new(<span class="string">"mF_9.B5f-4.1JqM"</span>);
<span class="kw">let </span>result = bearer.try_into_value();
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(
result.unwrap(),
HeaderValue::from_static(<span class="string">&quot;Bearer mF_9.B5f-4.1JqM&quot;</span>)
HeaderValue::from_static(<span class="string">"Bearer mF_9.B5f-4.1JqM"</span>)
);
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/authorization/scheme/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs`."><title>basic.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -134,7 +134,7 @@
<a href="#134" id="134">134</a>
<a href="#135" id="135">135</a>
<a href="#136" id="136">136</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Basic&quot; HTTP Authentication Scheme.
</pre></div><pre class="rust"><code><span class="doccomment">//! Challenge for the "Basic" HTTP Authentication Scheme.
</span><span class="kw">use </span>std::{borrow::Cow, fmt, str};
@@ -156,7 +156,7 @@
/// use actix_web_httpauth::headers::www_authenticate::WwwAuthenticate;
///
/// fn index(_req: HttpRequest) -&gt; HttpResponse {
/// let challenge = Basic::with_realm(&quot;Restricted area&quot;);
/// let challenge = Basic::with_realm("Restricted area");
///
/// HttpResponse::Unauthorized()
/// .insert_header(WwwAuthenticate(challenge))
@@ -167,8 +167,8 @@
/// [`WWW-Authenticate`]: ../struct.WwwAuthenticate.html
</span><span class="attr">#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Clone)]
</span><span class="kw">pub struct </span>Basic {
<span class="comment">// &quot;realm&quot; parameter is optional now: https://tools.ietf.org/html/rfc7235#appendix-A
</span><span class="kw">pub</span>(<span class="kw">crate</span>) realm: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
<span class="comment">// "realm" parameter is optional now: https://tools.ietf.org/html/rfc7235#appendix-A
</span><span class="kw">pub</span>(<span class="kw">crate</span>) realm: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
}
<span class="kw">impl </span>Basic {
@@ -189,17 +189,17 @@
///
/// ```
/// # use actix_web_httpauth::headers::www_authenticate::basic::Basic;
/// let challenge = Basic::with_realm(&quot;Restricted area&quot;);
/// let challenge = Basic::with_realm("Restricted area");
/// ```
///
/// ```
/// # use actix_web_httpauth::headers::www_authenticate::basic::Basic;
/// let my_realm = &quot;Earth realm&quot;.to_string();
/// let my_realm = "Earth realm".to_string();
/// let challenge = Basic::with_realm(my_realm);
/// ```
</span><span class="kw">pub fn </span>with_realm&lt;T&gt;(value: T) -&gt; Basic
<span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
Basic {
realm: <span class="prelude-val">Some</span>(value.into()),
@@ -210,14 +210,14 @@
<span class="attr">#[doc(hidden)]
</span><span class="kw">impl </span>Challenge <span class="kw">for </span>Basic {
<span class="kw">fn </span>to_bytes(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Bytes {
<span class="comment">// 5 is for `&quot;Basic&quot;`, 9 is for `&quot;realm=\&quot;\&quot;&quot;`
<span class="comment">// 5 is for `"Basic"`, 9 is for `"realm=\"\""`
</span><span class="kw">let </span>length = <span class="number">5 </span>+ <span class="self">self</span>.realm.as_ref().map_or(<span class="number">0</span>, |realm| realm.len() + <span class="number">9</span>);
<span class="kw">let </span><span class="kw-2">mut </span>buffer = BytesMut::with_capacity(length);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot;Basic&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b"Basic"</span>[..]);
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>realm) = <span class="self">self</span>.realm {
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; realm=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" realm=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, realm);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>);
buffer.put_u8(<span class="string">b'"'</span>);
}
buffer.freeze()
@@ -225,11 +225,11 @@
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>Basic {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; <span class="prelude-ty">Result</span>&lt;(), fmt::Error&gt; {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; <span class="prelude-ty">Result</span>&lt;(), fmt::Error&gt; {
<span class="kw">let </span>bytes = <span class="self">self</span>.to_bytes();
<span class="kw">let </span>repr = str::from_utf8(<span class="kw-2">&amp;</span>bytes)
<span class="comment">// Should not happen since challenges are crafted manually
// from a `&amp;&#39;static str` or `String`
// from a `&amp;'static str` or `String`
</span>.map_err(|<span class="kw">_</span>| fmt::Error)<span class="question-mark">?</span>;
f.write_str(repr)
@@ -255,19 +255,19 @@
<span class="kw">let </span>value = challenge.try_into_value();
<span class="macro">assert!</span>(value.is_ok());
<span class="kw">let </span>value = value.unwrap();
<span class="macro">assert_eq!</span>(value, <span class="string">&quot;Basic&quot;</span>);
<span class="macro">assert_eq!</span>(value, <span class="string">"Basic"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_with_realm_into_header_value() {
<span class="kw">let </span>challenge = Basic {
realm: <span class="prelude-val">Some</span>(<span class="string">&quot;Restricted area&quot;</span>.into()),
realm: <span class="prelude-val">Some</span>(<span class="string">"Restricted area"</span>.into()),
};
<span class="kw">let </span>value = challenge.try_into_value();
<span class="macro">assert!</span>(value.is_ok());
<span class="kw">let </span>value = value.unwrap();
<span class="macro">assert_eq!</span>(value, <span class="string">&quot;Basic realm=\&quot;Restricted area\&quot;&quot;</span>);
<span class="macro">assert_eq!</span>(value, <span class="string">"Basic realm=\"Restricted area\""</span>);
}
}
</code></pre></div></section></main></body></html>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/builder.rs`."><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -86,7 +86,7 @@
/// [RFC 6749 §3.3]: https://tools.ietf.org/html/rfc6749#section-3.3
</span><span class="kw">pub fn </span>scope&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.<span class="number">0</span>.scope = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
@@ -97,7 +97,7 @@
/// [RFC 2617]: https://tools.ietf.org/html/rfc2617
</span><span class="kw">pub fn </span>realm&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.<span class="number">0</span>.realm = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
@@ -116,7 +116,7 @@
/// [RFC 6750 §3]: https://tools.ietf.org/html/rfc6750#section-3
</span><span class="kw">pub fn </span>error_description&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.<span class="number">0</span>.error_description = <span class="prelude-val">Some</span>(value.into());
<span class="self">self
@@ -129,7 +129,7 @@
/// [RFC 6750 §3](https://tools.ietf.org/html/rfc6750#section-3)
</span><span class="kw">pub fn </span>error_uri&lt;T&gt;(<span class="kw-2">mut </span><span class="self">self</span>, value: T) -&gt; <span class="self">Self
</span><span class="kw">where
</span>T: Into&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
</span>T: Into&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
{
<span class="self">self</span>.<span class="number">0</span>.error_uri = <span class="prelude-val">Some</span>(value.into());
<span class="self">self

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs`."><title>challenge.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs`."><title>challenge.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -161,11 +161,11 @@
///
/// fn index(_req: HttpRequest) -&gt; HttpResponse {
/// let challenge = Bearer::build()
/// .realm(&quot;example&quot;)
/// .scope(&quot;openid profile email&quot;)
/// .realm("example")
/// .scope("openid profile email")
/// .error(Error::InvalidToken)
/// .error_description(&quot;The access token expired&quot;)
/// .error_uri(&quot;http://example.org&quot;)
/// .error_description("The access token expired")
/// .error_uri("http://example.org")
/// .finish();
///
/// HttpResponse::Unauthorized()
@@ -178,11 +178,11 @@
/// [RFC 6750]: https://tools.ietf.org/html/rfc6750#section-3
</span><span class="attr">#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
</span><span class="kw">pub struct </span>Bearer {
<span class="kw">pub</span>(<span class="kw">crate</span>) scope: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) realm: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) scope: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) realm: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) error: <span class="prelude-ty">Option</span>&lt;Error&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) error_description: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) error_uri: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">&#39;static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) error_description: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
<span class="kw">pub</span>(<span class="kw">crate</span>) error_uri: <span class="prelude-ty">Option</span>&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;&gt;,
}
<span class="kw">impl </span>Bearer {
@@ -192,8 +192,8 @@
/// ```
/// # use actix_web_httpauth::headers::www_authenticate::bearer::{Bearer};
/// let challenge = Bearer::build()
/// .realm(&quot;Restricted area&quot;)
/// .scope(&quot;openid profile email&quot;)
/// .realm("Restricted area")
/// .scope("openid profile email")
/// .finish();
/// ```
</span><span class="kw">pub fn </span>build() -&gt; BearerBuilder {
@@ -216,44 +216,44 @@
+ desc_uri_required;
<span class="kw">let </span><span class="kw-2">mut </span>buffer = BytesMut::with_capacity(capacity);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot;Bearer&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b"Bearer"</span>[..]);
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>realm) = <span class="self">self</span>.realm {
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; realm=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" realm=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, realm);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>);
buffer.put_u8(<span class="string">b'"'</span>);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>scope) = <span class="self">self</span>.scope {
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; scope=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" scope=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, scope);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>);
buffer.put_u8(<span class="string">b'"'</span>);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>error) = <span class="self">self</span>.error {
<span class="kw">let </span>error_repr = error.as_str();
<span class="kw">let </span>remaining = buffer.remaining_mut();
<span class="kw">let </span>required = desc_uri_required + error_repr.len() + <span class="number">9</span>; <span class="comment">// 9 is for `&quot; error=\&quot;\&quot;&quot;`
<span class="kw">let </span>required = desc_uri_required + error_repr.len() + <span class="number">9</span>; <span class="comment">// 9 is for `" error=\"\""`
</span><span class="kw">if </span>remaining &lt; required {
buffer.reserve(required);
}
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; error=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" error=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, error_repr);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>)
buffer.put_u8(<span class="string">b'"'</span>)
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>error_description) = <span class="self">self</span>.error_description {
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; error_description=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" error_description=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, error_description);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>);
buffer.put_u8(<span class="string">b'"'</span>);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(<span class="kw-2">ref </span>error_uri) = <span class="self">self</span>.error_uri {
buffer.put(<span class="kw-2">&amp;</span><span class="string">b&quot; error_uri=\&quot;&quot;</span>[..]);
buffer.put(<span class="kw-2">&amp;</span><span class="string">b" error_uri=\""</span>[..]);
utils::put_quoted(<span class="kw-2">&amp;mut </span>buffer, error_uri);
buffer.put_u8(<span class="string">b&#39;&quot;&#39;</span>);
buffer.put_u8(<span class="string">b'"'</span>);
}
buffer.freeze()
@@ -261,12 +261,12 @@
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>Bearer {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; <span class="prelude-ty">Result</span>&lt;(), fmt::Error&gt; {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; <span class="prelude-ty">Result</span>&lt;(), fmt::Error&gt; {
<span class="kw">let </span>bytes = <span class="self">self</span>.to_bytes();
<span class="kw">let </span>repr = str::from_utf8(<span class="kw-2">&amp;</span>bytes)
<span class="comment">// Should not happen since challenges are crafted manually
// from `&amp;&#39;static str`&#39;s and Strings
// from `&amp;'static str`'s and Strings
</span>.map_err(|<span class="kw">_</span>| fmt::Error)<span class="question-mark">?</span>;
f.write_str(repr)

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/errors.rs`."><title>errors.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -86,15 +86,15 @@
#[allow(clippy::trivially_copy_pass_by_ref)]
</span><span class="kw">pub fn </span>as_str(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>str {
<span class="kw">match </span><span class="self">self </span>{
Error::InvalidRequest =&gt; <span class="string">&quot;invalid_request&quot;</span>,
Error::InvalidToken =&gt; <span class="string">&quot;invalid_token&quot;</span>,
Error::InsufficientScope =&gt; <span class="string">&quot;insufficient_scope&quot;</span>,
Error::InvalidRequest =&gt; <span class="string">"invalid_request"</span>,
Error::InvalidToken =&gt; <span class="string">"invalid_token"</span>,
Error::InsufficientScope =&gt; <span class="string">"insufficient_scope"</span>,
}
}
}
<span class="kw">impl </span>fmt::Display <span class="kw">for </span>Error {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; fmt::Result {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; fmt::Result {
f.write_str(<span class="self">self</span>.as_str())
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../../" data-static-root-path="../../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../../src-files.js"></script><script defer src="../../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -23,7 +23,7 @@
<a href="#23" id="23">23</a>
<a href="#24" id="24">24</a>
<a href="#25" id="25">25</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Challenge for the &quot;Bearer&quot; HTTP Authentication Scheme.
</pre></div><pre class="rust"><code><span class="doccomment">//! Challenge for the "Bearer" HTTP Authentication Scheme.
</span><span class="kw">mod </span>builder;
<span class="kw">mod </span>challenge;
@@ -39,12 +39,12 @@
</span><span class="kw">fn </span>to_bytes() {
<span class="kw">let </span>bearer = Bearer::build()
.error(Error::InvalidToken)
.error_description(<span class="string">&quot;Subject 8740827c-2e0a-447b-9716-d73042e4039d not found&quot;</span>)
.error_description(<span class="string">"Subject 8740827c-2e0a-447b-9716-d73042e4039d not found"</span>)
.finish();
<span class="macro">assert_eq!</span>(
<span class="string">&quot;Bearer error=\&quot;invalid_token\&quot; error_description=\&quot;Subject 8740827c-2e0a-447b-9716-d73042e4039d not found\&quot;&quot;</span>,
<span class="macro">format!</span>(<span class="string">&quot;{bearer}&quot;</span>)
<span class="string">"Bearer error=\"invalid_token\" error_description=\"Subject 8740827c-2e0a-447b-9716-d73042e4039d not found\""</span>,
<span class="macro">format!</span>(<span class="string">"{bearer}"</span>)
);
}
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../../src-files.js"></script><script defer src="../../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/header.rs`."><title>header.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/header.rs`."><title>header.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/headers/www_authenticate/mod.rs`."><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../../../src-files.js"></script><script defer src="../../../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -44,8 +44,8 @@
</span><span class="attr">#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible, missing_docs)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">pub mod </span>extractors;

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/middleware.rs`."><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -473,7 +473,7 @@
</span>F: Fn(ServiceRequest, basic::BasicAuth) -&gt; O,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt;,
{
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP &quot;Basic&quot; authentication scheme.
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP "Basic" authentication scheme.
///
/// # Examples
/// ```
@@ -502,7 +502,7 @@
</span>F: Fn(ServiceRequest, bearer::BearerAuth) -&gt; O,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt;,
{
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP &quot;Bearer&quot; authentication scheme.
<span class="doccomment">/// Construct `HttpAuthentication` middleware for the HTTP "Bearer" authentication scheme.
///
/// # Examples
/// ```
@@ -515,13 +515,13 @@
/// req: ServiceRequest,
/// credentials: BearerAuth
/// ) -&gt; Result&lt;ServiceRequest, (Error, ServiceRequest)&gt; {
/// if credentials.token() == &quot;mF_9.B5f-4.1JqM&quot; {
/// if credentials.token() == "mF_9.B5f-4.1JqM" {
/// Ok(req)
/// } else {
/// let config = req.app_data::&lt;bearer::Config&gt;()
/// .cloned()
/// .unwrap_or_default()
/// .scope(&quot;urn:example:channel=HBO&amp;urn:example:rating=G,PG-13&quot;);
/// .scope("urn:example:channel=HBO&amp;urn:example:rating=G,PG-13");
///
/// Err((AuthenticationError::from(config).into(), req))
/// }
@@ -536,12 +536,12 @@
<span class="kw">impl</span>&lt;S, B, T, F, O&gt; Transform&lt;S, ServiceRequest&gt; <span class="kw">for </span>HttpAuthentication&lt;T, F&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
F: Fn(ServiceRequest, T) -&gt; O + <span class="lifetime">&#39;static</span>,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt; + <span class="lifetime">&#39;static</span>,
T: FromRequest + <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
F: Fn(ServiceRequest, T) -&gt; O + <span class="lifetime">'static</span>,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt; + <span class="lifetime">'static</span>,
T: FromRequest + <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = Error;
@@ -570,16 +570,16 @@
<span class="kw">impl</span>&lt;S, B, F, T, O&gt; Service&lt;ServiceRequest&gt; <span class="kw">for </span>AuthenticationMiddleware&lt;S, F, T&gt;
<span class="kw">where
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">&#39;static</span>,
S::Future: <span class="lifetime">&#39;static</span>,
F: Fn(ServiceRequest, T) -&gt; O + <span class="lifetime">&#39;static</span>,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt; + <span class="lifetime">&#39;static</span>,
T: FromRequest + <span class="lifetime">&#39;static</span>,
B: MessageBody + <span class="lifetime">&#39;static</span>,
</span>S: Service&lt;ServiceRequest, Response = ServiceResponse&lt;B&gt;, Error = Error&gt; + <span class="lifetime">'static</span>,
S::Future: <span class="lifetime">'static</span>,
F: Fn(ServiceRequest, T) -&gt; O + <span class="lifetime">'static</span>,
O: Future&lt;Output = <span class="prelude-ty">Result</span>&lt;ServiceRequest, (Error, ServiceRequest)&gt;&gt; + <span class="lifetime">'static</span>,
T: FromRequest + <span class="lifetime">'static</span>,
B: MessageBody + <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Response = ServiceResponse&lt;EitherBody&lt;B&gt;&gt;;
<span class="kw">type </span>Error = S::Error;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Response, <span class="self">Self</span>::Error&gt;&gt;;
<span class="kw">type </span>Future = LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Response, <span class="self">Self</span>::Error&gt;&gt;;
<span class="macro">actix_web::dev::forward_ready!</span>(service);
@@ -609,7 +609,7 @@
<span class="kw">struct </span>Extract&lt;T&gt; {
req: <span class="prelude-ty">Option</span>&lt;ServiceRequest&gt;,
fut: <span class="prelude-ty">Option</span>&lt;LocalBoxFuture&lt;<span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span>&lt;T, Error&gt;&gt;&gt;,
fut: <span class="prelude-ty">Option</span>&lt;LocalBoxFuture&lt;<span class="lifetime">'static</span>, <span class="prelude-ty">Result</span>&lt;T, Error&gt;&gt;&gt;,
_extractor: PhantomData&lt;<span class="kw">fn</span>() -&gt; T&gt;,
}
@@ -626,14 +626,14 @@
<span class="kw">impl</span>&lt;T&gt; Future <span class="kw">for </span>Extract&lt;T&gt;
<span class="kw">where
</span>T: FromRequest,
T::Future: <span class="lifetime">&#39;static</span>,
T::Error: <span class="lifetime">&#39;static</span>,
T::Future: <span class="lifetime">'static</span>,
T::Error: <span class="lifetime">'static</span>,
{
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;(ServiceRequest, T), (Error, ServiceRequest)&gt;;
<span class="kw">fn </span>poll(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, ctx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">fn </span>poll(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, ctx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">if </span><span class="self">self</span>.fut.is_none() {
<span class="kw">let </span>req = <span class="self">self</span>.req.as_mut().expect(<span class="string">&quot;Extract future was polled twice!&quot;</span>);
<span class="kw">let </span>req = <span class="self">self</span>.req.as_mut().expect(<span class="string">"Extract future was polled twice!"</span>);
<span class="kw">let </span>fut = req.extract::&lt;T&gt;().map_err(Into::into);
<span class="self">self</span>.fut = <span class="prelude-val">Some</span>(Box::pin(fut));
}
@@ -641,17 +641,17 @@
<span class="kw">let </span>fut = <span class="self">self
</span>.fut
.as_mut()
.expect(<span class="string">&quot;Extraction future should be initialized at this point&quot;</span>);
.expect(<span class="string">"Extraction future should be initialized at this point"</span>);
<span class="kw">let </span>credentials = <span class="macro">ready!</span>(fut.as_mut().poll(ctx)).map_err(|err| {
(
err,
<span class="comment">// returning request allows a proper error response to be created
</span><span class="self">self</span>.req.take().expect(<span class="string">&quot;Extract future was polled twice!&quot;</span>),
</span><span class="self">self</span>.req.take().expect(<span class="string">"Extract future was polled twice!"</span>),
)
})<span class="question-mark">?</span>;
<span class="kw">let </span>req = <span class="self">self</span>.req.take().expect(<span class="string">&quot;Extract future was polled twice!&quot;</span>);
<span class="kw">let </span>req = <span class="self">self</span>.req.take().expect(<span class="string">"Extract future was polled twice!"</span>);
Poll::Ready(<span class="prelude-val">Ok</span>((req, credentials)))
}
}
@@ -676,14 +676,14 @@
<span class="kw">let </span>middleware = AuthenticationMiddleware {
service: Rc::new(into_service(|<span class="kw">_</span>: ServiceRequest| <span class="kw">async move </span>{
actix_web::rt::time::sleep(std::time::Duration::from_secs(<span class="number">1</span>)).<span class="kw">await</span>;
<span class="prelude-val">Err</span>::&lt;ServiceResponse, <span class="kw">_</span>&gt;(error::ErrorBadRequest(<span class="string">&quot;error&quot;</span>))
<span class="prelude-val">Err</span>::&lt;ServiceResponse, <span class="kw">_</span>&gt;(error::ErrorBadRequest(<span class="string">"error"</span>))
})),
process_fn: Arc::new(|req, <span class="kw">_</span>: BearerAuth| <span class="kw">async </span>{ <span class="prelude-val">Ok</span>(req) }),
_extractor: PhantomData,
};
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Bearer 1&quot;</span>))
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Bearer 1"</span>))
.to_srv_request();
<span class="kw">let </span>f = middleware.call(req).<span class="kw">await</span>;
@@ -699,26 +699,26 @@
<span class="kw">let </span>middleware = AuthenticationMiddleware {
service: Rc::new(into_service(|<span class="kw">_</span>: ServiceRequest| <span class="kw">async move </span>{
actix_web::rt::time::sleep(std::time::Duration::from_secs(<span class="number">1</span>)).<span class="kw">await</span>;
<span class="prelude-val">Err</span>::&lt;ServiceResponse, <span class="kw">_</span>&gt;(error::ErrorBadRequest(<span class="string">&quot;error&quot;</span>))
<span class="prelude-val">Err</span>::&lt;ServiceResponse, <span class="kw">_</span>&gt;(error::ErrorBadRequest(<span class="string">"error"</span>))
})),
process_fn: Arc::new(|req, <span class="kw">_</span>: BearerAuth| <span class="kw">async </span>{ <span class="prelude-val">Ok</span>(req) }),
_extractor: PhantomData,
};
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Bearer 1&quot;</span>))
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Bearer 1"</span>))
.to_srv_request();
<span class="kw">let </span>f1 = middleware.call(req).<span class="kw">await</span>;
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Bearer 1&quot;</span>))
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Bearer 1"</span>))
.to_srv_request();
<span class="kw">let </span>f2 = middleware.call(req).<span class="kw">await</span>;
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Bearer 1&quot;</span>))
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Bearer 1"</span>))
.to_srv_request();
<span class="kw">let </span>f3 = middleware.call(req).<span class="kw">await</span>;
@@ -744,7 +744,7 @@
};
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization996&quot;</span>, <span class="string">&quot;Bearer 1&quot;</span>))
.append_header((<span class="string">"Authorization996"</span>, <span class="string">"Bearer 1"</span>))
.to_srv_request();
<span class="kw">let </span>f = middleware.call(req).<span class="kw">await</span>;
@@ -770,7 +770,7 @@
};
<span class="kw">let </span>req = TestRequest::get()
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;BearerLOL&quot;</span>))
.append_header((<span class="string">"Authorization"</span>, <span class="string">"BearerLOL"</span>))
.to_srv_request();
<span class="kw">let </span>f = middleware.call(req).<span class="kw">await</span>;
@@ -786,19 +786,19 @@
req: ServiceRequest,
_credentials: BasicAuth,
) -&gt; <span class="prelude-ty">Result</span>&lt;ServiceRequest, (actix_web::Error, ServiceRequest)&gt; {
<span class="prelude-val">Err</span>((ErrorForbidden(<span class="string">&quot;You are not welcome!&quot;</span>), req))
<span class="prelude-val">Err</span>((ErrorForbidden(<span class="string">"You are not welcome!"</span>), req))
}
<span class="kw">let </span>middleware = HttpAuthentication::basic(validator);
<span class="kw">let </span>srv = actix_web::test::init_service(
App::new()
.wrap(middleware)
.route(<span class="string">&quot;/&quot;</span>, web::get().to(HttpResponse::Ok)),
.route(<span class="string">"/"</span>, web::get().to(HttpResponse::Ok)),
)
.<span class="kw">await</span>;
<span class="kw">let </span>req = actix_web::test::TestRequest::with_uri(<span class="string">&quot;/&quot;</span>)
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Basic DontCare&quot;</span>))
<span class="kw">let </span>req = actix_web::test::TestRequest::with_uri(<span class="string">"/"</span>)
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Basic DontCare"</span>))
.to_request();
<span class="kw">let </span>resp = srv.call(req).<span class="kw">await</span>.unwrap();
@@ -811,21 +811,21 @@
req: ServiceRequest,
_credentials: BasicAuth,
) -&gt; <span class="prelude-ty">Result</span>&lt;ServiceRequest, (actix_web::Error, ServiceRequest)&gt; {
<span class="prelude-val">Err</span>((ErrorForbidden(<span class="string">&quot;You are not welcome!&quot;</span>), req))
<span class="prelude-val">Err</span>((ErrorForbidden(<span class="string">"You are not welcome!"</span>), req))
}
<span class="kw">let </span>middleware = actix_web::middleware::Compat::new(HttpAuthentication::basic(validator));
<span class="kw">let </span>srv = actix_web::test::init_service(
App::new().service(
web::scope(<span class="string">&quot;/&quot;</span>)
web::scope(<span class="string">"/"</span>)
.wrap(middleware)
.route(<span class="string">&quot;/&quot;</span>, web::get().to(HttpResponse::Ok)),
.route(<span class="string">"/"</span>, web::get().to(HttpResponse::Ok)),
),
)
.<span class="kw">await</span>;
<span class="kw">let </span>req = actix_web::test::TestRequest::with_uri(<span class="string">&quot;/&quot;</span>)
.append_header((<span class="string">&quot;Authorization&quot;</span>, <span class="string">&quot;Basic DontCare&quot;</span>))
<span class="kw">let </span>req = actix_web::test::TestRequest::with_uri(<span class="string">"/"</span>)
.append_header((<span class="string">"Authorization"</span>, <span class="string">"Basic DontCare"</span>))
.to_request();
<span class="kw">let </span>resp = srv.call(req).<span class="kw">await</span>.unwrap();

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-web-httpauth/src/utils.rs`."><title>utils.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-web-httpauth/src/utils.rs`."><title>utils.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_web_httpauth/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_web_httpauth"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -119,22 +119,22 @@
YieldQuote,
}
<span class="kw">struct </span>Quoted&lt;<span class="lifetime">&#39;a</span>&gt; {
inner: ::std::iter::Peekable&lt;str::Split&lt;<span class="lifetime">&#39;a</span>, char&gt;&gt;,
<span class="kw">struct </span>Quoted&lt;<span class="lifetime">'a</span>&gt; {
inner: ::std::iter::Peekable&lt;str::Split&lt;<span class="lifetime">'a</span>, char&gt;&gt;,
state: State,
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; Quoted&lt;<span class="lifetime">&#39;a</span>&gt; {
<span class="kw">pub fn </span>new(s: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span>str) -&gt; Quoted&lt;<span class="lifetime">&#39;_</span>&gt; {
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Quoted&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">pub fn </span>new(s: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str) -&gt; Quoted&lt;<span class="lifetime">'_</span>&gt; {
Quoted {
inner: s.split(<span class="string">&#39;&quot;&#39;</span>).peekable(),
inner: s.split(<span class="string">'"'</span>).peekable(),
state: State::YieldStr,
}
}
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; Iterator <span class="kw">for </span>Quoted&lt;<span class="lifetime">&#39;a</span>&gt; {
<span class="kw">type </span>Item = <span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span>str;
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Iterator <span class="kw">for </span>Quoted&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">type </span>Item = <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str;
<span class="kw">fn </span>next(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt; {
<span class="kw">match </span><span class="self">self</span>.state {
@@ -149,7 +149,7 @@
State::YieldQuote =&gt; <span class="kw">match </span><span class="self">self</span>.inner.peek() {
<span class="prelude-val">Some</span>(<span class="kw">_</span>) =&gt; {
<span class="self">self</span>.state = State::YieldStr;
<span class="prelude-val">Some</span>(<span class="string">&quot;\\\&quot;&quot;</span>)
<span class="prelude-val">Some</span>(<span class="string">"\\\""</span>)
}
<span class="prelude-val">None </span>=&gt; <span class="prelude-val">None</span>,
},
@@ -174,52 +174,52 @@
<span class="attr">#[test]
</span><span class="kw">fn </span>test_quote_str() {
<span class="kw">let </span>input = <span class="string">&quot;a \&quot;quoted\&quot; string&quot;</span>;
<span class="kw">let </span>input = <span class="string">"a \"quoted\" string"</span>;
<span class="kw">let </span><span class="kw-2">mut </span>output = BytesMut::new();
put_quoted(<span class="kw-2">&amp;mut </span>output, input);
<span class="kw">let </span>result = str::from_utf8(<span class="kw-2">&amp;</span>output).unwrap();
<span class="macro">assert_eq!</span>(result, <span class="string">&quot;a \\\&quot;quoted\\\&quot; string&quot;</span>);
<span class="macro">assert_eq!</span>(result, <span class="string">"a \\\"quoted\\\" string"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_without_quotes() {
<span class="kw">let </span>input = <span class="string">&quot;non-quoted string&quot;</span>;
<span class="kw">let </span>input = <span class="string">"non-quoted string"</span>;
<span class="kw">let </span><span class="kw-2">mut </span>output = BytesMut::new();
put_quoted(<span class="kw-2">&amp;mut </span>output, input);
<span class="kw">let </span>result = str::from_utf8(<span class="kw-2">&amp;</span>output).unwrap();
<span class="macro">assert_eq!</span>(result, <span class="string">&quot;non-quoted string&quot;</span>);
<span class="macro">assert_eq!</span>(result, <span class="string">"non-quoted string"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_starts_with_quote() {
<span class="kw">let </span>input = <span class="string">&quot;\&quot;first-quoted string&quot;</span>;
<span class="kw">let </span>input = <span class="string">"\"first-quoted string"</span>;
<span class="kw">let </span><span class="kw-2">mut </span>output = BytesMut::new();
put_quoted(<span class="kw-2">&amp;mut </span>output, input);
<span class="kw">let </span>result = str::from_utf8(<span class="kw-2">&amp;</span>output).unwrap();
<span class="macro">assert_eq!</span>(result, <span class="string">&quot;\\\&quot;first-quoted string&quot;</span>);
<span class="macro">assert_eq!</span>(result, <span class="string">"\\\"first-quoted string"</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_ends_with_quote() {
<span class="kw">let </span>input = <span class="string">&quot;last-quoted string\&quot;&quot;</span>;
<span class="kw">let </span>input = <span class="string">"last-quoted string\""</span>;
<span class="kw">let </span><span class="kw-2">mut </span>output = BytesMut::new();
put_quoted(<span class="kw-2">&amp;mut </span>output, input);
<span class="kw">let </span>result = str::from_utf8(<span class="kw-2">&amp;</span>output).unwrap();
<span class="macro">assert_eq!</span>(result, <span class="string">&quot;last-quoted string\\\&quot;&quot;</span>);
<span class="macro">assert_eq!</span>(result, <span class="string">"last-quoted string\\\""</span>);
}
<span class="attr">#[test]
</span><span class="kw">fn </span>test_double_quote() {
<span class="kw">let </span>input = <span class="string">&quot;quote\&quot;\&quot;string&quot;</span>;
<span class="kw">let </span>input = <span class="string">"quote\"\"string"</span>;
<span class="kw">let </span><span class="kw-2">mut </span>output = BytesMut::new();
put_quoted(<span class="kw-2">&amp;mut </span>output, input);
<span class="kw">let </span>result = str::from_utf8(<span class="kw-2">&amp;</span>output).unwrap();
<span class="macro">assert_eq!</span>(result, <span class="string">&quot;quote\\\&quot;\\\&quot;string&quot;</span>);
<span class="macro">assert_eq!</span>(result, <span class="string">"quote\\\"\\\"string"</span>);
}
}
</code></pre></div></section></main></body></html>

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-ws/src/fut.rs`."><title>fut.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-ws/src/fut.rs`."><title>fut.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -213,7 +213,7 @@
<span class="doccomment">/// A stream of Messages from a websocket client
///
/// Messages can be accessed via the stream&#39;s `.next()` method
/// Messages can be accessed via the stream's `.next()` method
</span><span class="kw">pub struct </span>MessageStream {
payload: Payload,
@@ -261,7 +261,7 @@
<span class="kw">impl </span>Stream <span class="kw">for </span>StreamingBody {
<span class="kw">type </span>Item = <span class="prelude-ty">Result</span>&lt;Bytes, Error&gt;;
<span class="kw">fn </span>poll_next(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; Poll&lt;<span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt;&gt; {
<span class="kw">fn </span>poll_next(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt;&gt; {
<span class="kw">let </span>this = <span class="self">self</span>.get_mut();
<span class="kw">if </span>this.closing {
@@ -298,7 +298,7 @@
<span class="kw">impl </span>Stream <span class="kw">for </span>MessageStream {
<span class="kw">type </span>Item = <span class="prelude-ty">Result</span>&lt;Message, ProtocolError&gt;;
<span class="kw">fn </span>poll_next(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; Poll&lt;<span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt;&gt; {
<span class="kw">fn </span>poll_next(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt;&gt; {
<span class="kw">let </span>this = <span class="self">self</span>.get_mut();
<span class="comment">// Return the first message in the queue if one exists
@@ -309,7 +309,7 @@
}
<span class="kw">if </span>!this.closing {
<span class="comment">// Read in bytes until there&#39;s nothing left to read
<span class="comment">// Read in bytes until there's nothing left to read
</span><span class="kw">loop </span>{
<span class="kw">match </span>Pin::new(<span class="kw-2">&amp;mut </span>this.payload).poll_next(cx) {
Poll::Ready(<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(bytes))) =&gt; {
@@ -330,7 +330,7 @@
}
}
<span class="comment">// Create messages until there&#39;s no more bytes left
<span class="comment">// Create messages until there's no more bytes left
</span><span class="kw">while let </span><span class="prelude-val">Some</span>(frame) = this.codec.decode(<span class="kw-2">&amp;mut </span>this.buf)<span class="question-mark">? </span>{
<span class="kw">let </span>message = <span class="kw">match </span>frame {
Frame::Text(bytes) =&gt; {
@@ -356,7 +356,7 @@
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(msg)));
}
<span class="comment">// If we&#39;ve exhausted our message queue and we&#39;re closing, close the stream
<span class="comment">// If we've exhausted our message queue and we're closing, close the stream
</span><span class="kw">if </span>this.closing {
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">None</span>);
}

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-ws/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-ws/src/lib.rs`."><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -88,8 +88,8 @@
</span><span class="attr">#![deny(rust_2018_idioms, nonstandard_style, future_incompatible)]
#![warn(missing_docs)]
#![doc(html_logo_url = <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]
#![doc(html_favicon_url = <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]
#![doc(html_logo_url = <span class="string">"https://actix.rs/img/logo.png"</span>)]
#![doc(html_favicon_url = <span class="string">"https://actix.rs/favicon.ico"</span>)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
</span><span class="kw">pub use </span>actix_http::ws::{CloseCode, CloseReason, Message, ProtocolError};
@@ -126,7 +126,7 @@
/// return;
/// }
/// }
/// Message::Text(s) =&gt; println!(&quot;Got text, {}&quot;, s),
/// Message::Text(s) =&gt; println!("Got text, {}", s),
/// _ =&gt; break,
/// }
/// }
@@ -142,9 +142,9 @@
/// HttpServer::new(move || {
/// App::new()
/// .wrap(Logger::default())
/// .route(&quot;/ws&quot;, web::get().to(ws))
/// .route("/ws", web::get().to(ws))
/// })
/// .bind(&quot;127.0.0.1:8080&quot;)?
/// .bind("127.0.0.1:8080")?
/// .run()
/// .await?;
///

View File

@@ -1,4 +1,4 @@
<!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="Source of the Rust file `actix-ws/src/session.rs`."><title>session.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (9fad68599 2023-12-03)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<!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="Source of the Rust file `actix-ws/src/session.rs`."><title>session.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-c67e44d78ab2db17.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_ws" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0-nightly (e9013ac0e 2023-12-05)" data-channel="nightly" data-search-js="search-5a66c239c06b3a66.js" data-settings-js="settings-fe03fdc259827cd2.js" ><script src="../../static.files/storage-fec3eaa3851e447d.js"></script><script defer src="../../static.files/src-script-3280b574d94e47b4.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-77dede896d6ac08e.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><nav class="sub"><a class="sub-logo-container" href="../../actix_ws/index.html"><img src="https://actix.rs/img/logo.png" alt="actix_ws"></a><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"><a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
<a href="#4" id="4">4</a>
@@ -165,8 +165,8 @@
</span><span class="kw">pub struct </span>Closed;
<span class="kw">impl </span>std::fmt::Display <span class="kw">for </span>Closed {
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>std::fmt::Formatter&lt;<span class="lifetime">&#39;_</span>&gt;) -&gt; std::fmt::Result {
<span class="macro">write!</span>(f, <span class="string">&quot;Session is closed&quot;</span>)
<span class="kw">fn </span>fmt(<span class="kw-2">&amp;</span><span class="self">self</span>, f: <span class="kw-2">&amp;mut </span>std::fmt::Formatter&lt;<span class="lifetime">'_</span>&gt;) -&gt; std::fmt::Result {
<span class="macro">write!</span>(f, <span class="string">"Session is closed"</span>)
}
}
@@ -189,7 +189,7 @@
<span class="doccomment">/// Send text into the websocket
///
/// ```rust,ignore
/// if session.text(&quot;Some text&quot;).await.is_err() {
/// if session.text("Some text").await.is_err() {
/// // session closed
/// }
/// ```
@@ -208,7 +208,7 @@
<span class="doccomment">/// Send raw bytes into the websocket
///
/// ```rust,ignore
/// if session.binary(b&quot;some bytes&quot;).await.is_err() {
/// if session.binary(b"some bytes").await.is_err() {
/// // session closed
/// }
/// ```
@@ -230,7 +230,7 @@
/// client has disconnected
///
/// ```rust,ignore
/// if session.ping(b&quot;&quot;).await.is_err() {
/// if session.ping(b"").await.is_err() {
/// // session is closed
/// }
/// ```