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

Deploying to gh-pages from @ b054733854 🚀

This commit is contained in:
robjtede
2022-07-31 19:14:56 +00:00
parent c938b4bd37
commit dd622cd699
34 changed files with 771 additions and 161 deletions

View File

@@ -123,16 +123,42 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">env::VarError</span>, <span class="ident">io</span>, <span class="ident">num::ParseIntError</span>, <span class="ident">path::PathBuf</span>, <span class="ident">str::ParseBoolError</span>};
<span class="kw">use</span> <span class="ident">toml::de::Error</span> <span class="kw">as</span> <span class="ident">TomlError</span>;
<span class="doccomment">/// Convenience type alias for `Result&lt;T, AtError&gt;`.</span>
<span class="kw">pub</span> <span class="kw">type</span> <span class="ident">AtResult</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">std::result::Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">AtError</span><span class="op">&gt;</span>;
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Clone</span>, <span class="ident">Debug</span>)]</span>
<span class="doccomment">/// Errors that can be returned from methods in this crate.</span>
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>, <span class="ident">Clone</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">AtError</span> {
<span class="doccomment">/// Environment variable does not exists or is invalid.</span>
<span class="ident">EnvVarError</span>(<span class="ident">VarError</span>),
<span class="doccomment">/// File already exists on disk.</span>
<span class="ident">FileExists</span>(<span class="ident">PathBuf</span>),
<span class="doccomment">/// Invalid value.</span>
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">missing_docs</span>)]</span>
<span class="ident">InvalidValue</span> {
<span class="ident">expected</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>,
<span class="ident">got</span>: <span class="ident">String</span>,
@@ -140,10 +166,20 @@
<span class="ident">line</span>: <span class="ident">u32</span>,
<span class="ident">column</span>: <span class="ident">u32</span>,
},
<span class="doccomment">/// I/O error.</span>
<span class="ident">IoError</span>(<span class="ident">ioe::IoError</span>),
<span class="doccomment">/// Value is not a boolean.</span>
<span class="ident">ParseBoolError</span>(<span class="ident">ParseBoolError</span>),
<span class="doccomment">/// Value is not an integer.</span>
<span class="ident">ParseIntError</span>(<span class="ident">ParseIntError</span>),
<span class="doccomment">/// Value is not an address.</span>
<span class="ident">ParseAddressError</span>(<span class="ident">String</span>),
<span class="doccomment">/// Error deserializing as TOML.</span>
<span class="ident">TomlError</span>(<span class="ident">TomlError</span>),
}

View File

@@ -702,12 +702,174 @@
<span id="700">700</span>
<span id="701">701</span>
<span id="702">702</span>
<span id="703">703</span>
<span id="704">704</span>
<span id="705">705</span>
<span id="706">706</span>
<span id="707">707</span>
<span id="708">708</span>
<span id="709">709</span>
<span id="710">710</span>
<span id="711">711</span>
<span id="712">712</span>
<span id="713">713</span>
<span id="714">714</span>
<span id="715">715</span>
<span id="716">716</span>
<span id="717">717</span>
<span id="718">718</span>
<span id="719">719</span>
<span id="720">720</span>
<span id="721">721</span>
<span id="722">722</span>
<span id="723">723</span>
<span id="724">724</span>
<span id="725">725</span>
<span id="726">726</span>
<span id="727">727</span>
<span id="728">728</span>
<span id="729">729</span>
<span id="730">730</span>
<span id="731">731</span>
<span id="732">732</span>
<span id="733">733</span>
<span id="734">734</span>
<span id="735">735</span>
<span id="736">736</span>
<span id="737">737</span>
<span id="738">738</span>
<span id="739">739</span>
<span id="740">740</span>
<span id="741">741</span>
<span id="742">742</span>
<span id="743">743</span>
<span id="744">744</span>
<span id="745">745</span>
<span id="746">746</span>
<span id="747">747</span>
<span id="748">748</span>
<span id="749">749</span>
<span id="750">750</span>
<span id="751">751</span>
<span id="752">752</span>
<span id="753">753</span>
<span id="754">754</span>
<span id="755">755</span>
<span id="756">756</span>
<span id="757">757</span>
<span id="758">758</span>
<span id="759">759</span>
<span id="760">760</span>
<span id="761">761</span>
<span id="762">762</span>
<span id="763">763</span>
<span id="764">764</span>
<span id="765">765</span>
<span id="766">766</span>
<span id="767">767</span>
<span id="768">768</span>
<span id="769">769</span>
<span id="770">770</span>
<span id="771">771</span>
<span id="772">772</span>
<span id="773">773</span>
<span id="774">774</span>
<span id="775">775</span>
<span id="776">776</span>
<span id="777">777</span>
<span id="778">778</span>
<span id="779">779</span>
<span id="780">780</span>
<span id="781">781</span>
<span id="782">782</span>
<span id="783">783</span>
<span id="784">784</span>
<span id="785">785</span>
<span id="786">786</span>
<span id="787">787</span>
<span id="788">788</span>
<span id="789">789</span>
<span id="790">790</span>
<span id="791">791</span>
<span id="792">792</span>
<span id="793">793</span>
<span id="794">794</span>
<span id="795">795</span>
<span id="796">796</span>
<span id="797">797</span>
<span id="798">798</span>
<span id="799">799</span>
<span id="800">800</span>
<span id="801">801</span>
<span id="802">802</span>
<span id="803">803</span>
<span id="804">804</span>
<span id="805">805</span>
</pre><pre class="rust"><code><span class="doccomment">//! Easily manage Actix Web&#39;s settings from a TOML file and environment variables.</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! To get started add a [`Settings::parse_toml(&quot;./Server.toml&quot;)`](Settings::parse_toml) call to the</span>
<span class="doccomment">//! top of your main function. This will create a template file with descriptions of all the</span>
<span class="doccomment">//! configurable settings. You can change or remove anything in that file and it will be picked up</span>
<span class="doccomment">//! the next time you run your application.</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! Overriding parts of the file can be done from values using [`Settings::override_field`] or from</span>
<span class="doccomment">//! the environment using [`Settings::override_field_with_env_var`].</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! # Examples</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! See examples folder on GitHub for complete example.</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! ```ignore</span>
<span class="doccomment">//! # use actix_web::{</span>
<span class="doccomment">//! # get,</span>
<span class="doccomment">//! # middleware::{Compress, Condition, Logger},</span>
<span class="doccomment">//! # web, App, HttpServer,</span>
<span class="doccomment">//! # };</span>
<span class="doccomment">//! use actix_settings::{ApplySettings as _, Mode, Settings};</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! #[actix_web::main]</span>
<span class="doccomment">//! async fn main() -&gt; std::io::Result&lt;()&gt; {</span>
<span class="doccomment">//! let mut settings = Settings::parse_toml(&quot;./Server.toml&quot;)</span>
<span class="doccomment">//! .expect(&quot;Failed to parse `Settings` from Server.toml&quot;);</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! // If the environment variable `$APPLICATION__HOSTS` is set,</span>
<span class="doccomment">//! // have its value override the `settings.actix.hosts` setting:</span>
<span class="doccomment">//! Settings::override_field_with_env_var(&amp;mut settings.actix.hosts, &quot;APPLICATION__HOSTS&quot;)?;</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! init_logger(&amp;settings);</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! HttpServer::new({</span>
<span class="doccomment">//! // clone settings into each worker thread</span>
<span class="doccomment">//! let settings = settings.clone();</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! move || {</span>
<span class="doccomment">//! App::new()</span>
<span class="doccomment">//! // Include this `.wrap()` call for compression settings to take effect</span>
<span class="doccomment">//! .wrap(Condition::new(</span>
<span class="doccomment">//! settings.actix.enable_compression,</span>
<span class="doccomment">//! Compress::default(),</span>
<span class="doccomment">//! ))</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! // add request logger</span>
<span class="doccomment">//! .wrap(Logger::default())</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! // make `Settings` available to handlers</span>
<span class="doccomment">//! .app_data(web::Data::new(settings.clone()))</span>
<span class="doccomment">//!</span>
<span class="doccomment">//! // add request handlers as normal</span>
<span class="doccomment">//! .service(index)</span>
<span class="doccomment">//! }</span>
<span class="doccomment">//! })</span>
<span class="doccomment">//! // apply the `Settings` to Actix Web&#39;s `HttpServer`</span>
<span class="doccomment">//! .apply_settings(&amp;settings)</span>
<span class="doccomment">//! .run()</span>
<span class="doccomment">//! .await</span>
<span class="doccomment">//! }</span>
<span class="doccomment">//! ```</span>
<span class="attribute">#![<span class="ident">forbid</span>(<span class="ident">unsafe_code</span>)]</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 class="ident">missing_debug_implementations</span>)]</span>
<span class="comment">// #![warn(missing_docs)]</span>
<span class="attribute">#![<span class="ident">warn</span>(<span class="ident">future_incompatible</span>, <span class="ident">missing_docs</span>, <span class="ident">missing_debug_implementations</span>)]</span>
<span class="attribute">#![<span class="ident">doc</span>(<span class="ident">html_logo_url</span> <span class="op">=</span> <span class="string">&quot;https://actix.rs/img/logo.png&quot;</span>)]</span>
<span class="attribute">#![<span class="ident">doc</span>(<span class="ident">html_favicon_url</span> <span class="op">=</span> <span class="string">&quot;https://actix.rs/favicon.ico&quot;</span>)]</span>
@@ -741,15 +903,21 @@
<span class="ident">NumWorkers</span>, <span class="ident">Timeout</span>, <span class="ident">Tls</span>,
};
<span class="doccomment">/// Wrapper for server and application-specific settings.</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 class="ident">Hash</span>, <span class="ident">Deserialize</span>)]</span>
<span class="attribute">#[<span class="ident">serde</span>(<span class="ident">bound</span> <span class="op">=</span> <span class="string">&quot;A: Deserialize&lt;&#39;de&gt;&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">BasicSettings</span><span class="op">&lt;</span><span class="ident">A</span><span class="op">&gt;</span> {
<span class="doccomment">/// Actix Web server settings.</span>
<span class="kw">pub</span> <span class="ident">actix</span>: <span class="ident">ActixSettings</span>,
<span class="doccomment">/// Application-specific settings.</span>
<span class="kw">pub</span> <span class="ident">application</span>: <span class="ident">A</span>,
}
<span class="doccomment">/// Convenience type alias for [`BasicSettings`] with no defined application-specific settings.</span>
<span class="kw">pub</span> <span class="kw">type</span> <span class="ident">Settings</span> <span class="op">=</span> <span class="ident">BasicSettings</span><span class="op">&lt;</span><span class="ident">NoSettings</span><span class="op">&gt;</span>;
<span class="doccomment">/// Marker type representing no defined application-specific settings.</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 class="ident">Hash</span>, <span class="ident">Deserialize</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">NoSettings</span> {<span class="comment">/* NOTE: turning this into a unit struct will cause deserialization failures. */</span>}
@@ -758,14 +926,16 @@
<span class="kw">where</span>
<span class="ident">A</span>: <span class="ident">de::DeserializeOwned</span>,
{
<span class="doccomment">/// NOTE **DO NOT** mess with the ordering of the tables in this template.</span>
<span class="doccomment">/// Especially the `[application]` table needs to be last in order</span>
<span class="doccomment">/// for some tests to keep working.</span>
<span class="comment">// NOTE **DO NOT** mess with the ordering of the tables in the default template.</span>
<span class="comment">// Especially the `[application]` table needs to be last in order</span>
<span class="comment">// for some tests to keep working.</span>
<span class="doccomment">/// Default settings file contents.</span>
<span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const</span> <span class="ident">DEFAULT_TOML_TEMPLATE</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span> <span class="op">=</span> <span class="macro">include_str!</span>(<span class="string">&quot;./defaults.toml&quot;</span>);
<span class="doccomment">/// Parse an instance of `Self` from a `TOML` file located at `filepath`.</span>
<span class="doccomment">/// If the file doesn&#39;t exist, it is generated from the default `TOML`</span>
<span class="doccomment">/// template, after which the newly generated file is read in and parsed.</span>
<span class="doccomment">/// Parse an instance of `Self` from a TOML file located at `filepath`.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// If the file doesn&#39;t exist, it is generated from the default TOML template, after which the</span>
<span class="doccomment">/// newly generated file is read in and parsed.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">parse_toml</span><span class="op">&lt;</span><span class="ident">P</span><span class="op">&gt;</span>(<span class="ident">filepath</span>: <span class="ident">P</span>) -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">P</span>: <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">Path</span><span class="op">&gt;</span>,
@@ -777,43 +947,62 @@
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File::open</span>(<span class="ident">filepath</span>)<span class="question-mark">?</span>;
<span class="comment">// TODO: don&#39;t bail on metadata fail</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">contents</span> <span class="op">=</span> <span class="ident">String::with_capacity</span>(<span class="ident">f</span>.<span class="ident">metadata</span>()<span class="question-mark">?</span>.<span class="ident">len</span>() <span class="kw">as</span> <span class="ident">usize</span>);
<span class="ident">f</span>.<span class="ident">read_to_string</span>(<span class="kw-2">&amp;mut</span> <span class="ident">contents</span>)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(<span class="ident">toml::from_str</span>::<span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="ident">contents</span>)<span class="question-mark">?</span>)
}
<span class="doccomment">/// Parse an instance of `Self` straight from the default `TOML` template.</span>
<span class="doccomment">/// Parse an instance of `Self` straight from the default TOML template.</span>
<span class="comment">// TODO: make infallible</span>
<span class="comment">// TODO: consider &quot;template&quot; rename</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">from_default_template</span>() -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span> {
<span class="ident"><span class="self">Self</span>::from_template</span>(<span class="ident"><span class="self">Self</span>::DEFAULT_TOML_TEMPLATE</span>)
}
<span class="doccomment">/// Parse an instance of `Self` straight from the default `TOML` template.</span>
<span class="doccomment">/// Parse an instance of `Self` straight from the default TOML template.</span>
<span class="comment">// TODO: consider &quot;template&quot; rename</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">from_template</span>(<span class="ident">template</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span><span class="self">Self</span><span class="op">&gt;</span> {
<span class="prelude-val">Ok</span>(<span class="ident">toml::from_str</span>(<span class="ident">template</span>)<span class="question-mark">?</span>)
}
<span class="doccomment">/// Write the default `TOML` template to a new file, to be located</span>
<span class="doccomment">/// at `filepath`. Return a `Error::FileExists(_)` error if a</span>
<span class="doccomment">/// file already exists at that location.</span>
<span class="doccomment">/// Writes the default TOML template to a new file, located at `filepath`.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Errors</span>
<span class="doccomment">/// Returns a [`FileExists`](crate::AtError::FileExists) error if a file already exists at that</span>
<span class="doccomment">/// location.</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">write_toml_file</span><span class="op">&lt;</span><span class="ident">P</span><span class="op">&gt;</span>(<span class="ident">filepath</span>: <span class="ident">P</span>) -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span>()<span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">P</span>: <span class="ident">AsRef</span><span class="op">&lt;</span><span class="ident">Path</span><span class="op">&gt;</span>,
{
<span class="kw">let</span> <span class="ident">filepath</span> <span class="op">=</span> <span class="ident">filepath</span>.<span class="ident">as_ref</span>();
<span class="kw">let</span> <span class="ident">contents</span> <span class="op">=</span> <span class="ident"><span class="self">Self</span>::DEFAULT_TOML_TEMPLATE</span>.<span class="ident">trim</span>();
<span class="kw">if</span> <span class="ident">filepath</span>.<span class="ident">exists</span>() {
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">AtError::FileExists</span>(<span class="ident">filepath</span>.<span class="ident">to_path_buf</span>()));
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File::create</span>(<span class="ident">filepath</span>)<span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="ident">contents</span>.<span class="ident">as_bytes</span>())<span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="ident"><span class="self">Self</span>::DEFAULT_TOML_TEMPLATE</span>.<span class="ident">trim</span>().<span class="ident">as_bytes</span>())<span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">flush</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}
<span class="doccomment">/// Attempts to parse `value` and override the referenced `field`.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_settings::{Settings, Mode};</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # fn inner() -&gt; actix_settings::AtResult&lt;()&gt; {</span>
<span class="doccomment">/// let mut settings = Settings::from_default_template()?;</span>
<span class="doccomment">/// assert_eq!(settings.actix.mode, Mode::Development);</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Settings::override_field(&amp;mut settings.actix.mode, &quot;production&quot;)?;</span>
<span class="doccomment">/// assert_eq!(settings.actix.mode, Mode::Production);</span>
<span class="doccomment">/// # Ok(()) }</span>
<span class="doccomment">/// ```</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">override_field</span><span class="op">&lt;</span><span class="ident">F</span>, <span class="ident">V</span><span class="op">&gt;</span>(<span class="ident">field</span>: <span class="kw-2">&amp;mut</span> <span class="ident">F</span>, <span class="ident">value</span>: <span class="ident">V</span>) -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span>()<span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">F</span>: <span class="ident">Parse</span>,
@@ -823,6 +1012,22 @@
<span class="prelude-val">Ok</span>(())
}
<span class="doccomment">/// Attempts to read an environment variable, parse it, and override the referenced `field`.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # Examples</span>
<span class="doccomment">/// ```</span>
<span class="doccomment">/// use actix_settings::{Settings, Mode};</span>
<span class="doccomment">///</span>
<span class="doccomment">/// std::env::set_var(&quot;OVERRIDE__MODE&quot;, &quot;production&quot;);</span>
<span class="doccomment">///</span>
<span class="doccomment">/// # fn inner() -&gt; actix_settings::AtResult&lt;()&gt; {</span>
<span class="doccomment">/// let mut settings = Settings::from_default_template()?;</span>
<span class="doccomment">/// assert_eq!(settings.actix.mode, Mode::Development);</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Settings::override_field_with_env_var(&amp;mut settings.actix.mode, &quot;OVERRIDE__MODE&quot;)?;</span>
<span class="doccomment">/// assert_eq!(settings.actix.mode, Mode::Production);</span>
<span class="doccomment">/// # Ok(()) }</span>
<span class="doccomment">/// ```</span>
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">override_field_with_env_var</span><span class="op">&lt;</span><span class="ident">F</span>, <span class="ident">N</span><span class="op">&gt;</span>(<span class="ident">field</span>: <span class="kw-2">&amp;mut</span> <span class="ident">F</span>, <span class="ident">var_name</span>: <span class="ident">N</span>) -&gt; <span class="ident">AtResult</span><span class="op">&lt;</span>()<span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">F</span>: <span class="ident">Parse</span>,
@@ -836,6 +1041,7 @@
}
}
<span class="doccomment">/// Extension trait for applying parsed settings to the server object.</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">ApplySettings</span> {
<span class="doccomment">/// Apply a [`BasicSettings`] value to `self`.</span>
<span class="doccomment">///</span>
@@ -904,9 +1110,9 @@
<span class="self">self</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">settings</span>.<span class="ident">actix</span>.<span class="ident">client_timeout</span> {
<span class="ident">Timeout::Default</span> =&gt; <span class="self">self</span>,
<span class="ident">Timeout::Milliseconds</span>(<span class="ident">n</span>) =&gt; {
<span class="self">self</span>.<span class="ident">client_disconnect_timeout</span>(<span class="ident">Duration::from_millis</span>(<span class="ident">n</span> <span class="kw">as</span> <span class="ident">u64</span>))
<span class="self">self</span>.<span class="ident">client_request_timeout</span>(<span class="ident">Duration::from_millis</span>(<span class="ident">n</span> <span class="kw">as</span> <span class="ident">u64</span>))
}
<span class="ident">Timeout::Seconds</span>(<span class="ident">n</span>) =&gt; <span class="self">self</span>.<span class="ident">client_disconnect_timeout</span>(<span class="ident">Duration::from_secs</span>(<span class="ident">n</span> <span class="kw">as</span> <span class="ident">u64</span>)),
<span class="ident">Timeout::Seconds</span>(<span class="ident">n</span>) =&gt; <span class="self">self</span>.<span class="ident">client_request_timeout</span>(<span class="ident">Duration::from_secs</span>(<span class="ident">n</span> <span class="kw">as</span> <span class="ident">u64</span>)),
};
<span class="self">self</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">settings</span>.<span class="ident">actix</span>.<span class="ident">client_shutdown</span> {

View File

@@ -38,11 +38,15 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">path::PathBuf</span>, <span class="ident">str::FromStr</span>};
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::AtError</span>;
<span class="doccomment">/// A specialized `FromStr` trait that returns [`AtError`] errors</span>
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">Parse</span>: <span class="ident">Sized</span> {
<span class="doccomment">/// Parse `Self` from `string`.</span>
<span class="kw">fn</span> <span class="ident">parse</span>(<span class="ident">string</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident">AtError</span><span class="op">&gt;</span>;
}

View File

@@ -89,6 +89,10 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
<span class="kw">use</span> <span class="ident">regex::Regex</span>;
<span class="kw">use</span> <span class="ident">serde::Deserialize</span>;
@@ -128,9 +132,13 @@
.<span class="ident">expect</span>(<span class="string">&quot;Failed to compile regex: ADDRS_REGEX&quot;</span>)
});
<span class="doccomment">/// A host/port pair for the server to bind to.</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 class="ident">Hash</span>, <span class="ident">Deserialize</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Address</span> {
<span class="doccomment">/// Host part of address.</span>
<span class="kw">pub</span> <span class="ident">host</span>: <span class="ident">String</span>,
<span class="doccomment">/// Port part of address.</span>
<span class="kw">pub</span> <span class="ident">port</span>: <span class="ident">u16</span>,
}

View File

@@ -59,15 +59,37 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// The maximum number of pending connections.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// This refers to the number of clients that can be waiting to be served. Exceeding this number</span>
<span class="doccomment">/// results in the client getting an error when attempting to connect. It should only affect servers</span>
<span class="doccomment">/// under significant load.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Generally set in the 642048 range. The default value is 2048. Takes a string value: Either</span>
<span class="doccomment">/// &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Backlog</span> {
<span class="doccomment">/// The default number of connections. See struct docs.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// A specific number of connections.</span>
<span class="ident">Manual</span>(<span class="ident">usize</span>),
}

View File

@@ -82,6 +82,19 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
@@ -90,11 +103,24 @@
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// The server keep-alive preference.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// By default keep alive is set to 5 seconds. Takes a string value: Either &quot;default&quot;, &quot;disabled&quot;,</span>
<span class="doccomment">/// &quot;os&quot;, or a string of the format &quot;N seconds&quot; where N is an integer &gt; 0 e.g. &quot;6 seconds&quot;.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">KeepAlive</span> {
<span class="doccomment">/// The default keep-alive as defined by Actix Web.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// Disable keep-alive.</span>
<span class="ident">Disabled</span>,
<span class="doccomment">/// Let the OS determine keep-alive duration.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// Note: this is usually quite long.</span>
<span class="ident">Os</span>,
<span class="doccomment">/// A specific keep-alive duration (in seconds).</span>
<span class="ident">Seconds</span>(<span class="ident">usize</span>),
}

View File

@@ -59,15 +59,31 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// The maximum per-worker concurrent TLS connection limit.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// All listeners will stop accepting connections when this limit is reached. It can be used to</span>
<span class="doccomment">/// limit the global TLS CPU usage. By default max connections is set to a 256. Takes a string</span>
<span class="doccomment">/// value: Either &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">MaxConnectionRate</span> {
<span class="doccomment">/// The default connection limit. See struct docs.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// A specific connection limit.</span>
<span class="ident">Manual</span>(<span class="ident">usize</span>),
}

View File

@@ -59,15 +59,31 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// The maximum per-worker number of concurrent connections.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// All socket listeners will stop accepting connections when this limit is reached for each worker.</span>
<span class="doccomment">/// By default max connections is set to a 25k. Takes a string value: Either &quot;default&quot;, or an</span>
<span class="doccomment">/// integer N &gt; 0 e.g. &quot;6&quot;.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">MaxConnections</span> {
<span class="doccomment">/// The default number of connections. See struct docs.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// A specific number of connections.</span>
<span class="ident">Manual</span>(<span class="ident">usize</span>),
}

View File

@@ -40,6 +40,31 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">serde::Deserialize</span>;
<span class="kw">mod</span> <span class="ident">address</span>;
@@ -66,18 +91,43 @@
<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 class="ident">Hash</span>, <span class="ident">Deserialize</span>)]</span>
<span class="attribute">#[<span class="ident">serde</span>(<span class="ident">rename_all</span> <span class="op">=</span> <span class="string">&quot;kebab-case&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">ActixSettings</span> {
<span class="doccomment">/// List of addresses for the server to bind to.</span>
<span class="kw">pub</span> <span class="ident">hosts</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">Address</span><span class="op">&gt;</span>,
<span class="kw">pub</span> <span class="ident">mode</span>: <span class="ident">mode::Mode</span>,
<span class="doccomment">/// Marker of intended deployment environment.</span>
<span class="kw">pub</span> <span class="ident">mode</span>: <span class="ident">Mode</span>,
<span class="doccomment">/// True if the [`Compress`](actix_web::middleware::Compress) middleware should be enabled.</span>
<span class="kw">pub</span> <span class="ident">enable_compression</span>: <span class="ident">bool</span>,
<span class="doccomment">/// True if the [`Logger`](actix_web::middleware::Logger) middleware should be enabled.</span>
<span class="kw">pub</span> <span class="ident">enable_log</span>: <span class="ident">bool</span>,
<span class="doccomment">/// The number of workers that the server should start.</span>
<span class="kw">pub</span> <span class="ident">num_workers</span>: <span class="ident">NumWorkers</span>,
<span class="doccomment">/// The maximum number of pending connections.</span>
<span class="kw">pub</span> <span class="ident">backlog</span>: <span class="ident">Backlog</span>,
<span class="doccomment">/// The per-worker maximum number of concurrent connections.</span>
<span class="kw">pub</span> <span class="ident">max_connections</span>: <span class="ident">MaxConnections</span>,
<span class="doccomment">/// The per-worker maximum concurrent TLS connection limit.</span>
<span class="kw">pub</span> <span class="ident">max_connection_rate</span>: <span class="ident">MaxConnectionRate</span>,
<span class="doccomment">/// Server keep-alive preference.</span>
<span class="kw">pub</span> <span class="ident">keep_alive</span>: <span class="ident">KeepAlive</span>,
<span class="doccomment">/// Timeout duration for reading client request header.</span>
<span class="kw">pub</span> <span class="ident">client_timeout</span>: <span class="ident">Timeout</span>,
<span class="doccomment">/// Timeout duration for connection shutdown.</span>
<span class="kw">pub</span> <span class="ident">client_shutdown</span>: <span class="ident">Timeout</span>,
<span class="doccomment">/// Timeout duration for graceful worker shutdown.</span>
<span class="kw">pub</span> <span class="ident">shutdown_timeout</span>: <span class="ident">Timeout</span>,
<span class="doccomment">/// TLS (HTTPS) configuration.</span>
<span class="kw">pub</span> <span class="ident">tls</span>: <span class="ident">Tls</span>,
}
</code></pre></div>

View File

@@ -23,14 +23,22 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">serde::Deserialize</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// Marker of intended deployment environment.</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 class="ident">Hash</span>, <span class="ident">Deserialize</span>)]</span>
<span class="attribute">#[<span class="ident">serde</span>(<span class="ident">rename_all</span> <span class="op">=</span> <span class="string">&quot;lowercase&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Mode</span> {
<span class="doccomment">/// Marks development environment.</span>
<span class="ident">Development</span>,
<span class="doccomment">/// Marks production environment.</span>
<span class="ident">Production</span>,
}

View File

@@ -59,15 +59,29 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>;
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// The number of workers that the server should start.</span>
<span class="doccomment">///</span>
<span class="doccomment">/// By default the number of available logical cpu cores is used. Takes a string value: Either</span>
<span class="doccomment">/// &quot;default&quot;, or an integer N &gt; 0 e.g. &quot;6&quot;.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">NumWorkers</span> {
<span class="doccomment">/// The default number of workers. See struct docs.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// A specific number of workers.</span>
<span class="ident">Manual</span>(<span class="ident">usize</span>),
}

View File

@@ -88,6 +88,16 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
@@ -96,10 +106,16 @@
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">AtError</span>, <span class="ident">AtResult</span>, <span class="ident">Parse</span>};
<span class="doccomment">/// A timeout duration in milliseconds or seconds.</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 class="ident">Hash</span>)]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">Timeout</span> {
<span class="doccomment">/// The default timeout. Depends on context.</span>
<span class="ident">Default</span>,
<span class="doccomment">/// Timeout in milliseconds.</span>
<span class="ident">Milliseconds</span>(<span class="ident">usize</span>),
<span class="doccomment">/// Timeout in seconds.</span>
<span class="ident">Seconds</span>(<span class="ident">usize</span>),
}
@@ -124,18 +140,22 @@
})
}
}
<span class="kw">match</span> <span class="ident">string</span> {
<span class="string">&quot;default&quot;</span> =&gt; <span class="prelude-val">Ok</span>(<span class="ident">Timeout::Default</span>),
<span class="ident">string</span> <span class="kw">if</span> <span class="op">!</span><span class="ident">FMT</span>.<span class="ident">is_match</span>(<span class="ident">string</span>) =&gt; <span class="macro">invalid_value!</span>(<span class="ident">string</span>),
<span class="ident">string</span> =&gt; <span class="kw">match</span> (<span class="ident">DIGITS</span>.<span class="ident">find</span>(<span class="ident">string</span>), <span class="ident">UNIT</span>.<span class="ident">find</span>(<span class="ident">string</span>)) {
(<span class="prelude-val">None</span>, <span class="kw">_</span>) =&gt; <span class="macro">invalid_value!</span>(<span class="ident">string</span>),
(<span class="kw">_</span>, <span class="prelude-val">None</span>) =&gt; <span class="macro">invalid_value!</span>(<span class="ident">string</span>),
(<span class="prelude-val">Some</span>(<span class="ident">dmatch</span>), <span class="prelude-val">Some</span>(<span class="ident">umatch</span>)) =&gt; {
<span class="kw">let</span> <span class="ident">digits</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">string</span>[<span class="ident">dmatch</span>.<span class="ident">start</span>()..<span class="ident">dmatch</span>.<span class="ident">end</span>()];
<span class="kw">let</span> <span class="ident">unit</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">string</span>[<span class="ident">umatch</span>.<span class="ident">start</span>()..<span class="ident">umatch</span>.<span class="ident">end</span>()];
(<span class="prelude-val">None</span>, <span class="kw">_</span>) <span class="op">|</span> (<span class="kw">_</span>, <span class="prelude-val">None</span>) =&gt; <span class="macro">invalid_value!</span>(<span class="ident">string</span>),
(<span class="prelude-val">Some</span>(<span class="ident">digits</span>), <span class="prelude-val">Some</span>(<span class="ident">unit</span>)) =&gt; {
<span class="kw">let</span> <span class="ident">digits</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">string</span>[<span class="ident">digits</span>.<span class="ident">range</span>()];
<span class="kw">let</span> <span class="ident">unit</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">string</span>[<span class="ident">unit</span>.<span class="ident">range</span>()];
<span class="kw">match</span> (<span class="ident">digits</span>.<span class="ident">parse</span>(), <span class="ident">unit</span>) {
(<span class="prelude-val">Ok</span>(<span class="ident">v</span>), <span class="string">&quot;milliseconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(<span class="ident">Timeout::Milliseconds</span>(<span class="ident">v</span>)),
(<span class="prelude-val">Ok</span>(<span class="ident">v</span>), <span class="string">&quot;seconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(<span class="ident">Timeout::Seconds</span>(<span class="ident">v</span>)),
(<span class="prelude-val">Ok</span>(<span class="ident">n</span>), <span class="string">&quot;milliseconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(<span class="ident">Timeout::Milliseconds</span>(<span class="ident">n</span>)),
(<span class="prelude-val">Ok</span>(<span class="ident">n</span>), <span class="string">&quot;seconds&quot;</span>) =&gt; <span class="prelude-val">Ok</span>(<span class="ident">Timeout::Seconds</span>(<span class="ident">n</span>)),
<span class="kw">_</span> =&gt; <span class="macro">invalid_value!</span>(<span class="ident">string</span>),
}
}

View File

@@ -11,15 +11,29 @@
<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>
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std::path::PathBuf</span>;
<span class="kw">use</span> <span class="ident">serde::Deserialize</span>;
<span class="doccomment">/// TLS (HTTPS) configuration.</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 class="ident">Hash</span>, <span class="ident">Deserialize</span>)]</span>
<span class="attribute">#[<span class="ident">serde</span>(<span class="ident">rename_all</span> <span class="op">=</span> <span class="string">&quot;kebab-case&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">doc</span>(<span class="ident">alias</span> <span class="op">=</span> <span class="string">&quot;ssl&quot;</span>, <span class="ident">alias</span> <span class="op">=</span> <span class="string">&quot;https&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Tls</span> {
<span class="doccomment">/// Tru if accepting TLS connections should be enabled.</span>
<span class="kw">pub</span> <span class="ident">enabled</span>: <span class="ident">bool</span>,
<span class="doccomment">/// Path to certificate `.pem` file.</span>
<span class="kw">pub</span> <span class="ident">certificate</span>: <span class="ident">PathBuf</span>,
<span class="doccomment">/// Path to private key `.pem` file.</span>
<span class="kw">pub</span> <span class="ident">private_key</span>: <span class="ident">PathBuf</span>,
}
</code></pre></div>