Files
GopherGate/target/doc/tokio/runtime/struct.Builder.html
2026-02-26 12:00:21 -05:00

283 lines
53 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="Builds Tokio Runtime with custom configuration values."><title>Builder in tokio::runtime - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Builder</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Builder</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.build" title="build">build</a></li><li><a href="#method.enable_all" title="enable_all">enable_all</a></li><li><a href="#method.enable_io" title="enable_io">enable_io</a></li><li><a href="#method.enable_time" title="enable_time">enable_time</a></li><li><a href="#method.event_interval" title="event_interval">event_interval</a></li><li><a href="#method.global_queue_interval" title="global_queue_interval">global_queue_interval</a></li><li><a href="#method.max_blocking_threads" title="max_blocking_threads">max_blocking_threads</a></li><li><a href="#method.max_io_events_per_tick" title="max_io_events_per_tick">max_io_events_per_tick</a></li><li><a href="#method.new_current_thread" title="new_current_thread">new_current_thread</a></li><li><a href="#method.new_multi_thread" title="new_multi_thread">new_multi_thread</a></li><li><a href="#method.on_thread_park" title="on_thread_park">on_thread_park</a></li><li><a href="#method.on_thread_start" title="on_thread_start">on_thread_start</a></li><li><a href="#method.on_thread_stop" title="on_thread_stop">on_thread_stop</a></li><li><a href="#method.on_thread_unpark" title="on_thread_unpark">on_thread_unpark</a></li><li><a href="#method.thread_keep_alive" title="thread_keep_alive">thread_keep_alive</a></li><li><a href="#method.thread_name" title="thread_name">thread_name</a></li><li><a href="#method.thread_name_fn" title="thread_name_fn">thread_name_fn</a></li><li><a href="#method.thread_stack_size" title="thread_stack_size">thread_stack_size</a></li><li><a href="#method.worker_threads" title="worker_threads">worker_threads</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Builder" title="Debug">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Builder" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Builder" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-UnwindSafe-for-Builder" title="!UnwindSafe">!UnwindSafe</a></li><li><a href="#impl-Send-for-Builder" title="Send">Send</a></li><li><a href="#impl-Sync-for-Builder" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Builder" title="Unpin">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>runtime</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></div><h1>Struct <span class="struct">Builder</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/runtime/builder.rs.html#53-140">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Builder { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Builds Tokio Runtime with custom configuration values.</p>
<p>Methods can be chained in order to set the configuration values. The
Runtime is constructed by calling <a href="struct.Builder.html#method.build" title="method tokio::runtime::Builder::build"><code>build</code></a>.</p>
<p>New instances of <code>Builder</code> are obtained via <a href="struct.Builder.html#method.new_multi_thread" title="associated function tokio::runtime::Builder::new_multi_thread"><code>Builder::new_multi_thread</code></a>
or <a href="struct.Builder.html#method.new_current_thread" title="associated function tokio::runtime::Builder::new_current_thread"><code>Builder::new_current_thread</code></a>.</p>
<p>See function level documentation for details on the various configuration
settings.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime::Builder;
<span class="kw">fn </span>main() {
<span class="comment">// build runtime
</span><span class="kw">let </span>runtime = Builder::new_multi_thread()
.worker_threads(<span class="number">4</span>)
.thread_name(<span class="string">"my-custom-name"</span>)
.thread_stack_size(<span class="number">3 </span>* <span class="number">1024 </span>* <span class="number">1024</span>)
.build()
.unwrap();
<span class="comment">// use runtime ...
</span>}</code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Builder" class="impl"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#235-1646">Source</a><a href="#impl-Builder" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new_current_thread" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#246-254">Source</a><h4 class="code-header">pub fn <a href="#method.new_current_thread" class="fn">new_current_thread</a>() -&gt; <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h4></section></summary><div class="docblock"><p>Returns a new builder with the current thread scheduler selected.</p>
<p>Configuration methods can be chained on the return value.</p>
<p>To spawn non-<code>Send</code> tasks on the resulting runtime, combine it with a
<a href="../task/struct.LocalSet.html" title="struct tokio::task::LocalSet"><code>LocalSet</code></a>, or call <a href="crate::runtime::Builder::build_local"><code>build_local</code></a> to create a <a href="crate::runtime::LocalRuntime"><code>LocalRuntime</code></a> (unstable).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_multi_thread" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#261-264">Source</a><h4 class="code-header">pub fn <a href="#method.new_multi_thread" class="fn">new_multi_thread</a>() -&gt; <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h4></section></summary><div class="docblock"><p>Returns a new builder with the multi thread scheduler selected.</p>
<p>Configuration methods can be chained on the return value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.enable_all" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#351-372">Source</a><h4 class="code-header">pub fn <a href="#method.enable_all" class="fn">enable_all</a>(&amp;mut self) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Enables both I/O and time drivers.</p>
<p>Doing this is a shorthand for calling <code>enable_io</code> and <code>enable_time</code>
individually. If additional components are added to Tokio in the future,
<code>enable_all</code> will include these future components.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.worker_threads" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#460-464">Source</a><h4 class="code-header">pub fn <a href="#method.worker_threads" class="fn">worker_threads</a>(&amp;mut self, val: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets the number of worker threads the <code>Runtime</code> will use.</p>
<p>This can be any number above 0 though it is advised to keep this value
on the smaller side.</p>
<p>This will override the value read from environment variable <code>TOKIO_WORKER_THREADS</code>.</p>
<h5 id="default"><a class="doc-anchor" href="#default">§</a>Default</h5>
<p>The default value is the number of cores available to the system.</p>
<p>When using the <code>current_thread</code> runtime this method has no effect.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5><h6 id="multi-threaded-runtime-with-4-threads"><a class="doc-anchor" href="#multi-threaded-runtime-with-4-threads">§</a>Multi threaded runtime with 4 threads</h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="comment">// This will spawn a work-stealing runtime with 4 worker threads.
</span><span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.worker_threads(<span class="number">4</span>)
.build()
.unwrap();
rt.spawn(<span class="kw">async move </span>{});</code></pre></div><h6 id="current-thread-runtime-will-only-run-on-the-current-thread-via-runtimeblock_on"><a class="doc-anchor" href="#current-thread-runtime-will-only-run-on-the-current-thread-via-runtimeblock_on">§</a>Current thread runtime (will only run on the current thread via <code>Runtime::block_on</code>)</h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="comment">// Create a runtime that _must_ be driven from a call
// to `Runtime::block_on`.
</span><span class="kw">let </span>rt = runtime::Builder::new_current_thread()
.build()
.unwrap();
<span class="comment">// This will run the runtime and future on the current thread
</span>rt.block_on(<span class="kw">async move </span>{});</code></pre></div><h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
<p>This will panic if <code>val</code> is not larger than <code>0</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.max_blocking_threads" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#511-515">Source</a><h4 class="code-header">pub fn <a href="#method.max_blocking_threads" class="fn">max_blocking_threads</a>(&amp;mut self, val: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Specifies the limit for additional threads spawned by the Runtime.</p>
<p>These threads are used for blocking operations like tasks spawned
through <a href="../task/fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking"><code>spawn_blocking</code></a>, this includes but is not limited to:</p>
<ul>
<li><a href="../fs/index.html" title="mod tokio::fs"><code>fs</code></a> operations</li>
<li>dns resolution through <a href="../net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs"><code>ToSocketAddrs</code></a></li>
<li>writing to <a href="../io/struct.Stdout.html" title="struct tokio::io::Stdout"><code>Stdout</code></a> or <a href="../io/struct.Stderr.html" title="struct tokio::io::Stderr"><code>Stderr</code></a></li>
<li>reading from <a href="../io/struct.Stdin.html" title="struct tokio::io::Stdin"><code>Stdin</code></a></li>
</ul>
<p>Unlike the <a href="struct.Builder.html#method.worker_threads" title="method tokio::runtime::Builder::worker_threads"><code>worker_threads</code></a>, they are not always active and will exit
if left idle for too long. You can change this timeout duration with <a href="struct.Builder.html#method.thread_keep_alive" title="method tokio::runtime::Builder::thread_keep_alive"><code>thread_keep_alive</code></a>.</p>
<p>Its recommended to not set this limit too low in order to avoid hanging on operations
requiring <a href="../task/fn.spawn_blocking.html" title="fn tokio::task::spawn_blocking"><code>spawn_blocking</code></a>.</p>
<p>The default value is 512.</p>
<h5 id="queue-behavior"><a class="doc-anchor" href="#queue-behavior">§</a>Queue Behavior</h5>
<p>When a blocking task is submitted, it will be inserted into a queue. If available, one of
the idle threads will be notified to run the task. Otherwise, if the threshold set by this
method has not been reached, a new thread will be spawned. If no idle thread is available
and no more threads are allowed to be spawned, the task will remain in the queue until one
of the busy threads pick it up. Note that since the queue does not apply any backpressure,
it could potentially grow unbounded.</p>
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
<p>This will panic if <code>val</code> is not larger than <code>0</code>.</p>
<h5 id="upgrading-from-0x"><a class="doc-anchor" href="#upgrading-from-0x">§</a>Upgrading from 0.x</h5>
<p>In old versions <code>max_threads</code> limited both blocking and worker threads, but the
current <code>max_blocking_threads</code> does not include async worker threads in the count.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.thread_name" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#535-539">Source</a><h4 class="code-header">pub fn <a href="#method.thread_name" class="fn">thread_name</a>(&amp;mut self, val: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets name of threads spawned by the <code>Runtime</code>s thread pool.</p>
<p>The default name is “tokio-runtime-worker”.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.thread_name(<span class="string">"my-pool"</span>)
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.thread_name_fn" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#563-569">Source</a><h4 class="code-header">pub fn <a href="#method.thread_name_fn" class="fn">thread_name_fn</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; &amp;mut Self<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() -&gt; <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Sets a function used to generate the name of threads spawned by the <code>Runtime</code>s thread pool.</p>
<p>The default name fn is <code>|| "tokio-runtime-worker".into()</code>.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.thread_name_fn(|| {
<span class="kw">static </span>ATOMIC_ID: AtomicUsize = AtomicUsize::new(<span class="number">0</span>);
<span class="kw">let </span>id = ATOMIC_ID.fetch_add(<span class="number">1</span>, Ordering::SeqCst);
<span class="macro">format!</span>(<span class="string">"my-pool-{}"</span>, id)
})
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.thread_stack_size" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#593-596">Source</a><h4 class="code-header">pub fn <a href="#method.thread_stack_size" class="fn">thread_stack_size</a>(&amp;mut self, val: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets the stack size (in bytes) for worker threads.</p>
<p>The actual stack size may be greater than this value if the platform
specifies minimal stack size.</p>
<p>The default stack size for spawned threads is 2 MiB, though this
particular stack size is subject to change in the future.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.thread_stack_size(<span class="number">32 </span>* <span class="number">1024</span>)
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.on_thread_start" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#619-625">Source</a><h4 class="code-header">pub fn <a href="#method.on_thread_start" class="fn">on_thread_start</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; &amp;mut Self<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Executes function <code>f</code> after each thread is started but before it starts
doing work.</p>
<p>This is intended for bookkeeping and monitoring use cases.</p>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>runtime = runtime::Builder::new_multi_thread()
.on_thread_start(|| {
<span class="macro">println!</span>(<span class="string">"thread started"</span>);
})
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.on_thread_stop" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#647-653">Source</a><h4 class="code-header">pub fn <a href="#method.on_thread_stop" class="fn">on_thread_stop</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; &amp;mut Self<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Executes function <code>f</code> before each thread stops.</p>
<p>This is intended for bookkeeping and monitoring use cases.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>{
<span class="kw">let </span>runtime = runtime::Builder::new_multi_thread()
.on_thread_stop(|| {
<span class="macro">println!</span>(<span class="string">"thread stopping"</span>);
})
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.on_thread_park" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#728-734">Source</a><h4 class="code-header">pub fn <a href="#method.on_thread_park" class="fn">on_thread_park</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; &amp;mut Self<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Executes function <code>f</code> just before a thread is parked (goes idle).
<code>f</code> is called within the Tokio context, so functions like <a href="../task/fn.spawn.html" title="fn tokio::task::spawn"><code>tokio::spawn</code></a>
can be called, and may result in this thread being unparked immediately.</p>
<p>This can be used to start work only when the executor is idle, or for bookkeeping
and monitoring purposes.</p>
<p>Note: There can only be one park callback for a runtime; calling this function
more than once replaces the last callback defined, rather than adding to it.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5><h6 id="multithreaded-executor"><a class="doc-anchor" href="#multithreaded-executor">§</a>Multithreaded executor</h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>once = AtomicBool::new(<span class="bool-val">true</span>);
<span class="kw">let </span>barrier = Arc::new(Barrier::new(<span class="number">2</span>));
<span class="kw">let </span>runtime = runtime::Builder::new_multi_thread()
.worker_threads(<span class="number">1</span>)
.on_thread_park({
<span class="kw">let </span>barrier = barrier.clone();
<span class="kw">move </span>|| {
<span class="kw">let </span>barrier = barrier.clone();
<span class="kw">if </span>once.swap(<span class="bool-val">false</span>, Ordering::Relaxed) {
tokio::spawn(<span class="kw">async move </span>{ barrier.wait().<span class="kw">await</span>; });
}
}
})
.build()
.unwrap();
runtime.block_on(<span class="kw">async </span>{
barrier.wait().<span class="kw">await</span>;
})</code></pre></div><h6 id="current-thread-executor"><a class="doc-anchor" href="#current-thread-executor">§</a>Current thread executor</h6>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>once = AtomicBool::new(<span class="bool-val">true</span>);
<span class="kw">let </span>barrier = Arc::new(Barrier::new(<span class="number">2</span>));
<span class="kw">let </span>runtime = runtime::Builder::new_current_thread()
.on_thread_park({
<span class="kw">let </span>barrier = barrier.clone();
<span class="kw">move </span>|| {
<span class="kw">let </span>barrier = barrier.clone();
<span class="kw">if </span>once.swap(<span class="bool-val">false</span>, Ordering::Relaxed) {
tokio::spawn(<span class="kw">async move </span>{ barrier.wait().<span class="kw">await</span>; });
}
}
})
.build()
.unwrap();
runtime.block_on(<span class="kw">async </span>{
barrier.wait().<span class="kw">await</span>;
})</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.on_thread_unpark" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#766-772">Source</a><h4 class="code-header">pub fn <a href="#method.on_thread_unpark" class="fn">on_thread_unpark</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; &amp;mut Self<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Executes function <code>f</code> just after a thread unparks (starts executing tasks).</p>
<p>This is intended for bookkeeping and monitoring use cases; note that work
in this callback will increase latencies when the application has allowed one or
more runtime threads to go idle.</p>
<p>Note: There can only be one unpark callback for a runtime; calling this function
more than once replaces the last callback defined, rather than adding to it.</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>runtime = runtime::Builder::new_multi_thread()
.on_thread_unpark(|| {
<span class="macro">println!</span>(<span class="string">"thread unparking"</span>);
})
.build();
runtime.unwrap().block_on(<span class="kw">async </span>{
tokio::task::yield_now().<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"Hello from Tokio!"</span>);
})</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.build" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#985-991">Source</a><h4 class="code-header">pub fn <a href="#method.build" class="fn">build</a>(&amp;mut self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a>&gt;</h4></section></summary><div class="docblock"><p>Creates the configured <code>Runtime</code>.</p>
<p>The returned <code>Runtime</code> instance is ready to spawn tasks.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime::Builder;
<span class="kw">let </span>rt = Builder::new_multi_thread().build().unwrap();
rt.block_on(<span class="kw">async </span>{
<span class="macro">println!</span>(<span class="string">"Hello from the Tokio runtime"</span>);
});</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.thread_keep_alive" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1061-1064">Source</a><h4 class="code-header">pub fn <a href="#method.thread_keep_alive" class="fn">thread_keep_alive</a>(&amp;mut self, duration: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets a custom timeout for a thread in the blocking pool.</p>
<p>By default, the timeout for a thread is set to 10 seconds. This can
be overridden using <code>.thread_keep_alive()</code>.</p>
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.thread_keep_alive(Duration::from_millis(<span class="number">100</span>))
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.global_queue_interval" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1103-1107">Source</a><h4 class="code-header">pub fn <a href="#method.global_queue_interval" class="fn">global_queue_interval</a>(&amp;mut self, val: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets the number of scheduler ticks after which the scheduler will poll the global
task queue.</p>
<p>A scheduler “tick” roughly corresponds to one <code>poll</code> invocation on a task.</p>
<p>By default the global queue interval is 31 for the current-thread scheduler. Please see
<a href="index.html#multi-threaded-runtime-behavior-at-the-time-of-writing" title="mod tokio::runtime">the module documentation</a> for the default behavior of the multi-thread scheduler.</p>
<p>Schedulers have a local queue of already-claimed tasks, and a global queue of incoming
tasks. Setting the interval to a smaller value increases the fairness of the scheduler,
at the cost of more synchronization overhead. That can be beneficial for prioritizing
getting started on new work, especially if tasks frequently yield rather than complete
or await on further I/O. Setting the interval to <code>1</code> will prioritize the global queue and
tasks from the local queue will be executed only if the global queue is empty.
Conversely, a higher value prioritizes existing work, and is a good choice when most
tasks quickly complete polling.</p>
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
<p>This function will panic if 0 is passed as an argument.</p>
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.global_queue_interval(<span class="number">31</span>)
.build();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.event_interval" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1139-1142">Source</a><h4 class="code-header">pub fn <a href="#method.event_interval" class="fn">event_interval</a>(&amp;mut self, val: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Sets the number of scheduler ticks after which the scheduler will poll for
external events (timers, I/O, and so on).</p>
<p>A scheduler “tick” roughly corresponds to one <code>poll</code> invocation on a task.</p>
<p>By default, the event interval is <code>61</code> for all scheduler types.</p>
<p>Setting the event interval determines the effective “priority” of delivering
these external events (which may wake up additional tasks), compared to
executing tasks that are currently ready to run. A smaller value is useful
when tasks frequently spend a long time in polling, or frequently yield,
which can result in overly long delays picking up I/O events. Conversely,
picking up new events requires extra synchronization and syscall overhead,
so if tasks generally complete their polling quickly, a higher event interval
will minimize that overhead while still keeping the scheduler responsive to
events.</p>
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.event_interval(<span class="number">31</span>)
.build();</code></pre></div></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Builder-1" class="impl"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1649-1688">Source</a><a href="#impl-Builder-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.enable_io" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1665-1668">Source</a><h4 class="code-header">pub fn <a href="#method.enable_io" class="fn">enable_io</a>(&amp;mut self) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Enables the I/O driver.</p>
<p>Doing this enables using net, process, signal, and some I/O types on
the runtime.</p>
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.enable_io()
.build()
.unwrap();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.max_io_events_per_tick" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1684-1687">Source</a><h4 class="code-header">pub fn <a href="#method.max_io_events_per_tick" class="fn">max_io_events_per_tick</a>(&amp;mut self, capacity: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Enables the I/O driver and configures the max number of events to be
processed per tick.</p>
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="kw">let </span>rt = runtime::Builder::new_current_thread()
.enable_io()
.max_io_events_per_tick(<span class="number">1024</span>)
.build()
.unwrap();</code></pre></div></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Builder-2" class="impl"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1692-1714">Source</a><a href="#impl-Builder-2" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.enable_time" class="method"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1710-1713">Source</a><h4 class="code-header">pub fn <a href="#method.enable_time" class="fn">enable_time</a>(&amp;mut self) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Enables the time driver.</p>
<p>Doing this enables using <code>tokio::time</code> on the runtime.</p>
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::runtime;
<span class="kw">let </span>rt = runtime::Builder::new_multi_thread()
.enable_time()
.build()
.unwrap();</code></pre></div></div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Builder" class="impl"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1824-1840">Source</a><a href="#impl-Debug-for-Builder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/tokio/runtime/builder.rs.html#1825-1839">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, fmt: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.93.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Builder" class="impl"><a href="#impl-Freeze-for-Builder" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section><section id="impl-RefUnwindSafe-for-Builder" class="impl"><a href="#impl-RefUnwindSafe-for-Builder" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section><section id="impl-Send-for-Builder" class="impl"><a href="#impl-Send-for-Builder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section><section id="impl-Sync-for-Builder" class="impl"><a href="#impl-Sync-for-Builder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section><section id="impl-Unpin-for-Builder" class="impl"><a href="#impl-Unpin-for-Builder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section><section id="impl-UnwindSafe-for-Builder" class="impl"><a href="#impl-UnwindSafe-for-Builder" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>