1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-08-31 11:26:59 +02:00

Deploying to gh-pages from @ 8741cd32cc 🚀

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

View File

@@ -71,12 +71,12 @@
<span id="68">68</span>
<span id="69">69</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">convert</span>::<span class="ident">From</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">str</span>;
<span class="kw">use</span> <span class="ident">std::convert::From</span>;
<span class="kw">use</span> <span class="ident">std::error::Error</span>;
<span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::str</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">http</span>::<span class="ident">header</span>;
<span class="kw">use</span> <span class="ident">actix_web::http::header</span>;
<span class="doccomment">/// Possible errors while parsing `Authorization` header.</span>
<span class="doccomment">///</span>
@@ -91,22 +91,22 @@
<span class="doccomment">/// Required authentication field is missing</span>
<span class="ident">MissingField</span>(<span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>),
<span class="doccomment">/// Unable to convert header into the str</span>
<span class="ident">ToStrError</span>(<span class="ident">header</span>::<span class="ident">ToStrError</span>),
<span class="ident">ToStrError</span>(<span class="ident">header::ToStrError</span>),
<span class="doccomment">/// Malformed base64 string</span>
<span class="ident">Base64DecodeError</span>(<span class="ident">base64</span>::<span class="ident">DecodeError</span>),
<span class="ident">Base64DecodeError</span>(<span class="ident">base64::DecodeError</span>),
<span class="doccomment">/// Malformed UTF-8 string</span>
<span class="ident">Utf8Error</span>(<span class="ident">str</span>::<span class="ident">Utf8Error</span>),
<span class="ident">Utf8Error</span>(<span class="ident">str::Utf8Error</span>),
}
<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Display</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
<span class="kw">impl</span> <span class="ident">fmt::Display</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">f</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt::Formatter</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">fmt::Result</span> {
<span class="kw">let</span> <span class="ident">display</span> <span class="op">=</span> <span class="kw">match</span> <span class="self">self</span> {
<span class="ident">ParseError</span>::<span class="ident">Invalid</span> <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Invalid header value&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError</span>::<span class="ident">MissingScheme</span> <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Missing authorization scheme&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError</span>::<span class="ident">MissingField</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Missing header field&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError</span>::<span class="ident">ToStrError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError</span>::<span class="ident">Base64DecodeError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError</span>::<span class="ident">Utf8Error</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::Invalid</span> <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Invalid header value&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::MissingScheme</span> <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Missing authorization scheme&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::MissingField</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="string">&quot;Missing header field&quot;</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">e</span>.<span class="ident">to_string</span>(),
};
<span class="ident">f</span>.<span class="ident">write_str</span>(<span class="kw-2">&amp;</span><span class="ident">display</span>)
}
@@ -115,29 +115,29 @@
<span class="kw">impl</span> <span class="ident">Error</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">source</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span>(<span class="kw">dyn</span> <span class="ident">Error</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>)<span class="op">&gt;</span> {
<span class="kw">match</span> <span class="self">self</span> {
<span class="ident">ParseError</span>::<span class="ident">Invalid</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError</span>::<span class="ident">MissingScheme</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError</span>::<span class="ident">MissingField</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError</span>::<span class="ident">ToStrError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError</span>::<span class="ident">Base64DecodeError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError</span>::<span class="ident">Utf8Error</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::Invalid</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError::MissingScheme</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError::MissingField</span>(<span class="kw">_</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="ident">e</span>),
}
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">header</span>::<span class="ident">ToStrError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">header</span>::<span class="ident">ToStrError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError</span>::<span class="ident">ToStrError</span>(<span class="ident">e</span>)
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">header::ToStrError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">header::ToStrError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError::ToStrError</span>(<span class="ident">e</span>)
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">base64</span>::<span class="ident">DecodeError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">base64</span>::<span class="ident">DecodeError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError</span>::<span class="ident">Base64DecodeError</span>(<span class="ident">e</span>)
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">base64::DecodeError</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">base64::DecodeError</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError::Base64DecodeError</span>(<span class="ident">e</span>)
}
}
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">str</span>::<span class="ident">Utf8Error</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">str</span>::<span class="ident">Utf8Error</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError</span>::<span class="ident">Utf8Error</span>(<span class="ident">e</span>)
<span class="kw">impl</span> <span class="ident">From</span><span class="op">&lt;</span><span class="ident">str::Utf8Error</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ParseError</span> {
<span class="kw">fn</span> <span class="ident">from</span>(<span class="ident">e</span>: <span class="ident">str::Utf8Error</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="self">Self</span> {
<span class="ident">ParseError::Utf8Error</span>(<span class="ident">e</span>)
}
}
</pre></div>