mirror of
https://github.com/actix/actix-extras.git
synced 2025-08-31 19:37:00 +02:00
Deploying to gh-pages from @ 7e6335a09f
🚀
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/all_or_some.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>all_or_some.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -116,5 +116,5 @@
|
||||
<span class="macro">assert!</span>(<span class="ident">AllOrSome::Some</span>(()).<span class="ident">is_some</span>());
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/builder.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>builder.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -1288,5 +1288,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/error.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>error.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -114,5 +114,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/inner.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>inner.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -770,5 +770,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/lib.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>lib.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -126,5 +126,5 @@
|
||||
<span class="kw">use</span> <span class="ident">inner</span>::{<span class="ident">Inner</span>, <span class="ident">OriginFn</span>};
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">middleware::CorsMiddleware</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `actix-cors/src/middleware.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>middleware.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_cors/index.html"><div class="logo-container">
|
||||
@@ -458,5 +458,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_cors" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -1662,5 +1662,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -204,5 +204,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -328,5 +328,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -346,5 +346,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_identity" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -664,5 +664,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_protobuf" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_protobuf" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -33,13 +33,7 @@
|
||||
<span id="28">28</span>
|
||||
<span id="29">29</span>
|
||||
<span id="30">30</span>
|
||||
<span id="31">31</span>
|
||||
<span id="32">32</span>
|
||||
<span id="33">33</span>
|
||||
<span id="34">34</span>
|
||||
<span id="35">35</span>
|
||||
<span id="36">36</span>
|
||||
</pre><pre class="rust"><code><span class="doccomment">//! Redis integration for Actix and session store for Actix Web.</span>
|
||||
</pre><pre class="rust"><code><span class="doccomment">//! Redis integration for `actix`.</span>
|
||||
|
||||
<span class="attribute">#![<span class="ident">deny</span>(<span class="ident">rust_2018_idioms</span>, <span class="ident">nonstandard_style</span>)]</span>
|
||||
<span class="attribute">#![<span class="ident">warn</span>(<span class="ident">future_incompatible</span>)]</span>
|
||||
@@ -49,14 +43,7 @@
|
||||
|
||||
<span class="kw">use</span> <span class="ident">derive_more</span>::{<span class="ident">Display</span>, <span class="ident">Error</span>, <span class="ident">From</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"web"</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">session</span>;
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"web"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">actix_web::cookie::SameSite</span>;
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"web"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">session::RedisSession</span>;
|
||||
|
||||
<span class="doccomment">/// General purpose actix redis error</span>
|
||||
<span class="doccomment">/// General purpose `actix-redis` error.</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>, <span class="ident">Error</span>, <span class="ident">From</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Error</span> {
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Redis error {}"</span>, <span class="ident">_0</span>)]</span>
|
||||
@@ -75,6 +62,7 @@
|
||||
<span class="comment">// re-export</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::error::Error</span> <span class="kw">as</span> <span class="ident">RespError</span>;
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::resp::RespValue</span>;
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_async::resp_array</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -286,5 +286,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_redis" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1302
src/actix_session/middleware.rs.html
Normal file
1302
src/actix_session/middleware.rs.html
Normal file
File diff suppressed because it is too large
Load Diff
522
src/actix_session/session.rs.html
Normal file
522
src/actix_session/session.rs.html
Normal file
@@ -0,0 +1,522 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>session.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10"> 10</span>
|
||||
<span id="11"> 11</span>
|
||||
<span id="12"> 12</span>
|
||||
<span id="13"> 13</span>
|
||||
<span id="14"> 14</span>
|
||||
<span id="15"> 15</span>
|
||||
<span id="16"> 16</span>
|
||||
<span id="17"> 17</span>
|
||||
<span id="18"> 18</span>
|
||||
<span id="19"> 19</span>
|
||||
<span id="20"> 20</span>
|
||||
<span id="21"> 21</span>
|
||||
<span id="22"> 22</span>
|
||||
<span id="23"> 23</span>
|
||||
<span id="24"> 24</span>
|
||||
<span id="25"> 25</span>
|
||||
<span id="26"> 26</span>
|
||||
<span id="27"> 27</span>
|
||||
<span id="28"> 28</span>
|
||||
<span id="29"> 29</span>
|
||||
<span id="30"> 30</span>
|
||||
<span id="31"> 31</span>
|
||||
<span id="32"> 32</span>
|
||||
<span id="33"> 33</span>
|
||||
<span id="34"> 34</span>
|
||||
<span id="35"> 35</span>
|
||||
<span id="36"> 36</span>
|
||||
<span id="37"> 37</span>
|
||||
<span id="38"> 38</span>
|
||||
<span id="39"> 39</span>
|
||||
<span id="40"> 40</span>
|
||||
<span id="41"> 41</span>
|
||||
<span id="42"> 42</span>
|
||||
<span id="43"> 43</span>
|
||||
<span id="44"> 44</span>
|
||||
<span id="45"> 45</span>
|
||||
<span id="46"> 46</span>
|
||||
<span id="47"> 47</span>
|
||||
<span id="48"> 48</span>
|
||||
<span id="49"> 49</span>
|
||||
<span id="50"> 50</span>
|
||||
<span id="51"> 51</span>
|
||||
<span id="52"> 52</span>
|
||||
<span id="53"> 53</span>
|
||||
<span id="54"> 54</span>
|
||||
<span id="55"> 55</span>
|
||||
<span id="56"> 56</span>
|
||||
<span id="57"> 57</span>
|
||||
<span id="58"> 58</span>
|
||||
<span id="59"> 59</span>
|
||||
<span id="60"> 60</span>
|
||||
<span id="61"> 61</span>
|
||||
<span id="62"> 62</span>
|
||||
<span id="63"> 63</span>
|
||||
<span id="64"> 64</span>
|
||||
<span id="65"> 65</span>
|
||||
<span id="66"> 66</span>
|
||||
<span id="67"> 67</span>
|
||||
<span id="68"> 68</span>
|
||||
<span id="69"> 69</span>
|
||||
<span id="70"> 70</span>
|
||||
<span id="71"> 71</span>
|
||||
<span id="72"> 72</span>
|
||||
<span id="73"> 73</span>
|
||||
<span id="74"> 74</span>
|
||||
<span id="75"> 75</span>
|
||||
<span id="76"> 76</span>
|
||||
<span id="77"> 77</span>
|
||||
<span id="78"> 78</span>
|
||||
<span id="79"> 79</span>
|
||||
<span id="80"> 80</span>
|
||||
<span id="81"> 81</span>
|
||||
<span id="82"> 82</span>
|
||||
<span id="83"> 83</span>
|
||||
<span id="84"> 84</span>
|
||||
<span id="85"> 85</span>
|
||||
<span id="86"> 86</span>
|
||||
<span id="87"> 87</span>
|
||||
<span id="88"> 88</span>
|
||||
<span id="89"> 89</span>
|
||||
<span id="90"> 90</span>
|
||||
<span id="91"> 91</span>
|
||||
<span id="92"> 92</span>
|
||||
<span id="93"> 93</span>
|
||||
<span id="94"> 94</span>
|
||||
<span id="95"> 95</span>
|
||||
<span id="96"> 96</span>
|
||||
<span id="97"> 97</span>
|
||||
<span id="98"> 98</span>
|
||||
<span id="99"> 99</span>
|
||||
<span id="100">100</span>
|
||||
<span id="101">101</span>
|
||||
<span id="102">102</span>
|
||||
<span id="103">103</span>
|
||||
<span id="104">104</span>
|
||||
<span id="105">105</span>
|
||||
<span id="106">106</span>
|
||||
<span id="107">107</span>
|
||||
<span id="108">108</span>
|
||||
<span id="109">109</span>
|
||||
<span id="110">110</span>
|
||||
<span id="111">111</span>
|
||||
<span id="112">112</span>
|
||||
<span id="113">113</span>
|
||||
<span id="114">114</span>
|
||||
<span id="115">115</span>
|
||||
<span id="116">116</span>
|
||||
<span id="117">117</span>
|
||||
<span id="118">118</span>
|
||||
<span id="119">119</span>
|
||||
<span id="120">120</span>
|
||||
<span id="121">121</span>
|
||||
<span id="122">122</span>
|
||||
<span id="123">123</span>
|
||||
<span id="124">124</span>
|
||||
<span id="125">125</span>
|
||||
<span id="126">126</span>
|
||||
<span id="127">127</span>
|
||||
<span id="128">128</span>
|
||||
<span id="129">129</span>
|
||||
<span id="130">130</span>
|
||||
<span id="131">131</span>
|
||||
<span id="132">132</span>
|
||||
<span id="133">133</span>
|
||||
<span id="134">134</span>
|
||||
<span id="135">135</span>
|
||||
<span id="136">136</span>
|
||||
<span id="137">137</span>
|
||||
<span id="138">138</span>
|
||||
<span id="139">139</span>
|
||||
<span id="140">140</span>
|
||||
<span id="141">141</span>
|
||||
<span id="142">142</span>
|
||||
<span id="143">143</span>
|
||||
<span id="144">144</span>
|
||||
<span id="145">145</span>
|
||||
<span id="146">146</span>
|
||||
<span id="147">147</span>
|
||||
<span id="148">148</span>
|
||||
<span id="149">149</span>
|
||||
<span id="150">150</span>
|
||||
<span id="151">151</span>
|
||||
<span id="152">152</span>
|
||||
<span id="153">153</span>
|
||||
<span id="154">154</span>
|
||||
<span id="155">155</span>
|
||||
<span id="156">156</span>
|
||||
<span id="157">157</span>
|
||||
<span id="158">158</span>
|
||||
<span id="159">159</span>
|
||||
<span id="160">160</span>
|
||||
<span id="161">161</span>
|
||||
<span id="162">162</span>
|
||||
<span id="163">163</span>
|
||||
<span id="164">164</span>
|
||||
<span id="165">165</span>
|
||||
<span id="166">166</span>
|
||||
<span id="167">167</span>
|
||||
<span id="168">168</span>
|
||||
<span id="169">169</span>
|
||||
<span id="170">170</span>
|
||||
<span id="171">171</span>
|
||||
<span id="172">172</span>
|
||||
<span id="173">173</span>
|
||||
<span id="174">174</span>
|
||||
<span id="175">175</span>
|
||||
<span id="176">176</span>
|
||||
<span id="177">177</span>
|
||||
<span id="178">178</span>
|
||||
<span id="179">179</span>
|
||||
<span id="180">180</span>
|
||||
<span id="181">181</span>
|
||||
<span id="182">182</span>
|
||||
<span id="183">183</span>
|
||||
<span id="184">184</span>
|
||||
<span id="185">185</span>
|
||||
<span id="186">186</span>
|
||||
<span id="187">187</span>
|
||||
<span id="188">188</span>
|
||||
<span id="189">189</span>
|
||||
<span id="190">190</span>
|
||||
<span id="191">191</span>
|
||||
<span id="192">192</span>
|
||||
<span id="193">193</span>
|
||||
<span id="194">194</span>
|
||||
<span id="195">195</span>
|
||||
<span id="196">196</span>
|
||||
<span id="197">197</span>
|
||||
<span id="198">198</span>
|
||||
<span id="199">199</span>
|
||||
<span id="200">200</span>
|
||||
<span id="201">201</span>
|
||||
<span id="202">202</span>
|
||||
<span id="203">203</span>
|
||||
<span id="204">204</span>
|
||||
<span id="205">205</span>
|
||||
<span id="206">206</span>
|
||||
<span id="207">207</span>
|
||||
<span id="208">208</span>
|
||||
<span id="209">209</span>
|
||||
<span id="210">210</span>
|
||||
<span id="211">211</span>
|
||||
<span id="212">212</span>
|
||||
<span id="213">213</span>
|
||||
<span id="214">214</span>
|
||||
<span id="215">215</span>
|
||||
<span id="216">216</span>
|
||||
<span id="217">217</span>
|
||||
<span id="218">218</span>
|
||||
<span id="219">219</span>
|
||||
<span id="220">220</span>
|
||||
<span id="221">221</span>
|
||||
<span id="222">222</span>
|
||||
<span id="223">223</span>
|
||||
<span id="224">224</span>
|
||||
<span id="225">225</span>
|
||||
<span id="226">226</span>
|
||||
<span id="227">227</span>
|
||||
<span id="228">228</span>
|
||||
<span id="229">229</span>
|
||||
<span id="230">230</span>
|
||||
<span id="231">231</span>
|
||||
<span id="232">232</span>
|
||||
<span id="233">233</span>
|
||||
<span id="234">234</span>
|
||||
<span id="235">235</span>
|
||||
<span id="236">236</span>
|
||||
<span id="237">237</span>
|
||||
<span id="238">238</span>
|
||||
<span id="239">239</span>
|
||||
<span id="240">240</span>
|
||||
<span id="241">241</span>
|
||||
<span id="242">242</span>
|
||||
<span id="243">243</span>
|
||||
<span id="244">244</span>
|
||||
<span id="245">245</span>
|
||||
<span id="246">246</span>
|
||||
<span id="247">247</span>
|
||||
<span id="248">248</span>
|
||||
<span id="249">249</span>
|
||||
<span id="250">250</span>
|
||||
<span id="251">251</span>
|
||||
<span id="252">252</span>
|
||||
<span id="253">253</span>
|
||||
<span id="254">254</span>
|
||||
<span id="255">255</span>
|
||||
<span id="256">256</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{
|
||||
<span class="ident">cell</span>::{<span class="ident">Ref</span>, <span class="ident">RefCell</span>},
|
||||
<span class="ident">collections::HashMap</span>,
|
||||
<span class="ident">mem</span>,
|
||||
<span class="ident">rc::Rc</span>,
|
||||
};
|
||||
|
||||
<span class="kw">use</span> <span class="ident">actix_utils::future</span>::{<span class="ident">ready</span>, <span class="ident">Ready</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::{
|
||||
<span class="ident">dev</span>::{<span class="ident">Extensions</span>, <span class="ident">Payload</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
|
||||
<span class="ident">error::Error</span>,
|
||||
<span class="ident">FromRequest</span>, <span class="ident">HttpMessage</span>, <span class="ident">HttpRequest</span>,
|
||||
};
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">de::DeserializeOwned</span>, <span class="ident">Serialize</span>};
|
||||
|
||||
<span class="doccomment">/// The primary interface to access and modify session state.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`Session`] is an [extractor](#impl-FromRequest)—you can specify it as an input type for your</span>
|
||||
<span class="doccomment">/// request handlers and it will be automatically extracted from the incoming request.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">/// use actix_session::Session;</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// async fn index(session: Session) -> actix_web::Result<&'static str> {</span>
|
||||
<span class="doccomment">/// // access session data</span>
|
||||
<span class="doccomment">/// if let Some(count) = session.get::<i32>("counter")? {</span>
|
||||
<span class="doccomment">/// session.insert("counter", count + 1)?;</span>
|
||||
<span class="doccomment">/// } else {</span>
|
||||
<span class="doccomment">/// session.insert("counter", 1)?;</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Ok("Welcome!")</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">/// # actix_web::web::to(index);</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// You can also retrieve a [`Session`] object from an `HttpRequest` or a `ServiceRequest` using</span>
|
||||
<span class="doccomment">/// [`SessionExt`].</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`SessionExt`]: crate::SessionExt</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Session</span>(<span class="ident">Rc</span><span class="op"><</span><span class="ident">RefCell</span><span class="op"><</span><span class="ident">SessionInner</span><span class="op">></span><span class="op">></span>);
|
||||
|
||||
<span class="doccomment">/// Status of a [`Session`].</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">SessionStatus</span> {
|
||||
<span class="doccomment">/// Session state has been updated - the changes will have to be persisted to the backend.</span>
|
||||
<span class="ident">Changed</span>,
|
||||
|
||||
<span class="doccomment">/// The session has been flagged for deletion - the session cookie will be removed from</span>
|
||||
<span class="doccomment">/// the client and the session state will be deleted from the session store.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Most operations on the session after it has been marked for deletion will have no effect.</span>
|
||||
<span class="ident">Purged</span>,
|
||||
|
||||
<span class="doccomment">/// The session has been flagged for renewal.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// The session key will be regenerated and the time-to-live of the session state will be</span>
|
||||
<span class="doccomment">/// extended.</span>
|
||||
<span class="ident">Renewed</span>,
|
||||
|
||||
<span class="doccomment">/// The session state has not been modified since its creation/retrieval.</span>
|
||||
<span class="ident">Unchanged</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">SessionStatus</span> {
|
||||
<span class="kw">fn</span> <span class="ident">default</span>() -> <span class="ident">SessionStatus</span> {
|
||||
<span class="ident">SessionStatus::Unchanged</span>
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Default</span>)]</span>
|
||||
<span class="kw">struct</span> <span class="ident">SessionInner</span> {
|
||||
<span class="ident">state</span>: <span class="ident">HashMap</span><span class="op"><</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">></span>,
|
||||
<span class="ident">status</span>: <span class="ident">SessionStatus</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Session</span> {
|
||||
<span class="doccomment">/// Get a `value` from the session.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">get</span><span class="op"><</span><span class="ident">T</span>: <span class="ident">DeserializeOwned</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">key</span>: <span class="kw-2">&</span><span class="ident">str</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">T</span><span class="op">></span>, <span class="ident">serde_json::Error</span><span class="op">></span> {
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">val_str</span>) <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>().<span class="ident">state</span>.<span class="ident">get</span>(<span class="ident">key</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>(<span class="ident">serde_json::from_str</span>(<span class="ident">val_str</span>)<span class="question-mark">?</span>))
|
||||
} <span class="kw">else</span> {
|
||||
<span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Get all raw key-value data from the session.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Note that values are JSON encoded.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">entries</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Ref</span><span class="op"><</span><span class="lifetime">'_</span>, <span class="ident">HashMap</span><span class="op"><</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="ident">Ref::map</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>(), <span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="kw-2">&</span><span class="ident">inner</span>.<span class="ident">state</span>)
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Returns session status.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">status</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">SessionStatus</span> {
|
||||
<span class="ident">Ref::map</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow</span>(), <span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="kw-2">&</span><span class="ident">inner</span>.<span class="ident">status</span>).<span class="ident">clone</span>()
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Inserts a key-value pair into the session.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Any serializable value can be used and will be encoded as JSON in session data, hence why</span>
|
||||
<span class="doccomment">/// only a reference to the value is taken.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// It returns an error if it fails to serialize `value` to JSON.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">insert</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">key</span>: <span class="kw">impl</span> <span class="ident">Into</span><span class="op"><</span><span class="ident">String</span><span class="op">></span>,
|
||||
<span class="ident">value</span>: <span class="kw">impl</span> <span class="ident">Serialize</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">serde_json::Error</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
|
||||
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
|
||||
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
|
||||
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">value</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">insert</span>(<span class="ident">key</span>.<span class="ident">into</span>(), <span class="ident">val</span>);
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Remove value from the session.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// If present, the JSON encoded value is returned.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">remove</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">key</span>: <span class="kw-2">&</span><span class="ident">str</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">String</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
|
||||
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
|
||||
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
|
||||
<span class="kw">return</span> <span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">remove</span>(<span class="ident">key</span>);
|
||||
}
|
||||
|
||||
<span class="prelude-val">None</span>
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Remove value from the session and deserialize.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Returns None if key was not present in session. Returns `T` if deserialization succeeds,</span>
|
||||
<span class="doccomment">/// otherwise returns un-deserialized JSON string.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">remove_as</span><span class="op"><</span><span class="ident">T</span>: <span class="ident">DeserializeOwned</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">key</span>: <span class="kw-2">&</span><span class="ident">str</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">T</span>, <span class="ident">String</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="self">self</span>.<span class="ident">remove</span>(<span class="ident">key</span>)
|
||||
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">val_str</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">serde_json::from_str</span>(<span class="kw-2">&</span><span class="ident">val_str</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">val</span>) => <span class="prelude-val">Ok</span>(<span class="ident">val</span>),
|
||||
<span class="prelude-val">Err</span>(<span class="ident">_err</span>) => {
|
||||
<span class="macro">tracing::debug!</span>(
|
||||
<span class="string">"removed value (key: {}) could not be deserialized as {}"</span>,
|
||||
<span class="ident">key</span>,
|
||||
<span class="ident">std::any::type_name</span>::<span class="op"><</span><span class="ident">T</span><span class="op">></span>()
|
||||
);
|
||||
|
||||
<span class="prelude-val">Err</span>(<span class="ident">val_str</span>)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Clear the session.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">clear</span>(<span class="kw-2">&</span><span class="self">self</span>) {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
|
||||
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
|
||||
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Changed</span>;
|
||||
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">clear</span>()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Removes session both client and server side.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">purge</span>(<span class="kw-2">&</span><span class="self">self</span>) {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Purged</span>;
|
||||
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">clear</span>();
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Renews the session key, assigning existing session state to new key.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">renew</span>(<span class="kw-2">&</span><span class="self">self</span>) {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="self">self</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
|
||||
<span class="kw">if</span> <span class="ident">inner</span>.<span class="ident">status</span> <span class="op">!</span><span class="op">=</span> <span class="ident">SessionStatus::Purged</span> {
|
||||
<span class="ident">inner</span>.<span class="ident">status</span> <span class="op">=</span> <span class="ident">SessionStatus::Renewed</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Adds the given key-value pairs to the session on the request.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Values that match keys already existing on the session will be overwritten. Values should</span>
|
||||
<span class="doccomment">/// already be JSON serialized.</span>
|
||||
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn</span> <span class="ident">set_session</span>(
|
||||
<span class="ident">req</span>: <span class="kw-2">&mut</span> <span class="ident">ServiceRequest</span>,
|
||||
<span class="ident">data</span>: <span class="kw">impl</span> <span class="ident">IntoIterator</span><span class="op"><</span><span class="ident">Item</span> <span class="op">=</span> (<span class="ident">String</span>, <span class="ident">String</span>)<span class="op">></span>,
|
||||
) {
|
||||
<span class="kw">let</span> <span class="ident">session</span> <span class="op">=</span> <span class="ident">Session::get_session</span>(<span class="kw-2">&mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>());
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">session</span>.<span class="number">0</span>.<span class="ident">borrow_mut</span>();
|
||||
<span class="ident">inner</span>.<span class="ident">state</span>.<span class="ident">extend</span>(<span class="ident">data</span>);
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Returns session status and iterator of key-value pairs of changes.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// This is a destructive operation - the session state is removed from the request extensions typemap,</span>
|
||||
<span class="doccomment">/// leaving behind a new empty map. It should only be used when the session is being finalised (i.e.</span>
|
||||
<span class="doccomment">/// in `SessionMiddleware`).</span>
|
||||
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn</span> <span class="ident">get_changes</span><span class="op"><</span><span class="ident">B</span><span class="op">></span>(
|
||||
<span class="ident">res</span>: <span class="kw-2">&mut</span> <span class="ident">ServiceResponse</span><span class="op"><</span><span class="ident">B</span><span class="op">></span>,
|
||||
) -> (<span class="ident">SessionStatus</span>, <span class="ident">HashMap</span><span class="op"><</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">></span>) {
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">s_impl</span>) <span class="op">=</span> <span class="ident">res</span>
|
||||
.<span class="ident">request</span>()
|
||||
.<span class="ident">extensions</span>()
|
||||
.<span class="ident">get</span>::<span class="op"><</span><span class="ident">Rc</span><span class="op"><</span><span class="ident">RefCell</span><span class="op"><</span><span class="ident">SessionInner</span><span class="op">></span><span class="op">></span><span class="op">></span>()
|
||||
{
|
||||
<span class="kw">let</span> <span class="ident">state</span> <span class="op">=</span> <span class="ident">mem::take</span>(<span class="kw-2">&mut</span> <span class="ident">s_impl</span>.<span class="ident">borrow_mut</span>().<span class="ident">state</span>);
|
||||
(<span class="ident">s_impl</span>.<span class="ident">borrow</span>().<span class="ident">status</span>.<span class="ident">clone</span>(), <span class="ident">state</span>)
|
||||
} <span class="kw">else</span> {
|
||||
(<span class="ident">SessionStatus::Unchanged</span>, <span class="ident">HashMap::new</span>())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn</span> <span class="ident">get_session</span>(<span class="ident">extensions</span>: <span class="kw-2">&mut</span> <span class="ident">Extensions</span>) -> <span class="ident">Session</span> {
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">s_impl</span>) <span class="op">=</span> <span class="ident">extensions</span>.<span class="ident">get</span>::<span class="op"><</span><span class="ident">Rc</span><span class="op"><</span><span class="ident">RefCell</span><span class="op"><</span><span class="ident">SessionInner</span><span class="op">></span><span class="op">></span><span class="op">></span>() {
|
||||
<span class="kw">return</span> <span class="ident">Session</span>(<span class="ident">Rc::clone</span>(<span class="ident">s_impl</span>));
|
||||
}
|
||||
|
||||
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::new</span>(<span class="ident">RefCell::new</span>(<span class="ident">SessionInner::default</span>()));
|
||||
<span class="ident">extensions</span>.<span class="ident">insert</span>(<span class="ident">inner</span>.<span class="ident">clone</span>());
|
||||
|
||||
<span class="ident">Session</span>(<span class="ident">inner</span>)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Extractor implementation for [`Session`]s.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # Examples</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">/// # use actix_web::*;</span>
|
||||
<span class="doccomment">/// use actix_session::Session;</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// #[get("/")]</span>
|
||||
<span class="doccomment">/// async fn index(session: Session) -> Result<impl Responder> {</span>
|
||||
<span class="doccomment">/// // access session data</span>
|
||||
<span class="doccomment">/// if let Some(count) = session.get::<i32>("counter")? {</span>
|
||||
<span class="doccomment">/// session.insert("counter", count + 1)?;</span>
|
||||
<span class="doccomment">/// } else {</span>
|
||||
<span class="doccomment">/// session.insert("counter", 1)?;</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// let count = session.get::<i32>("counter")?.unwrap();</span>
|
||||
<span class="doccomment">/// Ok(format!("Counter: {}", count))</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="kw">impl</span> <span class="ident">FromRequest</span> <span class="kw">for</span> <span class="ident">Session</span> {
|
||||
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
|
||||
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">Ready</span><span class="op"><</span><span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">Session</span>, <span class="ident">Error</span><span class="op">></span><span class="op">></span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">inline</span>]</span>
|
||||
<span class="kw">fn</span> <span class="ident">from_request</span>(<span class="ident">req</span>: <span class="kw-2">&</span><span class="ident">HttpRequest</span>, <span class="kw">_</span>: <span class="kw-2">&mut</span> <span class="ident">Payload</span>) -> <span class="ident"><span class="self">Self</span>::Future</span> {
|
||||
<span class="ident">ready</span>(<span class="prelude-val">Ok</span>(<span class="ident">Session::get_session</span>(<span class="kw-2">&mut</span> <span class="kw-2">*</span><span class="ident">req</span>.<span class="ident">extensions_mut</span>())))
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
72
src/actix_session/session_ext.rs.html
Normal file
72
src/actix_session/session_ext.rs.html
Normal file
@@ -0,0 +1,72 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>session_ext.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10">10</span>
|
||||
<span id="11">11</span>
|
||||
<span id="12">12</span>
|
||||
<span id="13">13</span>
|
||||
<span id="14">14</span>
|
||||
<span id="15">15</span>
|
||||
<span id="16">16</span>
|
||||
<span id="17">17</span>
|
||||
<span id="18">18</span>
|
||||
<span id="19">19</span>
|
||||
<span id="20">20</span>
|
||||
<span id="21">21</span>
|
||||
<span id="22">22</span>
|
||||
<span id="23">23</span>
|
||||
<span id="24">24</span>
|
||||
<span id="25">25</span>
|
||||
<span id="26">26</span>
|
||||
<span id="27">27</span>
|
||||
<span id="28">28</span>
|
||||
<span id="29">29</span>
|
||||
<span id="30">30</span>
|
||||
<span id="31">31</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">actix_web</span>::{
|
||||
<span class="ident">dev</span>::{<span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
|
||||
<span class="ident">HttpMessage</span>, <span class="ident">HttpRequest</span>,
|
||||
};
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::Session</span>;
|
||||
|
||||
<span class="doccomment">/// Extract a [`Session`] object from various `actix-web` types (e.g. `HttpRequest`,</span>
|
||||
<span class="doccomment">/// `ServiceRequest`, `ServiceResponse`).</span>
|
||||
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">SessionExt</span> {
|
||||
<span class="doccomment">/// Extract a [`Session`] object.</span>
|
||||
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Session</span>;
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">SessionExt</span> <span class="kw">for</span> <span class="ident">HttpRequest</span> {
|
||||
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Session</span> {
|
||||
<span class="ident">Session::get_session</span>(<span class="kw-2">&mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">SessionExt</span> <span class="kw">for</span> <span class="ident">ServiceRequest</span> {
|
||||
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Session</span> {
|
||||
<span class="ident">Session::get_session</span>(<span class="kw-2">&mut</span> <span class="kw-2">*</span><span class="self">self</span>.<span class="ident">extensions_mut</span>())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">SessionExt</span> <span class="kw">for</span> <span class="ident">ServiceResponse</span> {
|
||||
<span class="kw">fn</span> <span class="ident">get_session</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Session</span> {
|
||||
<span class="self">self</span>.<span class="ident">request</span>().<span class="ident">get_session</span>()
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
242
src/actix_session/storage/cookie.rs.html
Normal file
242
src/actix_session/storage/cookie.rs.html
Normal file
@@ -0,0 +1,242 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>cookie.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10"> 10</span>
|
||||
<span id="11"> 11</span>
|
||||
<span id="12"> 12</span>
|
||||
<span id="13"> 13</span>
|
||||
<span id="14"> 14</span>
|
||||
<span id="15"> 15</span>
|
||||
<span id="16"> 16</span>
|
||||
<span id="17"> 17</span>
|
||||
<span id="18"> 18</span>
|
||||
<span id="19"> 19</span>
|
||||
<span id="20"> 20</span>
|
||||
<span id="21"> 21</span>
|
||||
<span id="22"> 22</span>
|
||||
<span id="23"> 23</span>
|
||||
<span id="24"> 24</span>
|
||||
<span id="25"> 25</span>
|
||||
<span id="26"> 26</span>
|
||||
<span id="27"> 27</span>
|
||||
<span id="28"> 28</span>
|
||||
<span id="29"> 29</span>
|
||||
<span id="30"> 30</span>
|
||||
<span id="31"> 31</span>
|
||||
<span id="32"> 32</span>
|
||||
<span id="33"> 33</span>
|
||||
<span id="34"> 34</span>
|
||||
<span id="35"> 35</span>
|
||||
<span id="36"> 36</span>
|
||||
<span id="37"> 37</span>
|
||||
<span id="38"> 38</span>
|
||||
<span id="39"> 39</span>
|
||||
<span id="40"> 40</span>
|
||||
<span id="41"> 41</span>
|
||||
<span id="42"> 42</span>
|
||||
<span id="43"> 43</span>
|
||||
<span id="44"> 44</span>
|
||||
<span id="45"> 45</span>
|
||||
<span id="46"> 46</span>
|
||||
<span id="47"> 47</span>
|
||||
<span id="48"> 48</span>
|
||||
<span id="49"> 49</span>
|
||||
<span id="50"> 50</span>
|
||||
<span id="51"> 51</span>
|
||||
<span id="52"> 52</span>
|
||||
<span id="53"> 53</span>
|
||||
<span id="54"> 54</span>
|
||||
<span id="55"> 55</span>
|
||||
<span id="56"> 56</span>
|
||||
<span id="57"> 57</span>
|
||||
<span id="58"> 58</span>
|
||||
<span id="59"> 59</span>
|
||||
<span id="60"> 60</span>
|
||||
<span id="61"> 61</span>
|
||||
<span id="62"> 62</span>
|
||||
<span id="63"> 63</span>
|
||||
<span id="64"> 64</span>
|
||||
<span id="65"> 65</span>
|
||||
<span id="66"> 66</span>
|
||||
<span id="67"> 67</span>
|
||||
<span id="68"> 68</span>
|
||||
<span id="69"> 69</span>
|
||||
<span id="70"> 70</span>
|
||||
<span id="71"> 71</span>
|
||||
<span id="72"> 72</span>
|
||||
<span id="73"> 73</span>
|
||||
<span id="74"> 74</span>
|
||||
<span id="75"> 75</span>
|
||||
<span id="76"> 76</span>
|
||||
<span id="77"> 77</span>
|
||||
<span id="78"> 78</span>
|
||||
<span id="79"> 79</span>
|
||||
<span id="80"> 80</span>
|
||||
<span id="81"> 81</span>
|
||||
<span id="82"> 82</span>
|
||||
<span id="83"> 83</span>
|
||||
<span id="84"> 84</span>
|
||||
<span id="85"> 85</span>
|
||||
<span id="86"> 86</span>
|
||||
<span id="87"> 87</span>
|
||||
<span id="88"> 88</span>
|
||||
<span id="89"> 89</span>
|
||||
<span id="90"> 90</span>
|
||||
<span id="91"> 91</span>
|
||||
<span id="92"> 92</span>
|
||||
<span id="93"> 93</span>
|
||||
<span id="94"> 94</span>
|
||||
<span id="95"> 95</span>
|
||||
<span id="96"> 96</span>
|
||||
<span id="97"> 97</span>
|
||||
<span id="98"> 98</span>
|
||||
<span id="99"> 99</span>
|
||||
<span id="100">100</span>
|
||||
<span id="101">101</span>
|
||||
<span id="102">102</span>
|
||||
<span id="103">103</span>
|
||||
<span id="104">104</span>
|
||||
<span id="105">105</span>
|
||||
<span id="106">106</span>
|
||||
<span id="107">107</span>
|
||||
<span id="108">108</span>
|
||||
<span id="109">109</span>
|
||||
<span id="110">110</span>
|
||||
<span id="111">111</span>
|
||||
<span id="112">112</span>
|
||||
<span id="113">113</span>
|
||||
<span id="114">114</span>
|
||||
<span id="115">115</span>
|
||||
<span id="116">116</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::convert::TryInto</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">time::Duration</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::SessionKey</span>;
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::storage</span>::{
|
||||
<span class="ident">interface</span>::{<span class="ident">LoadError</span>, <span class="ident">SaveError</span>, <span class="ident">SessionState</span>, <span class="ident">UpdateError</span>},
|
||||
<span class="ident">SessionStore</span>,
|
||||
};
|
||||
|
||||
<span class="doccomment">/// Use the session key, stored in the session cookie, as storage backend for the session state.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```no_run</span>
|
||||
<span class="doccomment">/// use actix_web::{cookie::Key, web, App, HttpServer, HttpResponse, Error};</span>
|
||||
<span class="doccomment">/// use actix_session::{SessionMiddleware, storage::CookieSessionStore};</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// // The secret key would usually be read from a configuration file/environment variables.</span>
|
||||
<span class="doccomment">/// fn get_secret_key() -> Key {</span>
|
||||
<span class="doccomment">/// # todo!()</span>
|
||||
<span class="doccomment">/// // [...]</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// #[actix_web::main]</span>
|
||||
<span class="doccomment">/// async fn main() -> std::io::Result<()> {</span>
|
||||
<span class="doccomment">/// let secret_key = get_secret_key();</span>
|
||||
<span class="doccomment">/// HttpServer::new(move ||</span>
|
||||
<span class="doccomment">/// App::new()</span>
|
||||
<span class="doccomment">/// .wrap(SessionMiddleware::new(CookieSessionStore::default(), secret_key.clone()))</span>
|
||||
<span class="doccomment">/// .default_service(web::to(|| HttpResponse::Ok())))</span>
|
||||
<span class="doccomment">/// .bind(("127.0.0.1", 8080))?</span>
|
||||
<span class="doccomment">/// .run()</span>
|
||||
<span class="doccomment">/// .await</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # Limitations</span>
|
||||
<span class="doccomment">/// Cookies are subject to size limits - we require session keys to be shorter than 4096 bytes. This</span>
|
||||
<span class="doccomment">/// translates into a limit on the maximum size of the session state when using cookies as storage</span>
|
||||
<span class="doccomment">/// backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// The session cookie can always be inspected by end users via the developer tools exposed by their</span>
|
||||
<span class="doccomment">/// browsers. We strongly recommend setting the policy to [`CookieContentSecurity::Private`] when</span>
|
||||
<span class="doccomment">/// using cookies as storage backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// There is no way to invalidate a session before its natural expiry when using cookies as the</span>
|
||||
<span class="doccomment">/// storage backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`CookieContentSecurity::Private`]: crate::CookieContentSecurity::Private</span>
|
||||
<span class="attribute">#[<span class="ident">cfg_attr</span>(<span class="ident">docsrs</span>, <span class="ident">doc</span>(<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"cookie-session"</span>)))]</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Default</span>)]</span>
|
||||
<span class="attribute">#[<span class="ident">non_exhaustive</span>]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">CookieSessionStore</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">async_trait::async_trait</span>(<span class="question-mark">?</span><span class="ident">Send</span>)]</span>
|
||||
<span class="kw">impl</span> <span class="ident">SessionStore</span> <span class="kw">for</span> <span class="ident">CookieSessionStore</span> {
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">load</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">SessionState</span><span class="op">></span>, <span class="ident">LoadError</span><span class="op">></span> {
|
||||
<span class="ident">serde_json::from_str</span>(<span class="ident">session_key</span>.<span class="ident">as_ref</span>())
|
||||
.<span class="ident">map</span>(<span class="prelude-val">Some</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">anyhow::Error::new</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Deserialization</span>)
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">save</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">_ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">SaveError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">session_state</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">anyhow::Error::new</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Serialization</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">session_key</span>
|
||||
.<span class="ident">try_into</span>()
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Other</span>)<span class="question-mark">?</span>)
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">update</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">_session_key</span>: <span class="ident">SessionKey</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">UpdateError</span><span class="op">></span> {
|
||||
<span class="self">self</span>.<span class="ident">save</span>(<span class="ident">session_state</span>, <span class="ident">ttl</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">err</span> {
|
||||
<span class="ident">SaveError::Serialization</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Serialization</span>(<span class="ident">err</span>),
|
||||
<span class="ident">SaveError::Other</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Other</span>(<span class="ident">err</span>),
|
||||
})
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">delete</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">_session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">anyhow::Error</span><span class="op">></span> {
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">tests</span> {
|
||||
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
|
||||
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">storage::utils::generate_session_key</span>, <span class="ident">test_helpers::acceptance_test_suite</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_session_workflow</span>() {
|
||||
<span class="ident">acceptance_test_suite</span>(<span class="ident">CookieSessionStore::default</span>, <span class="bool-val">false</span>).<span class="kw">await</span>;
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">loading_a_random_session_key_returns_deserialization_error</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">CookieSessionStore::default</span>();
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="macro">assert!</span>(<span class="macro">matches!</span>(
|
||||
<span class="ident">store</span>.<span class="ident">load</span>(<span class="kw-2">&</span><span class="ident">session_key</span>).<span class="kw">await</span>.<span class="ident">unwrap_err</span>(),
|
||||
<span class="ident">LoadError::Deserialization</span>(<span class="kw">_</span>),
|
||||
));
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
218
src/actix_session/storage/interface.rs.html
Normal file
218
src/actix_session/storage/interface.rs.html
Normal file
@@ -0,0 +1,218 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>interface.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10"> 10</span>
|
||||
<span id="11"> 11</span>
|
||||
<span id="12"> 12</span>
|
||||
<span id="13"> 13</span>
|
||||
<span id="14"> 14</span>
|
||||
<span id="15"> 15</span>
|
||||
<span id="16"> 16</span>
|
||||
<span id="17"> 17</span>
|
||||
<span id="18"> 18</span>
|
||||
<span id="19"> 19</span>
|
||||
<span id="20"> 20</span>
|
||||
<span id="21"> 21</span>
|
||||
<span id="22"> 22</span>
|
||||
<span id="23"> 23</span>
|
||||
<span id="24"> 24</span>
|
||||
<span id="25"> 25</span>
|
||||
<span id="26"> 26</span>
|
||||
<span id="27"> 27</span>
|
||||
<span id="28"> 28</span>
|
||||
<span id="29"> 29</span>
|
||||
<span id="30"> 30</span>
|
||||
<span id="31"> 31</span>
|
||||
<span id="32"> 32</span>
|
||||
<span id="33"> 33</span>
|
||||
<span id="34"> 34</span>
|
||||
<span id="35"> 35</span>
|
||||
<span id="36"> 36</span>
|
||||
<span id="37"> 37</span>
|
||||
<span id="38"> 38</span>
|
||||
<span id="39"> 39</span>
|
||||
<span id="40"> 40</span>
|
||||
<span id="41"> 41</span>
|
||||
<span id="42"> 42</span>
|
||||
<span id="43"> 43</span>
|
||||
<span id="44"> 44</span>
|
||||
<span id="45"> 45</span>
|
||||
<span id="46"> 46</span>
|
||||
<span id="47"> 47</span>
|
||||
<span id="48"> 48</span>
|
||||
<span id="49"> 49</span>
|
||||
<span id="50"> 50</span>
|
||||
<span id="51"> 51</span>
|
||||
<span id="52"> 52</span>
|
||||
<span id="53"> 53</span>
|
||||
<span id="54"> 54</span>
|
||||
<span id="55"> 55</span>
|
||||
<span id="56"> 56</span>
|
||||
<span id="57"> 57</span>
|
||||
<span id="58"> 58</span>
|
||||
<span id="59"> 59</span>
|
||||
<span id="60"> 60</span>
|
||||
<span id="61"> 61</span>
|
||||
<span id="62"> 62</span>
|
||||
<span id="63"> 63</span>
|
||||
<span id="64"> 64</span>
|
||||
<span id="65"> 65</span>
|
||||
<span id="66"> 66</span>
|
||||
<span id="67"> 67</span>
|
||||
<span id="68"> 68</span>
|
||||
<span id="69"> 69</span>
|
||||
<span id="70"> 70</span>
|
||||
<span id="71"> 71</span>
|
||||
<span id="72"> 72</span>
|
||||
<span id="73"> 73</span>
|
||||
<span id="74"> 74</span>
|
||||
<span id="75"> 75</span>
|
||||
<span id="76"> 76</span>
|
||||
<span id="77"> 77</span>
|
||||
<span id="78"> 78</span>
|
||||
<span id="79"> 79</span>
|
||||
<span id="80"> 80</span>
|
||||
<span id="81"> 81</span>
|
||||
<span id="82"> 82</span>
|
||||
<span id="83"> 83</span>
|
||||
<span id="84"> 84</span>
|
||||
<span id="85"> 85</span>
|
||||
<span id="86"> 86</span>
|
||||
<span id="87"> 87</span>
|
||||
<span id="88"> 88</span>
|
||||
<span id="89"> 89</span>
|
||||
<span id="90"> 90</span>
|
||||
<span id="91"> 91</span>
|
||||
<span id="92"> 92</span>
|
||||
<span id="93"> 93</span>
|
||||
<span id="94"> 94</span>
|
||||
<span id="95"> 95</span>
|
||||
<span id="96"> 96</span>
|
||||
<span id="97"> 97</span>
|
||||
<span id="98"> 98</span>
|
||||
<span id="99"> 99</span>
|
||||
<span id="100">100</span>
|
||||
<span id="101">101</span>
|
||||
<span id="102">102</span>
|
||||
<span id="103">103</span>
|
||||
<span id="104">104</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::collections::HashMap</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">derive_more::Display</span>;
|
||||
<span class="kw">use</span> <span class="ident">time::Duration</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::SessionKey</span>;
|
||||
|
||||
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">type</span> <span class="ident">SessionState</span> <span class="op">=</span> <span class="ident">HashMap</span><span class="op"><</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">></span>;
|
||||
|
||||
<span class="doccomment">/// The interface to retrieve and save the current session data from/to the chosen storage backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// You can provide your own custom session store backend by implementing this trait.</span>
|
||||
<span class="attribute">#[<span class="ident">async_trait::async_trait</span>(<span class="question-mark">?</span><span class="ident">Send</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">SessionStore</span> {
|
||||
<span class="doccomment">/// Loads the session state associated to a session key.</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">load</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">SessionState</span><span class="op">></span>, <span class="ident">LoadError</span><span class="op">></span>;
|
||||
|
||||
<span class="doccomment">/// Persist the session state for a newly created session.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Returns the corresponding session key.</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">save</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">SaveError</span><span class="op">></span>;
|
||||
|
||||
<span class="doccomment">/// Updates the session state associated to a pre-existing session key.</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">update</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_key</span>: <span class="ident">SessionKey</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">UpdateError</span><span class="op">></span>;
|
||||
|
||||
<span class="doccomment">/// Deletes a session from the store.</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">delete</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">anyhow::Error</span><span class="op">></span>;
|
||||
}
|
||||
|
||||
<span class="comment">// We cannot derive the `Error` implementation using `derive_more` for our custom errors:</span>
|
||||
<span class="comment">// `derive_more`'s `#[error(source)]` attribute requires the source implement the `Error` trait,</span>
|
||||
<span class="comment">// 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="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">LoadError</span> {
|
||||
<span class="doccomment">/// Failed to deserialize session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Failed to deserialize session state"</span>)]</span>
|
||||
<span class="ident">Deserialization</span>(<span class="ident">anyhow::Error</span>),
|
||||
|
||||
<span class="doccomment">/// Something went wrong when retrieving the session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Something went wrong when retrieving the session state"</span>)]</span>
|
||||
<span class="ident">Other</span>(<span class="ident">anyhow::Error</span>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">std::error::Error</span> <span class="kw">for</span> <span class="ident">LoadError</span> {
|
||||
<span class="kw">fn</span> <span class="ident">source</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="kw-2">&</span>(<span class="kw">dyn</span> <span class="ident">std::error::Error</span> <span class="op">+</span> <span class="lifetime">'static</span>)<span class="op">></span> {
|
||||
<span class="kw">match</span> <span class="self">self</span> {
|
||||
<span class="ident"><span class="self">Self</span>::Deserialization</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
<span class="ident"><span class="self">Self</span>::Other</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Possible failures modes for [`SessionStore::save`].</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">SaveError</span> {
|
||||
<span class="doccomment">/// Failed to serialize session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Failed to serialize session state"</span>)]</span>
|
||||
<span class="ident">Serialization</span>(<span class="ident">anyhow::Error</span>),
|
||||
|
||||
<span class="doccomment">/// Something went wrong when persisting the session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Something went wrong when persisting the session state"</span>)]</span>
|
||||
<span class="ident">Other</span>(<span class="ident">anyhow::Error</span>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">std::error::Error</span> <span class="kw">for</span> <span class="ident">SaveError</span> {
|
||||
<span class="kw">fn</span> <span class="ident">source</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="kw-2">&</span>(<span class="kw">dyn</span> <span class="ident">std::error::Error</span> <span class="op">+</span> <span class="lifetime">'static</span>)<span class="op">></span> {
|
||||
<span class="kw">match</span> <span class="self">self</span> {
|
||||
<span class="ident"><span class="self">Self</span>::Serialization</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
<span class="ident"><span class="self">Self</span>::Other</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>)]</span>
|
||||
<span class="doccomment">/// Possible failures modes for [`SessionStore::update`].</span>
|
||||
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">UpdateError</span> {
|
||||
<span class="doccomment">/// Failed to serialize session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Failed to serialize session state"</span>)]</span>
|
||||
<span class="ident">Serialization</span>(<span class="ident">anyhow::Error</span>),
|
||||
|
||||
<span class="doccomment">/// Something went wrong when updating the session state.</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"Something went wrong when updating the session state."</span>)]</span>
|
||||
<span class="ident">Other</span>(<span class="ident">anyhow::Error</span>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">std::error::Error</span> <span class="kw">for</span> <span class="ident">UpdateError</span> {
|
||||
<span class="kw">fn</span> <span class="ident">source</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="kw-2">&</span>(<span class="kw">dyn</span> <span class="ident">std::error::Error</span> <span class="op">+</span> <span class="lifetime">'static</span>)<span class="op">></span> {
|
||||
<span class="kw">match</span> <span class="self">self</span> {
|
||||
<span class="ident"><span class="self">Self</span>::Serialization</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
<span class="ident"><span class="self">Self</span>::Other</span>(<span class="ident">err</span>) => <span class="prelude-val">Some</span>(<span class="ident">err</span>.<span class="ident">as_ref</span>()),
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
66
src/actix_session/storage/mod.rs.html
Normal file
66
src/actix_session/storage/mod.rs.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>mod.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10">10</span>
|
||||
<span id="11">11</span>
|
||||
<span id="12">12</span>
|
||||
<span id="13">13</span>
|
||||
<span id="14">14</span>
|
||||
<span id="15">15</span>
|
||||
<span id="16">16</span>
|
||||
<span id="17">17</span>
|
||||
<span id="18">18</span>
|
||||
<span id="19">19</span>
|
||||
<span id="20">20</span>
|
||||
<span id="21">21</span>
|
||||
<span id="22">22</span>
|
||||
<span id="23">23</span>
|
||||
<span id="24">24</span>
|
||||
<span id="25">25</span>
|
||||
<span id="26">26</span>
|
||||
<span id="27">27</span>
|
||||
<span id="28">28</span>
|
||||
</pre><pre class="rust"><code><span class="doccomment">//! Pluggable storage backends for session state.</span>
|
||||
|
||||
<span class="kw">mod</span> <span class="ident">interface</span>;
|
||||
<span class="kw">mod</span> <span class="ident">session_key</span>;
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::interface</span>::{<span class="ident">LoadError</span>, <span class="ident">SaveError</span>, <span class="ident">SessionStore</span>, <span class="ident">UpdateError</span>};
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::session_key::SessionKey</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"cookie-session"</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">cookie</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-actor-session"</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">redis_actor</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-rs-session"</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">redis_rs</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">any</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-actor-session"</span>, <span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-rs-session"</span>))]</span>
|
||||
<span class="kw">mod</span> <span class="ident">utils</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"cookie-session"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">cookie::CookieSessionStore</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-actor-session"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_actor</span>::{<span class="ident">RedisActorSessionStore</span>, <span class="ident">RedisActorSessionStoreBuilder</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-rs-session"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident">redis_rs</span>::{<span class="ident">RedisSessionStore</span>, <span class="ident">RedisSessionStoreBuilder</span>};
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
598
src/actix_session/storage/redis_actor.rs.html
Normal file
598
src/actix_session/storage/redis_actor.rs.html
Normal file
@@ -0,0 +1,598 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>redis_actor.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10"> 10</span>
|
||||
<span id="11"> 11</span>
|
||||
<span id="12"> 12</span>
|
||||
<span id="13"> 13</span>
|
||||
<span id="14"> 14</span>
|
||||
<span id="15"> 15</span>
|
||||
<span id="16"> 16</span>
|
||||
<span id="17"> 17</span>
|
||||
<span id="18"> 18</span>
|
||||
<span id="19"> 19</span>
|
||||
<span id="20"> 20</span>
|
||||
<span id="21"> 21</span>
|
||||
<span id="22"> 22</span>
|
||||
<span id="23"> 23</span>
|
||||
<span id="24"> 24</span>
|
||||
<span id="25"> 25</span>
|
||||
<span id="26"> 26</span>
|
||||
<span id="27"> 27</span>
|
||||
<span id="28"> 28</span>
|
||||
<span id="29"> 29</span>
|
||||
<span id="30"> 30</span>
|
||||
<span id="31"> 31</span>
|
||||
<span id="32"> 32</span>
|
||||
<span id="33"> 33</span>
|
||||
<span id="34"> 34</span>
|
||||
<span id="35"> 35</span>
|
||||
<span id="36"> 36</span>
|
||||
<span id="37"> 37</span>
|
||||
<span id="38"> 38</span>
|
||||
<span id="39"> 39</span>
|
||||
<span id="40"> 40</span>
|
||||
<span id="41"> 41</span>
|
||||
<span id="42"> 42</span>
|
||||
<span id="43"> 43</span>
|
||||
<span id="44"> 44</span>
|
||||
<span id="45"> 45</span>
|
||||
<span id="46"> 46</span>
|
||||
<span id="47"> 47</span>
|
||||
<span id="48"> 48</span>
|
||||
<span id="49"> 49</span>
|
||||
<span id="50"> 50</span>
|
||||
<span id="51"> 51</span>
|
||||
<span id="52"> 52</span>
|
||||
<span id="53"> 53</span>
|
||||
<span id="54"> 54</span>
|
||||
<span id="55"> 55</span>
|
||||
<span id="56"> 56</span>
|
||||
<span id="57"> 57</span>
|
||||
<span id="58"> 58</span>
|
||||
<span id="59"> 59</span>
|
||||
<span id="60"> 60</span>
|
||||
<span id="61"> 61</span>
|
||||
<span id="62"> 62</span>
|
||||
<span id="63"> 63</span>
|
||||
<span id="64"> 64</span>
|
||||
<span id="65"> 65</span>
|
||||
<span id="66"> 66</span>
|
||||
<span id="67"> 67</span>
|
||||
<span id="68"> 68</span>
|
||||
<span id="69"> 69</span>
|
||||
<span id="70"> 70</span>
|
||||
<span id="71"> 71</span>
|
||||
<span id="72"> 72</span>
|
||||
<span id="73"> 73</span>
|
||||
<span id="74"> 74</span>
|
||||
<span id="75"> 75</span>
|
||||
<span id="76"> 76</span>
|
||||
<span id="77"> 77</span>
|
||||
<span id="78"> 78</span>
|
||||
<span id="79"> 79</span>
|
||||
<span id="80"> 80</span>
|
||||
<span id="81"> 81</span>
|
||||
<span id="82"> 82</span>
|
||||
<span id="83"> 83</span>
|
||||
<span id="84"> 84</span>
|
||||
<span id="85"> 85</span>
|
||||
<span id="86"> 86</span>
|
||||
<span id="87"> 87</span>
|
||||
<span id="88"> 88</span>
|
||||
<span id="89"> 89</span>
|
||||
<span id="90"> 90</span>
|
||||
<span id="91"> 91</span>
|
||||
<span id="92"> 92</span>
|
||||
<span id="93"> 93</span>
|
||||
<span id="94"> 94</span>
|
||||
<span id="95"> 95</span>
|
||||
<span id="96"> 96</span>
|
||||
<span id="97"> 97</span>
|
||||
<span id="98"> 98</span>
|
||||
<span id="99"> 99</span>
|
||||
<span id="100">100</span>
|
||||
<span id="101">101</span>
|
||||
<span id="102">102</span>
|
||||
<span id="103">103</span>
|
||||
<span id="104">104</span>
|
||||
<span id="105">105</span>
|
||||
<span id="106">106</span>
|
||||
<span id="107">107</span>
|
||||
<span id="108">108</span>
|
||||
<span id="109">109</span>
|
||||
<span id="110">110</span>
|
||||
<span id="111">111</span>
|
||||
<span id="112">112</span>
|
||||
<span id="113">113</span>
|
||||
<span id="114">114</span>
|
||||
<span id="115">115</span>
|
||||
<span id="116">116</span>
|
||||
<span id="117">117</span>
|
||||
<span id="118">118</span>
|
||||
<span id="119">119</span>
|
||||
<span id="120">120</span>
|
||||
<span id="121">121</span>
|
||||
<span id="122">122</span>
|
||||
<span id="123">123</span>
|
||||
<span id="124">124</span>
|
||||
<span id="125">125</span>
|
||||
<span id="126">126</span>
|
||||
<span id="127">127</span>
|
||||
<span id="128">128</span>
|
||||
<span id="129">129</span>
|
||||
<span id="130">130</span>
|
||||
<span id="131">131</span>
|
||||
<span id="132">132</span>
|
||||
<span id="133">133</span>
|
||||
<span id="134">134</span>
|
||||
<span id="135">135</span>
|
||||
<span id="136">136</span>
|
||||
<span id="137">137</span>
|
||||
<span id="138">138</span>
|
||||
<span id="139">139</span>
|
||||
<span id="140">140</span>
|
||||
<span id="141">141</span>
|
||||
<span id="142">142</span>
|
||||
<span id="143">143</span>
|
||||
<span id="144">144</span>
|
||||
<span id="145">145</span>
|
||||
<span id="146">146</span>
|
||||
<span id="147">147</span>
|
||||
<span id="148">148</span>
|
||||
<span id="149">149</span>
|
||||
<span id="150">150</span>
|
||||
<span id="151">151</span>
|
||||
<span id="152">152</span>
|
||||
<span id="153">153</span>
|
||||
<span id="154">154</span>
|
||||
<span id="155">155</span>
|
||||
<span id="156">156</span>
|
||||
<span id="157">157</span>
|
||||
<span id="158">158</span>
|
||||
<span id="159">159</span>
|
||||
<span id="160">160</span>
|
||||
<span id="161">161</span>
|
||||
<span id="162">162</span>
|
||||
<span id="163">163</span>
|
||||
<span id="164">164</span>
|
||||
<span id="165">165</span>
|
||||
<span id="166">166</span>
|
||||
<span id="167">167</span>
|
||||
<span id="168">168</span>
|
||||
<span id="169">169</span>
|
||||
<span id="170">170</span>
|
||||
<span id="171">171</span>
|
||||
<span id="172">172</span>
|
||||
<span id="173">173</span>
|
||||
<span id="174">174</span>
|
||||
<span id="175">175</span>
|
||||
<span id="176">176</span>
|
||||
<span id="177">177</span>
|
||||
<span id="178">178</span>
|
||||
<span id="179">179</span>
|
||||
<span id="180">180</span>
|
||||
<span id="181">181</span>
|
||||
<span id="182">182</span>
|
||||
<span id="183">183</span>
|
||||
<span id="184">184</span>
|
||||
<span id="185">185</span>
|
||||
<span id="186">186</span>
|
||||
<span id="187">187</span>
|
||||
<span id="188">188</span>
|
||||
<span id="189">189</span>
|
||||
<span id="190">190</span>
|
||||
<span id="191">191</span>
|
||||
<span id="192">192</span>
|
||||
<span id="193">193</span>
|
||||
<span id="194">194</span>
|
||||
<span id="195">195</span>
|
||||
<span id="196">196</span>
|
||||
<span id="197">197</span>
|
||||
<span id="198">198</span>
|
||||
<span id="199">199</span>
|
||||
<span id="200">200</span>
|
||||
<span id="201">201</span>
|
||||
<span id="202">202</span>
|
||||
<span id="203">203</span>
|
||||
<span id="204">204</span>
|
||||
<span id="205">205</span>
|
||||
<span id="206">206</span>
|
||||
<span id="207">207</span>
|
||||
<span id="208">208</span>
|
||||
<span id="209">209</span>
|
||||
<span id="210">210</span>
|
||||
<span id="211">211</span>
|
||||
<span id="212">212</span>
|
||||
<span id="213">213</span>
|
||||
<span id="214">214</span>
|
||||
<span id="215">215</span>
|
||||
<span id="216">216</span>
|
||||
<span id="217">217</span>
|
||||
<span id="218">218</span>
|
||||
<span id="219">219</span>
|
||||
<span id="220">220</span>
|
||||
<span id="221">221</span>
|
||||
<span id="222">222</span>
|
||||
<span id="223">223</span>
|
||||
<span id="224">224</span>
|
||||
<span id="225">225</span>
|
||||
<span id="226">226</span>
|
||||
<span id="227">227</span>
|
||||
<span id="228">228</span>
|
||||
<span id="229">229</span>
|
||||
<span id="230">230</span>
|
||||
<span id="231">231</span>
|
||||
<span id="232">232</span>
|
||||
<span id="233">233</span>
|
||||
<span id="234">234</span>
|
||||
<span id="235">235</span>
|
||||
<span id="236">236</span>
|
||||
<span id="237">237</span>
|
||||
<span id="238">238</span>
|
||||
<span id="239">239</span>
|
||||
<span id="240">240</span>
|
||||
<span id="241">241</span>
|
||||
<span id="242">242</span>
|
||||
<span id="243">243</span>
|
||||
<span id="244">244</span>
|
||||
<span id="245">245</span>
|
||||
<span id="246">246</span>
|
||||
<span id="247">247</span>
|
||||
<span id="248">248</span>
|
||||
<span id="249">249</span>
|
||||
<span id="250">250</span>
|
||||
<span id="251">251</span>
|
||||
<span id="252">252</span>
|
||||
<span id="253">253</span>
|
||||
<span id="254">254</span>
|
||||
<span id="255">255</span>
|
||||
<span id="256">256</span>
|
||||
<span id="257">257</span>
|
||||
<span id="258">258</span>
|
||||
<span id="259">259</span>
|
||||
<span id="260">260</span>
|
||||
<span id="261">261</span>
|
||||
<span id="262">262</span>
|
||||
<span id="263">263</span>
|
||||
<span id="264">264</span>
|
||||
<span id="265">265</span>
|
||||
<span id="266">266</span>
|
||||
<span id="267">267</span>
|
||||
<span id="268">268</span>
|
||||
<span id="269">269</span>
|
||||
<span id="270">270</span>
|
||||
<span id="271">271</span>
|
||||
<span id="272">272</span>
|
||||
<span id="273">273</span>
|
||||
<span id="274">274</span>
|
||||
<span id="275">275</span>
|
||||
<span id="276">276</span>
|
||||
<span id="277">277</span>
|
||||
<span id="278">278</span>
|
||||
<span id="279">279</span>
|
||||
<span id="280">280</span>
|
||||
<span id="281">281</span>
|
||||
<span id="282">282</span>
|
||||
<span id="283">283</span>
|
||||
<span id="284">284</span>
|
||||
<span id="285">285</span>
|
||||
<span id="286">286</span>
|
||||
<span id="287">287</span>
|
||||
<span id="288">288</span>
|
||||
<span id="289">289</span>
|
||||
<span id="290">290</span>
|
||||
<span id="291">291</span>
|
||||
<span id="292">292</span>
|
||||
<span id="293">293</span>
|
||||
<span id="294">294</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">actix::Addr</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_redis</span>::{<span class="ident">resp_array</span>, <span class="ident">Command</span>, <span class="ident">RedisActor</span>, <span class="ident">RespValue</span>};
|
||||
<span class="kw">use</span> <span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>};
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::SessionKey</span>;
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::storage</span>::{
|
||||
<span class="ident">interface</span>::{<span class="ident">LoadError</span>, <span class="ident">SaveError</span>, <span class="ident">SessionState</span>, <span class="ident">UpdateError</span>},
|
||||
<span class="ident">utils::generate_session_key</span>,
|
||||
<span class="ident">SessionStore</span>,
|
||||
};
|
||||
|
||||
<span class="doccomment">/// Use Redis as session storage backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```no_run</span>
|
||||
<span class="doccomment">/// use actix_web::{web, App, HttpServer, HttpResponse, Error};</span>
|
||||
<span class="doccomment">/// use actix_session::{SessionMiddleware, storage::RedisActorSessionStore};</span>
|
||||
<span class="doccomment">/// use actix_web::cookie::Key;</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// // The secret key would usually be read from a configuration file/environment variables.</span>
|
||||
<span class="doccomment">/// fn get_secret_key() -> Key {</span>
|
||||
<span class="doccomment">/// # todo!()</span>
|
||||
<span class="doccomment">/// // [...]</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// #[actix_web::main]</span>
|
||||
<span class="doccomment">/// async fn main() -> std::io::Result<()> {</span>
|
||||
<span class="doccomment">/// let secret_key = get_secret_key();</span>
|
||||
<span class="doccomment">/// let redis_connection_string = "127.0.0.1:6379";</span>
|
||||
<span class="doccomment">/// HttpServer::new(move ||</span>
|
||||
<span class="doccomment">/// App::new()</span>
|
||||
<span class="doccomment">/// .wrap(</span>
|
||||
<span class="doccomment">/// SessionMiddleware::new(</span>
|
||||
<span class="doccomment">/// RedisActorSessionStore::new(redis_connection_string),</span>
|
||||
<span class="doccomment">/// secret_key.clone()</span>
|
||||
<span class="doccomment">/// )</span>
|
||||
<span class="doccomment">/// )</span>
|
||||
<span class="doccomment">/// .default_service(web::to(|| HttpResponse::Ok())))</span>
|
||||
<span class="doccomment">/// .bind(("127.0.0.1", 8080))?</span>
|
||||
<span class="doccomment">/// .run()</span>
|
||||
<span class="doccomment">/// .await</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # Implementation notes</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// `RedisActorSessionStore` leverages `actix-redis`'s `RedisActor` implementation - each thread</span>
|
||||
<span class="doccomment">/// worker gets its own connection to Redis.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ## Limitations</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// `RedisActorSessionStore` does not currently support establishing authenticated connections to</span>
|
||||
<span class="doccomment">/// Redis. Use [`RedisSessionStore`] if you need TLS support.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`RedisSessionStore`]: crate::storage::RedisSessionStore</span>
|
||||
<span class="attribute">#[<span class="ident">cfg_attr</span>(<span class="ident">docsrs</span>, <span class="ident">doc</span>(<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-actor-session"</span>)))]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration</span>,
|
||||
<span class="ident">addr</span>: <span class="ident">Addr</span><span class="op"><</span><span class="ident">RedisActor</span><span class="op">></span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="doccomment">/// A fluent API to configure [`RedisActorSessionStore`].</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// It takes as input the only required input to create a new instance of</span>
|
||||
<span class="doccomment">/// [`RedisActorSessionStore`]—a connection string for Redis.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">builder</span><span class="op"><</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op"><</span><span class="ident">String</span><span class="op">></span><span class="op">></span>(<span class="ident">connection_string</span>: <span class="ident">S</span>) -> <span class="ident">RedisActorSessionStoreBuilder</span> {
|
||||
<span class="ident">RedisActorSessionStoreBuilder</span> {
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration::default</span>(),
|
||||
<span class="ident">connection_string</span>: <span class="ident">connection_string</span>.<span class="ident">into</span>(),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Create a new instance of [`RedisActorSessionStore`] using the default configuration.</span>
|
||||
<span class="doccomment">/// It takes as input the only required input to create a new instance of [`RedisActorSessionStore`] - a</span>
|
||||
<span class="doccomment">/// connection string for Redis.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span><span class="op"><</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op"><</span><span class="ident">String</span><span class="op">></span><span class="op">></span>(<span class="ident">connection_string</span>: <span class="ident">S</span>) -> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="ident"><span class="self">Self</span>::builder</span>(<span class="ident">connection_string</span>).<span class="ident">build</span>()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">struct</span> <span class="ident">CacheConfiguration</span> {
|
||||
<span class="ident">cache_keygen</span>: <span class="ident">Box</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&</span><span class="ident">str</span>) -> <span class="ident">String</span><span class="op">></span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">CacheConfiguration</span> {
|
||||
<span class="kw">fn</span> <span class="ident">default</span>() -> <span class="self">Self</span> {
|
||||
<span class="self">Self</span> {
|
||||
<span class="ident">cache_keygen</span>: <span class="ident">Box::new</span>(<span class="ident">str::to_owned</span>),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// A fluent builder to construct a [`RedisActorSessionStore`] instance with custom configuration</span>
|
||||
<span class="doccomment">/// parameters.</span>
|
||||
<span class="attribute">#[<span class="ident">cfg_attr</span>(<span class="ident">docsrs</span>, <span class="ident">doc</span>(<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-actor-session"</span>)))]</span>
|
||||
<span class="attribute">#[<span class="ident">must_use</span>]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">RedisActorSessionStoreBuilder</span> {
|
||||
<span class="ident">connection_string</span>: <span class="ident">String</span>,
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">RedisActorSessionStoreBuilder</span> {
|
||||
<span class="doccomment">/// Set a custom cache key generation strategy, expecting a session key as input.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cache_keygen</span><span class="op"><</span><span class="ident">F</span><span class="op">></span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">keygen</span>: <span class="ident">F</span>) -> <span class="self">Self</span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="kw-2">&</span><span class="ident">str</span>) -> <span class="ident">String</span> <span class="op">+</span> <span class="lifetime">'static</span>,
|
||||
{
|
||||
<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span> <span class="op">=</span> <span class="ident">Box::new</span>(<span class="ident">keygen</span>);
|
||||
<span class="self">self</span>
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Finalise the builder and return a [`RedisActorSessionStore`] instance.</span>
|
||||
<span class="attribute">#[<span class="ident">must_use</span>]</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">build</span>(<span class="self">self</span>) -> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="ident">configuration</span>: <span class="self">self</span>.<span class="ident">configuration</span>,
|
||||
<span class="ident">addr</span>: <span class="ident">RedisActor::start</span>(<span class="self">self</span>.<span class="ident">connection_string</span>),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">async_trait::async_trait</span>(<span class="question-mark">?</span><span class="ident">Send</span>)]</span>
|
||||
<span class="kw">impl</span> <span class="ident">SessionStore</span> <span class="kw">for</span> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">load</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">SessionState</span><span class="op">></span>, <span class="ident">LoadError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="self">self</span>
|
||||
.<span class="ident">addr</span>
|
||||
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array!</span>[<span class="string">"GET"</span>, <span class="ident">cache_key</span>]))
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Other</span>)<span class="question-mark">?</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">val</span> {
|
||||
<span class="ident">RespValue::Error</span>(<span class="ident">err</span>) => <span class="prelude-val">Err</span>(<span class="ident">LoadError::Other</span>(<span class="macro">anyhow::anyhow!</span>(<span class="ident">err</span>))),
|
||||
|
||||
<span class="ident">RespValue::SimpleString</span>(<span class="ident">s</span>) => <span class="prelude-val">Ok</span>(<span class="ident">serde_json::from_str</span>(<span class="kw-2">&</span><span class="ident">s</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Deserialization</span>)<span class="question-mark">?</span>),
|
||||
|
||||
<span class="ident">RespValue::BulkString</span>(<span class="ident">s</span>) => <span class="prelude-val">Ok</span>(<span class="ident">serde_json::from_slice</span>(<span class="kw-2">&</span><span class="ident">s</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Deserialization</span>)<span class="question-mark">?</span>),
|
||||
|
||||
<span class="kw">_</span> => <span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">save</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">SaveError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">session_state</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Serialization</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command</span>(<span class="macro">resp_array!</span>[
|
||||
<span class="string">"SET"</span>,
|
||||
<span class="ident">cache_key</span>,
|
||||
<span class="ident">body</span>,
|
||||
<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>, <span class="ident">ttl</span>.<span class="ident">whole_seconds</span>())
|
||||
]);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="self">self</span>
|
||||
.<span class="ident">addr</span>
|
||||
.<span class="ident">send</span>(<span class="ident">cmd</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Other</span>)<span class="question-mark">?</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">result</span> {
|
||||
<span class="ident">RespValue::SimpleString</span>(<span class="kw">_</span>) => <span class="prelude-val">Ok</span>(<span class="ident">session_key</span>),
|
||||
<span class="ident">RespValue::Nil</span> => <span class="prelude-val">Err</span>(<span class="ident">SaveError::Other</span>(<span class="macro">anyhow::anyhow!</span>(
|
||||
<span class="string">"Failed to save session state. A record with the same key already existed in Redis"</span>
|
||||
))),
|
||||
<span class="ident">err</span> => <span class="prelude-val">Err</span>(<span class="ident">SaveError::Other</span>(<span class="macro">anyhow::anyhow!</span>(
|
||||
<span class="string">"Failed to save session state. {:?}"</span>,
|
||||
<span class="ident">err</span>
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">update</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_key</span>: <span class="ident">SessionKey</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">UpdateError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">session_state</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Serialization</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">cmd</span> <span class="op">=</span> <span class="ident">Command</span>(<span class="macro">resp_array!</span>[
|
||||
<span class="string">"SET"</span>,
|
||||
<span class="ident">cache_key</span>,
|
||||
<span class="ident">body</span>,
|
||||
<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>, <span class="ident">ttl</span>.<span class="ident">whole_seconds</span>())
|
||||
]);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="self">self</span>
|
||||
.<span class="ident">addr</span>
|
||||
.<span class="ident">send</span>(<span class="ident">cmd</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Other</span>)<span class="question-mark">?</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">result</span> {
|
||||
<span class="ident">RespValue::Nil</span> => {
|
||||
<span class="comment">// The SET operation was not performed because the XX condition was not verified.</span>
|
||||
<span class="comment">// This can happen if the session state expired between the load operation and the</span>
|
||||
<span class="comment">// update operation. Unlucky, to say the least. We fall back to the `save` routine</span>
|
||||
<span class="comment">// to ensure that the new key is unique.</span>
|
||||
<span class="self">self</span>.<span class="ident">save</span>(<span class="ident">session_state</span>, <span class="ident">ttl</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">err</span> {
|
||||
<span class="ident">SaveError::Serialization</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Serialization</span>(<span class="ident">err</span>),
|
||||
<span class="ident">SaveError::Other</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Other</span>(<span class="ident">err</span>),
|
||||
})
|
||||
}
|
||||
<span class="ident">RespValue::SimpleString</span>(<span class="kw">_</span>) => <span class="prelude-val">Ok</span>(<span class="ident">session_key</span>),
|
||||
<span class="ident">val</span> => <span class="prelude-val">Err</span>(<span class="ident">UpdateError::Other</span>(<span class="macro">anyhow::anyhow!</span>(
|
||||
<span class="string">"Failed to update session state. {:?}"</span>,
|
||||
<span class="ident">val</span>
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">delete</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">anyhow::Error</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="self">self</span>
|
||||
.<span class="ident">addr</span>
|
||||
.<span class="ident">send</span>(<span class="ident">Command</span>(<span class="macro">resp_array!</span>[<span class="string">"DEL"</span>, <span class="ident">cache_key</span>]))
|
||||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">res</span> {
|
||||
<span class="comment">// Redis returns the number of deleted records</span>
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">RespValue::Integer</span>(<span class="kw">_</span>)) => <span class="prelude-val">Ok</span>(()),
|
||||
<span class="ident">val</span> => <span class="prelude-val">Err</span>(<span class="macro">anyhow::anyhow!</span>(
|
||||
<span class="string">"Failed to remove session from cache. {:?}"</span>,
|
||||
<span class="ident">val</span>
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">test</span> {
|
||||
<span class="kw">use</span> <span class="ident">std::collections::HashMap</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::test_helpers::acceptance_test_suite</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">redis_actor_store</span>() -> <span class="ident">RedisActorSessionStore</span> {
|
||||
<span class="ident">RedisActorSessionStore::new</span>(<span class="string">"127.0.0.1:6379"</span>)
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_session_workflow</span>() {
|
||||
<span class="ident">acceptance_test_suite</span>(<span class="ident">redis_actor_store</span>, <span class="bool-val">true</span>).<span class="kw">await</span>;
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">loading_a_missing_session_returns_none</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">redis_actor_store</span>();
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="macro">assert!</span>(<span class="ident">store</span>.<span class="ident">load</span>(<span class="kw-2">&</span><span class="ident">session_key</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>().<span class="ident">is_none</span>());
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">updating_of_an_expired_state_is_handled_gracefully</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">redis_actor_store</span>();
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="kw">let</span> <span class="ident">initial_session_key</span> <span class="op">=</span> <span class="ident">session_key</span>.<span class="ident">as_ref</span>().<span class="ident">to_owned</span>();
|
||||
<span class="kw">let</span> <span class="ident">updated_session_key</span> <span class="op">=</span> <span class="ident">store</span>
|
||||
.<span class="ident">update</span>(<span class="ident">session_key</span>, <span class="ident">HashMap::new</span>(), <span class="kw-2">&</span><span class="ident">time::Duration::seconds</span>(<span class="number">1</span>))
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">unwrap</span>();
|
||||
<span class="macro">assert_ne!</span>(<span class="ident">initial_session_key</span>, <span class="ident">updated_session_key</span>.<span class="ident">as_ref</span>());
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
604
src/actix_session/storage/redis_rs.rs.html
Normal file
604
src/actix_session/storage/redis_rs.rs.html
Normal file
@@ -0,0 +1,604 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>redis_rs.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10"> 10</span>
|
||||
<span id="11"> 11</span>
|
||||
<span id="12"> 12</span>
|
||||
<span id="13"> 13</span>
|
||||
<span id="14"> 14</span>
|
||||
<span id="15"> 15</span>
|
||||
<span id="16"> 16</span>
|
||||
<span id="17"> 17</span>
|
||||
<span id="18"> 18</span>
|
||||
<span id="19"> 19</span>
|
||||
<span id="20"> 20</span>
|
||||
<span id="21"> 21</span>
|
||||
<span id="22"> 22</span>
|
||||
<span id="23"> 23</span>
|
||||
<span id="24"> 24</span>
|
||||
<span id="25"> 25</span>
|
||||
<span id="26"> 26</span>
|
||||
<span id="27"> 27</span>
|
||||
<span id="28"> 28</span>
|
||||
<span id="29"> 29</span>
|
||||
<span id="30"> 30</span>
|
||||
<span id="31"> 31</span>
|
||||
<span id="32"> 32</span>
|
||||
<span id="33"> 33</span>
|
||||
<span id="34"> 34</span>
|
||||
<span id="35"> 35</span>
|
||||
<span id="36"> 36</span>
|
||||
<span id="37"> 37</span>
|
||||
<span id="38"> 38</span>
|
||||
<span id="39"> 39</span>
|
||||
<span id="40"> 40</span>
|
||||
<span id="41"> 41</span>
|
||||
<span id="42"> 42</span>
|
||||
<span id="43"> 43</span>
|
||||
<span id="44"> 44</span>
|
||||
<span id="45"> 45</span>
|
||||
<span id="46"> 46</span>
|
||||
<span id="47"> 47</span>
|
||||
<span id="48"> 48</span>
|
||||
<span id="49"> 49</span>
|
||||
<span id="50"> 50</span>
|
||||
<span id="51"> 51</span>
|
||||
<span id="52"> 52</span>
|
||||
<span id="53"> 53</span>
|
||||
<span id="54"> 54</span>
|
||||
<span id="55"> 55</span>
|
||||
<span id="56"> 56</span>
|
||||
<span id="57"> 57</span>
|
||||
<span id="58"> 58</span>
|
||||
<span id="59"> 59</span>
|
||||
<span id="60"> 60</span>
|
||||
<span id="61"> 61</span>
|
||||
<span id="62"> 62</span>
|
||||
<span id="63"> 63</span>
|
||||
<span id="64"> 64</span>
|
||||
<span id="65"> 65</span>
|
||||
<span id="66"> 66</span>
|
||||
<span id="67"> 67</span>
|
||||
<span id="68"> 68</span>
|
||||
<span id="69"> 69</span>
|
||||
<span id="70"> 70</span>
|
||||
<span id="71"> 71</span>
|
||||
<span id="72"> 72</span>
|
||||
<span id="73"> 73</span>
|
||||
<span id="74"> 74</span>
|
||||
<span id="75"> 75</span>
|
||||
<span id="76"> 76</span>
|
||||
<span id="77"> 77</span>
|
||||
<span id="78"> 78</span>
|
||||
<span id="79"> 79</span>
|
||||
<span id="80"> 80</span>
|
||||
<span id="81"> 81</span>
|
||||
<span id="82"> 82</span>
|
||||
<span id="83"> 83</span>
|
||||
<span id="84"> 84</span>
|
||||
<span id="85"> 85</span>
|
||||
<span id="86"> 86</span>
|
||||
<span id="87"> 87</span>
|
||||
<span id="88"> 88</span>
|
||||
<span id="89"> 89</span>
|
||||
<span id="90"> 90</span>
|
||||
<span id="91"> 91</span>
|
||||
<span id="92"> 92</span>
|
||||
<span id="93"> 93</span>
|
||||
<span id="94"> 94</span>
|
||||
<span id="95"> 95</span>
|
||||
<span id="96"> 96</span>
|
||||
<span id="97"> 97</span>
|
||||
<span id="98"> 98</span>
|
||||
<span id="99"> 99</span>
|
||||
<span id="100">100</span>
|
||||
<span id="101">101</span>
|
||||
<span id="102">102</span>
|
||||
<span id="103">103</span>
|
||||
<span id="104">104</span>
|
||||
<span id="105">105</span>
|
||||
<span id="106">106</span>
|
||||
<span id="107">107</span>
|
||||
<span id="108">108</span>
|
||||
<span id="109">109</span>
|
||||
<span id="110">110</span>
|
||||
<span id="111">111</span>
|
||||
<span id="112">112</span>
|
||||
<span id="113">113</span>
|
||||
<span id="114">114</span>
|
||||
<span id="115">115</span>
|
||||
<span id="116">116</span>
|
||||
<span id="117">117</span>
|
||||
<span id="118">118</span>
|
||||
<span id="119">119</span>
|
||||
<span id="120">120</span>
|
||||
<span id="121">121</span>
|
||||
<span id="122">122</span>
|
||||
<span id="123">123</span>
|
||||
<span id="124">124</span>
|
||||
<span id="125">125</span>
|
||||
<span id="126">126</span>
|
||||
<span id="127">127</span>
|
||||
<span id="128">128</span>
|
||||
<span id="129">129</span>
|
||||
<span id="130">130</span>
|
||||
<span id="131">131</span>
|
||||
<span id="132">132</span>
|
||||
<span id="133">133</span>
|
||||
<span id="134">134</span>
|
||||
<span id="135">135</span>
|
||||
<span id="136">136</span>
|
||||
<span id="137">137</span>
|
||||
<span id="138">138</span>
|
||||
<span id="139">139</span>
|
||||
<span id="140">140</span>
|
||||
<span id="141">141</span>
|
||||
<span id="142">142</span>
|
||||
<span id="143">143</span>
|
||||
<span id="144">144</span>
|
||||
<span id="145">145</span>
|
||||
<span id="146">146</span>
|
||||
<span id="147">147</span>
|
||||
<span id="148">148</span>
|
||||
<span id="149">149</span>
|
||||
<span id="150">150</span>
|
||||
<span id="151">151</span>
|
||||
<span id="152">152</span>
|
||||
<span id="153">153</span>
|
||||
<span id="154">154</span>
|
||||
<span id="155">155</span>
|
||||
<span id="156">156</span>
|
||||
<span id="157">157</span>
|
||||
<span id="158">158</span>
|
||||
<span id="159">159</span>
|
||||
<span id="160">160</span>
|
||||
<span id="161">161</span>
|
||||
<span id="162">162</span>
|
||||
<span id="163">163</span>
|
||||
<span id="164">164</span>
|
||||
<span id="165">165</span>
|
||||
<span id="166">166</span>
|
||||
<span id="167">167</span>
|
||||
<span id="168">168</span>
|
||||
<span id="169">169</span>
|
||||
<span id="170">170</span>
|
||||
<span id="171">171</span>
|
||||
<span id="172">172</span>
|
||||
<span id="173">173</span>
|
||||
<span id="174">174</span>
|
||||
<span id="175">175</span>
|
||||
<span id="176">176</span>
|
||||
<span id="177">177</span>
|
||||
<span id="178">178</span>
|
||||
<span id="179">179</span>
|
||||
<span id="180">180</span>
|
||||
<span id="181">181</span>
|
||||
<span id="182">182</span>
|
||||
<span id="183">183</span>
|
||||
<span id="184">184</span>
|
||||
<span id="185">185</span>
|
||||
<span id="186">186</span>
|
||||
<span id="187">187</span>
|
||||
<span id="188">188</span>
|
||||
<span id="189">189</span>
|
||||
<span id="190">190</span>
|
||||
<span id="191">191</span>
|
||||
<span id="192">192</span>
|
||||
<span id="193">193</span>
|
||||
<span id="194">194</span>
|
||||
<span id="195">195</span>
|
||||
<span id="196">196</span>
|
||||
<span id="197">197</span>
|
||||
<span id="198">198</span>
|
||||
<span id="199">199</span>
|
||||
<span id="200">200</span>
|
||||
<span id="201">201</span>
|
||||
<span id="202">202</span>
|
||||
<span id="203">203</span>
|
||||
<span id="204">204</span>
|
||||
<span id="205">205</span>
|
||||
<span id="206">206</span>
|
||||
<span id="207">207</span>
|
||||
<span id="208">208</span>
|
||||
<span id="209">209</span>
|
||||
<span id="210">210</span>
|
||||
<span id="211">211</span>
|
||||
<span id="212">212</span>
|
||||
<span id="213">213</span>
|
||||
<span id="214">214</span>
|
||||
<span id="215">215</span>
|
||||
<span id="216">216</span>
|
||||
<span id="217">217</span>
|
||||
<span id="218">218</span>
|
||||
<span id="219">219</span>
|
||||
<span id="220">220</span>
|
||||
<span id="221">221</span>
|
||||
<span id="222">222</span>
|
||||
<span id="223">223</span>
|
||||
<span id="224">224</span>
|
||||
<span id="225">225</span>
|
||||
<span id="226">226</span>
|
||||
<span id="227">227</span>
|
||||
<span id="228">228</span>
|
||||
<span id="229">229</span>
|
||||
<span id="230">230</span>
|
||||
<span id="231">231</span>
|
||||
<span id="232">232</span>
|
||||
<span id="233">233</span>
|
||||
<span id="234">234</span>
|
||||
<span id="235">235</span>
|
||||
<span id="236">236</span>
|
||||
<span id="237">237</span>
|
||||
<span id="238">238</span>
|
||||
<span id="239">239</span>
|
||||
<span id="240">240</span>
|
||||
<span id="241">241</span>
|
||||
<span id="242">242</span>
|
||||
<span id="243">243</span>
|
||||
<span id="244">244</span>
|
||||
<span id="245">245</span>
|
||||
<span id="246">246</span>
|
||||
<span id="247">247</span>
|
||||
<span id="248">248</span>
|
||||
<span id="249">249</span>
|
||||
<span id="250">250</span>
|
||||
<span id="251">251</span>
|
||||
<span id="252">252</span>
|
||||
<span id="253">253</span>
|
||||
<span id="254">254</span>
|
||||
<span id="255">255</span>
|
||||
<span id="256">256</span>
|
||||
<span id="257">257</span>
|
||||
<span id="258">258</span>
|
||||
<span id="259">259</span>
|
||||
<span id="260">260</span>
|
||||
<span id="261">261</span>
|
||||
<span id="262">262</span>
|
||||
<span id="263">263</span>
|
||||
<span id="264">264</span>
|
||||
<span id="265">265</span>
|
||||
<span id="266">266</span>
|
||||
<span id="267">267</span>
|
||||
<span id="268">268</span>
|
||||
<span id="269">269</span>
|
||||
<span id="270">270</span>
|
||||
<span id="271">271</span>
|
||||
<span id="272">272</span>
|
||||
<span id="273">273</span>
|
||||
<span id="274">274</span>
|
||||
<span id="275">275</span>
|
||||
<span id="276">276</span>
|
||||
<span id="277">277</span>
|
||||
<span id="278">278</span>
|
||||
<span id="279">279</span>
|
||||
<span id="280">280</span>
|
||||
<span id="281">281</span>
|
||||
<span id="282">282</span>
|
||||
<span id="283">283</span>
|
||||
<span id="284">284</span>
|
||||
<span id="285">285</span>
|
||||
<span id="286">286</span>
|
||||
<span id="287">287</span>
|
||||
<span id="288">288</span>
|
||||
<span id="289">289</span>
|
||||
<span id="290">290</span>
|
||||
<span id="291">291</span>
|
||||
<span id="292">292</span>
|
||||
<span id="293">293</span>
|
||||
<span id="294">294</span>
|
||||
<span id="295">295</span>
|
||||
<span id="296">296</span>
|
||||
<span id="297">297</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::sync::Arc</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">redis</span>::{<span class="ident">aio::ConnectionManager</span>, <span class="ident">AsyncCommands</span>, <span class="ident">Value</span>};
|
||||
<span class="kw">use</span> <span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>};
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">super</span>::SessionKey</span>;
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::storage</span>::{
|
||||
<span class="ident">interface</span>::{<span class="ident">LoadError</span>, <span class="ident">SaveError</span>, <span class="ident">SessionState</span>, <span class="ident">UpdateError</span>},
|
||||
<span class="ident">utils::generate_session_key</span>,
|
||||
<span class="ident">SessionStore</span>,
|
||||
};
|
||||
|
||||
<span class="doccomment">/// Use Redis as session storage backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```no_run</span>
|
||||
<span class="doccomment">/// use actix_web::{web, App, HttpServer, HttpResponse, Error};</span>
|
||||
<span class="doccomment">/// use actix_session::{SessionMiddleware, storage::RedisSessionStore};</span>
|
||||
<span class="doccomment">/// use actix_web::cookie::Key;</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// // The secret key would usually be read from a configuration file/environment variables.</span>
|
||||
<span class="doccomment">/// fn get_secret_key() -> Key {</span>
|
||||
<span class="doccomment">/// # todo!()</span>
|
||||
<span class="doccomment">/// // [...]</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// #[actix_web::main]</span>
|
||||
<span class="doccomment">/// async fn main() -> std::io::Result<()> {</span>
|
||||
<span class="doccomment">/// let secret_key = get_secret_key();</span>
|
||||
<span class="doccomment">/// let redis_connection_string = "redis://127.0.0.1:6379";</span>
|
||||
<span class="doccomment">/// let store = RedisSessionStore::new(redis_connection_string).await.unwrap();</span>
|
||||
<span class="doccomment">/// HttpServer::new(move ||</span>
|
||||
<span class="doccomment">/// App::new()</span>
|
||||
<span class="doccomment">/// .wrap(SessionMiddleware::new(</span>
|
||||
<span class="doccomment">/// store.clone(),</span>
|
||||
<span class="doccomment">/// secret_key.clone()</span>
|
||||
<span class="doccomment">/// ))</span>
|
||||
<span class="doccomment">/// .default_service(web::to(|| HttpResponse::Ok())))</span>
|
||||
<span class="doccomment">/// .bind(("127.0.0.1", 8080))?</span>
|
||||
<span class="doccomment">/// .run()</span>
|
||||
<span class="doccomment">/// .await</span>
|
||||
<span class="doccomment">/// }</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # TLS support</span>
|
||||
<span class="doccomment">/// Add the `redis-rs-tls-session` feature flag to enable TLS support. You can then establish a TLS</span>
|
||||
<span class="doccomment">/// connection to Redis using the `rediss://` URL scheme:</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```no_run</span>
|
||||
<span class="doccomment">/// use actix_session::{storage::RedisSessionStore};</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # actix_web::rt::System::new().block_on(async {</span>
|
||||
<span class="doccomment">/// let redis_connection_string = "rediss://127.0.0.1:6379";</span>
|
||||
<span class="doccomment">/// let store = RedisSessionStore::new(redis_connection_string).await.unwrap();</span>
|
||||
<span class="doccomment">/// # })</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// # Implementation notes</span>
|
||||
<span class="doccomment">/// `RedisSessionStore` leverages [`redis-rs`] as Redis client.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`redis-rs`]: https://github.com/mitsuhiko/redis-rs</span>
|
||||
<span class="attribute">#[<span class="ident">cfg_attr</span>(<span class="ident">docsrs</span>, <span class="ident">doc</span>(<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-rs-session"</span>)))]</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">RedisSessionStore</span> {
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration</span>,
|
||||
<span class="ident">client</span>: <span class="ident">ConnectionManager</span>,
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>)]</span>
|
||||
<span class="kw">struct</span> <span class="ident">CacheConfiguration</span> {
|
||||
<span class="ident">cache_keygen</span>: <span class="ident">Arc</span><span class="op"><</span><span class="kw">dyn</span> <span class="ident">Fn</span>(<span class="kw-2">&</span><span class="ident">str</span>) -> <span class="ident">String</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span><span class="op">></span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Default</span> <span class="kw">for</span> <span class="ident">CacheConfiguration</span> {
|
||||
<span class="kw">fn</span> <span class="ident">default</span>() -> <span class="self">Self</span> {
|
||||
<span class="self">Self</span> {
|
||||
<span class="ident">cache_keygen</span>: <span class="ident">Arc::new</span>(<span class="ident">str::to_owned</span>),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">RedisSessionStore</span> {
|
||||
<span class="doccomment">/// A fluent API to configure [`RedisSessionStore`].</span>
|
||||
<span class="doccomment">/// It takes as input the only required input to create a new instance of [`RedisSessionStore`] - a</span>
|
||||
<span class="doccomment">/// connection string for Redis.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">builder</span><span class="op"><</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op"><</span><span class="ident">String</span><span class="op">></span><span class="op">></span>(<span class="ident">connection_string</span>: <span class="ident">S</span>) -> <span class="ident">RedisSessionStoreBuilder</span> {
|
||||
<span class="ident">RedisSessionStoreBuilder</span> {
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration::default</span>(),
|
||||
<span class="ident">connection_string</span>: <span class="ident">connection_string</span>.<span class="ident">into</span>(),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Create a new instance of [`RedisSessionStore`] using the default configuration.</span>
|
||||
<span class="doccomment">/// It takes as input the only required input to create a new instance of [`RedisSessionStore`] - a</span>
|
||||
<span class="doccomment">/// connection string for Redis.</span>
|
||||
<span class="kw">pub</span> <span class="kw">async</span> <span class="kw">fn</span> <span class="ident">new</span><span class="op"><</span><span class="ident">S</span>: <span class="ident">Into</span><span class="op"><</span><span class="ident">String</span><span class="op">></span><span class="op">></span>(
|
||||
<span class="ident">connection_string</span>: <span class="ident">S</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">RedisSessionStore</span>, <span class="ident">anyhow::Error</span><span class="op">></span> {
|
||||
<span class="ident"><span class="self">Self</span>::builder</span>(<span class="ident">connection_string</span>).<span class="ident">build</span>().<span class="kw">await</span>
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// A fluent builder to construct a [`RedisSessionStore`] instance with custom configuration</span>
|
||||
<span class="doccomment">/// parameters.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`RedisSessionStore`]: crate::storage::RedisSessionStore</span>
|
||||
<span class="attribute">#[<span class="ident">cfg_attr</span>(<span class="ident">docsrs</span>, <span class="ident">doc</span>(<span class="ident">cfg</span>(<span class="ident">feature</span> <span class="op">=</span> <span class="string">"redis-rs-session"</span>)))]</span>
|
||||
<span class="attribute">#[<span class="ident">must_use</span>]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">RedisSessionStoreBuilder</span> {
|
||||
<span class="ident">connection_string</span>: <span class="ident">String</span>,
|
||||
<span class="ident">configuration</span>: <span class="ident">CacheConfiguration</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">RedisSessionStoreBuilder</span> {
|
||||
<span class="doccomment">/// Set a custom cache key generation strategy, expecting a session key as input.</span>
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">cache_keygen</span><span class="op"><</span><span class="ident">F</span><span class="op">></span>(<span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">keygen</span>: <span class="ident">F</span>) -> <span class="self">Self</span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">F</span>: <span class="ident">Fn</span>(<span class="kw-2">&</span><span class="ident">str</span>) -> <span class="ident">String</span> <span class="op">+</span> <span class="lifetime">'static</span> <span class="op">+</span> <span class="ident">Send</span> <span class="op">+</span> <span class="ident">Sync</span>,
|
||||
{
|
||||
<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span> <span class="op">=</span> <span class="ident">Arc::new</span>(<span class="ident">keygen</span>);
|
||||
<span class="self">self</span>
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Finalise the builder and return a [`RedisActorSessionStore`] instance.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [`RedisActorSessionStore`]: crate::storage::RedisActorSessionStore</span>
|
||||
<span class="kw">pub</span> <span class="kw">async</span> <span class="kw">fn</span> <span class="ident">build</span>(<span class="self">self</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">RedisSessionStore</span>, <span class="ident">anyhow::Error</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">client</span> <span class="op">=</span> <span class="ident">ConnectionManager::new</span>(<span class="ident">redis::Client::open</span>(<span class="self">self</span>.<span class="ident">connection_string</span>)<span class="question-mark">?</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">RedisSessionStore</span> {
|
||||
<span class="ident">configuration</span>: <span class="self">self</span>.<span class="ident">configuration</span>,
|
||||
<span class="ident">client</span>,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">async_trait::async_trait</span>(<span class="question-mark">?</span><span class="ident">Send</span>)]</span>
|
||||
<span class="kw">impl</span> <span class="ident">SessionStore</span> <span class="kw">for</span> <span class="ident">RedisSessionStore</span> {
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">load</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">SessionState</span><span class="op">></span>, <span class="ident">LoadError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
<span class="kw">let</span> <span class="ident">value</span>: <span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">String</span><span class="op">></span> <span class="op">=</span> <span class="self">self</span>
|
||||
.<span class="ident">client</span>
|
||||
.<span class="ident">clone</span>()
|
||||
.<span class="ident">get</span>(<span class="ident">cache_key</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">value</span> {
|
||||
<span class="prelude-val">None</span> => <span class="prelude-val">Ok</span>(<span class="prelude-val">None</span>),
|
||||
<span class="prelude-val">Some</span>(<span class="ident">value</span>) => <span class="prelude-val">Ok</span>(<span class="ident">serde_json::from_str</span>(<span class="kw-2">&</span><span class="ident">value</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">LoadError::Deserialization</span>)<span class="question-mark">?</span>),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">save</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">SaveError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">session_state</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Serialization</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="ident">redis::cmd</span>(<span class="string">"SET"</span>)
|
||||
.<span class="ident">arg</span>(<span class="kw-2">&</span>[
|
||||
<span class="kw-2">&</span><span class="ident">cache_key</span>,
|
||||
<span class="kw-2">&</span><span class="ident">body</span>,
|
||||
<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">&</span><span class="macro">format!</span>(<span class="string">"{}"</span>, <span class="ident">ttl</span>.<span class="ident">whole_seconds</span>()),
|
||||
])
|
||||
.<span class="ident">query_async</span>(<span class="kw-2">&mut</span> <span class="self">self</span>.<span class="ident">client</span>.<span class="ident">clone</span>())
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">SaveError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">session_key</span>)
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">update</span>(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
<span class="ident">session_key</span>: <span class="ident">SessionKey</span>,
|
||||
<span class="ident">session_state</span>: <span class="ident">SessionState</span>,
|
||||
<span class="ident">ttl</span>: <span class="kw-2">&</span><span class="ident">Duration</span>,
|
||||
) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">SessionKey</span>, <span class="ident">UpdateError</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">serde_json::to_string</span>(<span class="kw-2">&</span><span class="ident">session_state</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Serialization</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">v</span>: <span class="ident">redis::Value</span> <span class="op">=</span> <span class="ident">redis::cmd</span>(<span class="string">"SET"</span>)
|
||||
.<span class="ident">arg</span>(<span class="kw-2">&</span>[
|
||||
<span class="kw-2">&</span><span class="ident">cache_key</span>,
|
||||
<span class="kw-2">&</span><span class="ident">body</span>,
|
||||
<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">&</span><span class="macro">format!</span>(<span class="string">"{}"</span>, <span class="ident">ttl</span>.<span class="ident">whole_seconds</span>()),
|
||||
])
|
||||
.<span class="ident">query_async</span>(<span class="kw-2">&mut</span> <span class="self">self</span>.<span class="ident">client</span>.<span class="ident">clone</span>())
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">v</span> {
|
||||
<span class="ident">Value::Nil</span> => {
|
||||
<span class="comment">// The SET operation was not performed because the XX condition was not verified.</span>
|
||||
<span class="comment">// This can happen if the session state expired between the load operation and the</span>
|
||||
<span class="comment">// update operation. Unlucky, to say the least. We fall back to the `save` routine</span>
|
||||
<span class="comment">// to ensure that the new key is unique.</span>
|
||||
<span class="self">self</span>.<span class="ident">save</span>(<span class="ident">session_state</span>, <span class="ident">ttl</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">err</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">err</span> {
|
||||
<span class="ident">SaveError::Serialization</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Serialization</span>(<span class="ident">err</span>),
|
||||
<span class="ident">SaveError::Other</span>(<span class="ident">err</span>) => <span class="ident">UpdateError::Other</span>(<span class="ident">err</span>),
|
||||
})
|
||||
}
|
||||
<span class="ident">Value::Int</span>(<span class="kw">_</span>) <span class="op">|</span> <span class="ident">Value::Okay</span> <span class="op">|</span> <span class="ident">Value::Status</span>(<span class="kw">_</span>) => <span class="prelude-val">Ok</span>(<span class="ident">session_key</span>),
|
||||
<span class="ident">val</span> => <span class="prelude-val">Err</span>(<span class="ident">UpdateError::Other</span>(<span class="macro">anyhow::anyhow!</span>(
|
||||
<span class="string">"Failed to update session state. {:?}"</span>,
|
||||
<span class="ident">val</span>
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">delete</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">session_key</span>: <span class="kw-2">&</span><span class="ident">SessionKey</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">anyhow::Error</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">cache_key</span> <span class="op">=</span> (<span class="self">self</span>.<span class="ident">configuration</span>.<span class="ident">cache_keygen</span>)(<span class="ident">session_key</span>.<span class="ident">as_ref</span>());
|
||||
|
||||
<span class="self">self</span>.<span class="ident">client</span>
|
||||
.<span class="ident">clone</span>()
|
||||
.<span class="ident">del</span>(<span class="kw-2">&</span><span class="ident">cache_key</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">map_err</span>(<span class="ident">Into::into</span>)
|
||||
.<span class="ident">map_err</span>(<span class="ident">UpdateError::Other</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">test</span> {
|
||||
<span class="kw">use</span> <span class="ident">std::collections::HashMap</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">redis::AsyncCommands</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::test_helpers::acceptance_test_suite</span>;
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">redis_store</span>() -> <span class="ident">RedisSessionStore</span> {
|
||||
<span class="ident">RedisSessionStore::new</span>(<span class="string">"redis://127.0.0.1:6379"</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">unwrap</span>()
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">test_session_workflow</span>() {
|
||||
<span class="kw">let</span> <span class="ident">redis_store</span> <span class="op">=</span> <span class="ident">redis_store</span>().<span class="kw">await</span>;
|
||||
<span class="ident">acceptance_test_suite</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> <span class="ident">redis_store</span>.<span class="ident">clone</span>(), <span class="bool-val">true</span>).<span class="kw">await</span>;
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">loading_a_missing_session_returns_none</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">redis_store</span>().<span class="kw">await</span>;
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="macro">assert!</span>(<span class="ident">store</span>.<span class="ident">load</span>(<span class="kw-2">&</span><span class="ident">session_key</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>().<span class="ident">is_none</span>());
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">loading_an_invalid_session_state_returns_deserialization_error</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">redis_store</span>().<span class="kw">await</span>;
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="ident">store</span>
|
||||
.<span class="ident">client</span>
|
||||
.<span class="ident">clone</span>()
|
||||
.<span class="ident">set</span>::<span class="op"><</span><span class="kw">_</span>, <span class="kw">_</span>, ()<span class="op">></span>(<span class="ident">session_key</span>.<span class="ident">as_ref</span>(), <span class="string">"random-thing-which-is-not-json"</span>)
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">unwrap</span>();
|
||||
<span class="macro">assert!</span>(<span class="macro">matches!</span>(
|
||||
<span class="ident">store</span>.<span class="ident">load</span>(<span class="kw-2">&</span><span class="ident">session_key</span>).<span class="kw">await</span>.<span class="ident">unwrap_err</span>(),
|
||||
<span class="ident">LoadError::Deserialization</span>(<span class="kw">_</span>),
|
||||
));
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">actix_web::test</span>]</span>
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">updating_of_an_expired_state_is_handled_gracefully</span>() {
|
||||
<span class="kw">let</span> <span class="ident">store</span> <span class="op">=</span> <span class="ident">redis_store</span>().<span class="kw">await</span>;
|
||||
<span class="kw">let</span> <span class="ident">session_key</span> <span class="op">=</span> <span class="ident">generate_session_key</span>();
|
||||
<span class="kw">let</span> <span class="ident">initial_session_key</span> <span class="op">=</span> <span class="ident">session_key</span>.<span class="ident">as_ref</span>().<span class="ident">to_owned</span>();
|
||||
<span class="kw">let</span> <span class="ident">updated_session_key</span> <span class="op">=</span> <span class="ident">store</span>
|
||||
.<span class="ident">update</span>(<span class="ident">session_key</span>, <span class="ident">HashMap::new</span>(), <span class="kw-2">&</span><span class="ident">time::Duration::seconds</span>(<span class="number">1</span>))
|
||||
.<span class="kw">await</span>
|
||||
.<span class="ident">unwrap</span>();
|
||||
<span class="macro">assert_ne!</span>(<span class="ident">initial_session_key</span>, <span class="ident">updated_session_key</span>.<span class="ident">as_ref</span>());
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
128
src/actix_session/storage/session_key.rs.html
Normal file
128
src/actix_session/storage/session_key.rs.html
Normal file
@@ -0,0 +1,128 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>session_key.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10">10</span>
|
||||
<span id="11">11</span>
|
||||
<span id="12">12</span>
|
||||
<span id="13">13</span>
|
||||
<span id="14">14</span>
|
||||
<span id="15">15</span>
|
||||
<span id="16">16</span>
|
||||
<span id="17">17</span>
|
||||
<span id="18">18</span>
|
||||
<span id="19">19</span>
|
||||
<span id="20">20</span>
|
||||
<span id="21">21</span>
|
||||
<span id="22">22</span>
|
||||
<span id="23">23</span>
|
||||
<span id="24">24</span>
|
||||
<span id="25">25</span>
|
||||
<span id="26">26</span>
|
||||
<span id="27">27</span>
|
||||
<span id="28">28</span>
|
||||
<span id="29">29</span>
|
||||
<span id="30">30</span>
|
||||
<span id="31">31</span>
|
||||
<span id="32">32</span>
|
||||
<span id="33">33</span>
|
||||
<span id="34">34</span>
|
||||
<span id="35">35</span>
|
||||
<span id="36">36</span>
|
||||
<span id="37">37</span>
|
||||
<span id="38">38</span>
|
||||
<span id="39">39</span>
|
||||
<span id="40">40</span>
|
||||
<span id="41">41</span>
|
||||
<span id="42">42</span>
|
||||
<span id="43">43</span>
|
||||
<span id="44">44</span>
|
||||
<span id="45">45</span>
|
||||
<span id="46">46</span>
|
||||
<span id="47">47</span>
|
||||
<span id="48">48</span>
|
||||
<span id="49">49</span>
|
||||
<span id="50">50</span>
|
||||
<span id="51">51</span>
|
||||
<span id="52">52</span>
|
||||
<span id="53">53</span>
|
||||
<span id="54">54</span>
|
||||
<span id="55">55</span>
|
||||
<span id="56">56</span>
|
||||
<span id="57">57</span>
|
||||
<span id="58">58</span>
|
||||
<span id="59">59</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::convert::TryFrom</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">derive_more</span>::{<span class="ident">Display</span>, <span class="ident">From</span>};
|
||||
|
||||
<span class="doccomment">/// A session key, the string stored in a client-side cookie to associate a user</span>
|
||||
<span class="doccomment">/// with its session state on the backend.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ## Validation</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// Session keys are stored as cookies, therefore they cannot be arbitrary long.</span>
|
||||
<span class="doccomment">/// We require session keys to be smaller than 4064 bytes.</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// ```rust</span>
|
||||
<span class="doccomment">/// use std::convert::TryInto;</span>
|
||||
<span class="doccomment">/// use actix_session::storage::SessionKey;</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// let key: String = std::iter::repeat('a').take(4065).collect();</span>
|
||||
<span class="doccomment">/// let session_key: Result<SessionKey, _> = key.try_into();</span>
|
||||
<span class="doccomment">/// assert!(session_key.is_err());</span>
|
||||
<span class="doccomment">/// ```</span>
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">PartialEq</span>, <span class="ident">Eq</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">SessionKey</span>(<span class="ident">String</span>);
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">TryFrom</span><span class="op"><</span><span class="ident">String</span><span class="op">></span> <span class="kw">for</span> <span class="ident">SessionKey</span> {
|
||||
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">InvalidSessionKeyError</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">try_from</span>(<span class="ident">v</span>: <span class="ident">String</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="self">Self</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">></span> {
|
||||
<span class="kw">if</span> <span class="ident">v</span>.<span class="ident">len</span>() <span class="op">></span> <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">"The session key is bigger than 4064 bytes, the upper limit on cookie content."</span>
|
||||
)
|
||||
.<span class="ident">into</span>());
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">SessionKey</span>(<span class="ident">v</span>))
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">AsRef</span><span class="op"><</span><span class="ident">str</span><span class="op">></span> <span class="kw">for</span> <span class="ident">SessionKey</span> {
|
||||
<span class="kw">fn</span> <span class="ident">as_ref</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span><span class="ident">str</span> {
|
||||
<span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span>
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">From</span><span class="op"><</span><span class="ident">SessionKey</span><span class="op">></span> <span class="kw">for</span> <span class="ident">String</span> {
|
||||
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">k</span>: <span class="ident">SessionKey</span>) -> <span class="self">Self</span> {
|
||||
<span class="ident">k</span>.<span class="number">0</span>
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Display</span>, <span class="ident">From</span>)]</span>
|
||||
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">"The provided string is not a valid session key"</span>)]</span>
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">InvalidSessionKeyError</span>(<span class="ident">anyhow::Error</span>);
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">std::error::Error</span> <span class="kw">for</span> <span class="ident">InvalidSessionKeyError</span> {
|
||||
<span class="kw">fn</span> <span class="ident">source</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Option</span><span class="op"><</span><span class="kw-2">&</span>(<span class="kw">dyn</span> <span class="ident">std::error::Error</span> <span class="op">+</span> <span class="lifetime">'static</span>)<span class="op">></span> {
|
||||
<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">as_ref</span>())
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
48
src/actix_session/storage/utils.rs.html
Normal file
48
src/actix_session/storage/utils.rs.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!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`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>utils.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><script defer src="../../../main.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script>
|
||||
<noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container"><img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a><h2 class="location"></h2>
|
||||
</nav>
|
||||
<nav class="sidebar"><a class="sidebar-logo" href="../../../actix_session/index.html"><div class="logo-container">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></div>
|
||||
</a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../actix_session/index.html">
|
||||
<img src="https://actix.rs/img/logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1"> 1</span>
|
||||
<span id="2"> 2</span>
|
||||
<span id="3"> 3</span>
|
||||
<span id="4"> 4</span>
|
||||
<span id="5"> 5</span>
|
||||
<span id="6"> 6</span>
|
||||
<span id="7"> 7</span>
|
||||
<span id="8"> 8</span>
|
||||
<span id="9"> 9</span>
|
||||
<span id="10">10</span>
|
||||
<span id="11">11</span>
|
||||
<span id="12">12</span>
|
||||
<span id="13">13</span>
|
||||
<span id="14">14</span>
|
||||
<span id="15">15</span>
|
||||
<span id="16">16</span>
|
||||
<span id="17">17</span>
|
||||
<span id="18">18</span>
|
||||
<span id="19">19</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::convert::TryInto</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">rand</span>::{<span class="ident">distributions::Alphanumeric</span>, <span class="ident">rngs::OsRng</span>, <span class="ident">Rng</span> <span class="kw">as</span> <span class="kw">_</span>};
|
||||
|
||||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::storage::SessionKey</span>;
|
||||
|
||||
<span class="doccomment">/// Session key generation routine that follows [OWASP recommendations].</span>
|
||||
<span class="doccomment">///</span>
|
||||
<span class="doccomment">/// [OWASP recommendations]: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-entropy</span>
|
||||
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn</span> <span class="ident">generate_session_key</span>() -> <span class="ident">SessionKey</span> {
|
||||
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">std::iter::repeat</span>(())
|
||||
.<span class="ident">map</span>(<span class="op">|</span>()<span class="op">|</span> <span class="ident">OsRng</span>.<span class="ident">sample</span>(<span class="ident">Alphanumeric</span>))
|
||||
.<span class="ident">take</span>(<span class="number">64</span>)
|
||||
.<span class="ident">collect</span>::<span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="kw">_</span><span class="op">></span><span class="op">></span>();
|
||||
|
||||
<span class="comment">// These unwraps will never panic because pre-conditions are always verified</span>
|
||||
<span class="comment">// (i.e. length and character set)</span>
|
||||
<span class="ident">String::from_utf8</span>(<span class="ident">value</span>).<span class="ident">unwrap</span>().<span class="ident">try_into</span>().<span class="ident">unwrap</span>()
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_session" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -300,5 +300,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -352,5 +352,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -50,5 +50,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -168,5 +168,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -210,5 +210,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -142,5 +142,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -206,5 +206,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -26,5 +26,5 @@
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme::bearer::Bearer</span>;
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::scheme::Scheme</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -394,5 +394,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -278,5 +278,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -34,5 +34,5 @@
|
||||
<span class="kw">fn</span> <span class="ident">parse</span>(<span class="ident">header</span>: <span class="kw-2">&</span><span class="ident">HeaderValue</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="self">Self</span>, <span class="ident">ParseError</span><span class="op">></span>;
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -12,5 +12,5 @@
|
||||
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">authorization</span>;
|
||||
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">www_authenticate</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -282,5 +282,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -130,5 +130,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -282,5 +282,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -106,5 +106,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -28,5 +28,5 @@
|
||||
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
|
||||
<span class="kw">mod</span> <span class="ident">tests</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -28,5 +28,5 @@
|
||||
<span class="kw">fn</span> <span class="ident">to_bytes</span>(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="ident">Bytes</span>;
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -70,5 +70,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -22,5 +22,5 @@
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::challenge::Challenge</span>;
|
||||
<span class="kw">pub</span> <span class="kw">use</span> <span class="ident"><span class="self">self</span>::header::WwwAuthenticate</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -54,5 +54,5 @@
|
||||
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">middleware</span>;
|
||||
<span class="kw">mod</span> <span class="ident">utils</span>;
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -828,5 +828,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
@@ -226,5 +226,5 @@
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (10913c000 2022-03-03)" ></div>
|
||||
</section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="actix_web_httpauth" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.61.0-nightly (9fcbc3205 2022-03-04)" ></div>
|
||||
</body></html>
|
Reference in New Issue
Block a user