Add generated documentation
This commit is contained in:
6
doc/tokio/all.html
Normal file
6
doc/tokio/all.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!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="List of all items in this crate"><meta name="keywords" content="rust, rustlang, rust-lang"><title>List of all items in this crate</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate tokio</p><div class="block version"><p>Version 1.0.1</p></div><a id="all-types" href="index.html"><p>Back to index</p></a></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span>
|
||||
</span>
|
||||
<span class="in-band">List of all items</span></h1><h3 id="Structs">Structs</h3><ul class="structs docblock"><li><a href="io/struct.Interest.html">io::Interest</a></li><li><a href="io/struct.ReadBuf.html">io::ReadBuf</a></li><li><a href="io/struct.Ready.html">io::Ready</a></li><li><a href="io/unix/struct.AsyncFd.html">io::unix::AsyncFd</a></li><li><a href="io/unix/struct.AsyncFdReadyGuard.html">io::unix::AsyncFdReadyGuard</a></li><li><a href="io/unix/struct.AsyncFdReadyMutGuard.html">io::unix::AsyncFdReadyMutGuard</a></li><li><a href="io/unix/struct.TryIoError.html">io::unix::TryIoError</a></li><li><a href="net/struct.TcpListener.html">net::TcpListener</a></li><li><a href="net/struct.TcpSocket.html">net::TcpSocket</a></li><li><a href="net/struct.TcpStream.html">net::TcpStream</a></li><li><a href="net/struct.UdpSocket.html">net::UdpSocket</a></li><li><a href="net/struct.UnixDatagram.html">net::UnixDatagram</a></li><li><a href="net/struct.UnixListener.html">net::UnixListener</a></li><li><a href="net/struct.UnixStream.html">net::UnixStream</a></li><li><a href="net/tcp/struct.OwnedReadHalf.html">net::tcp::OwnedReadHalf</a></li><li><a href="net/tcp/struct.OwnedWriteHalf.html">net::tcp::OwnedWriteHalf</a></li><li><a href="net/tcp/struct.ReadHalf.html">net::tcp::ReadHalf</a></li><li><a href="net/tcp/struct.ReuniteError.html">net::tcp::ReuniteError</a></li><li><a href="net/tcp/struct.WriteHalf.html">net::tcp::WriteHalf</a></li><li><a href="net/unix/struct.OwnedReadHalf.html">net::unix::OwnedReadHalf</a></li><li><a href="net/unix/struct.OwnedWriteHalf.html">net::unix::OwnedWriteHalf</a></li><li><a href="net/unix/struct.ReadHalf.html">net::unix::ReadHalf</a></li><li><a href="net/unix/struct.ReuniteError.html">net::unix::ReuniteError</a></li><li><a href="net/unix/struct.SocketAddr.html">net::unix::SocketAddr</a></li><li><a href="net/unix/struct.UCred.html">net::unix::UCred</a></li><li><a href="net/unix/struct.WriteHalf.html">net::unix::WriteHalf</a></li><li><a href="runtime/struct.Builder.html">runtime::Builder</a></li><li><a href="runtime/struct.EnterGuard.html">runtime::EnterGuard</a></li><li><a href="runtime/struct.Handle.html">runtime::Handle</a></li><li><a href="runtime/struct.Runtime.html">runtime::Runtime</a></li><li><a href="task/struct.JoinError.html">task::JoinError</a></li><li><a href="task/struct.JoinHandle.html">task::JoinHandle</a></li><li><a href="task/struct.LocalKey.html">task::LocalKey</a></li><li><a href="task/struct.LocalSet.html">task::LocalSet</a></li><li><a href="time/struct.Instant.html">time::Instant</a></li><li><a href="time/struct.Interval.html">time::Interval</a></li><li><a href="time/struct.Sleep.html">time::Sleep</a></li><li><a href="time/struct.Timeout.html">time::Timeout</a></li><li><a href="time/error/struct.Elapsed.html">time::error::Elapsed</a></li><li><a href="time/error/struct.Error.html">time::error::Error</a></li></ul><h3 id="Traits">Traits</h3><ul class="traits docblock"><li><a href="io/trait.AsyncBufRead.html">io::AsyncBufRead</a></li><li><a href="io/trait.AsyncRead.html">io::AsyncRead</a></li><li><a href="io/trait.AsyncSeek.html">io::AsyncSeek</a></li><li><a href="io/trait.AsyncWrite.html">io::AsyncWrite</a></li><li><a href="net/trait.ToSocketAddrs.html">net::ToSocketAddrs</a></li></ul><h3 id="Macros">Macros</h3><ul class="macros docblock"><li><a href="macro.join.html">join</a></li><li><a href="macro.pin.html">pin</a></li><li><a href="macro.select.html">select</a></li><li><a href="macro.task_local.html">task_local</a></li><li><a href="macro.try_join.html">try_join</a></li></ul><h3 id="Attribute Macros">Attribute Macros</h3><ul class="attributes docblock"><li><a href="attr.main.html">main</a></li><li><a href="attr.test.html">test</a></li></ul><h3 id="Functions">Functions</h3><ul class="functions docblock"><li><a href="net/fn.lookup_host.html">net::lookup_host</a></li><li><a href="fn.spawn.html">spawn</a></li><li><a href="task/fn.block_in_place.html">task::block_in_place</a></li><li><a href="task/fn.spawn.html">task::spawn</a></li><li><a href="task/fn.spawn_blocking.html">task::spawn_blocking</a></li><li><a href="task/fn.spawn_local.html">task::spawn_local</a></li><li><a href="task/fn.yield_now.html">task::yield_now</a></li><li><a href="time/fn.interval.html">time::interval</a></li><li><a href="time/fn.interval_at.html">time::interval_at</a></li><li><a href="time/fn.sleep.html">time::sleep</a></li><li><a href="time/fn.sleep_until.html">time::sleep_until</a></li><li><a href="time/fn.timeout.html">time::timeout</a></li><li><a href="time/fn.timeout_at.html">time::timeout_at</a></li></ul></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
97
doc/tokio/attr.main.html
Normal file
97
doc/tokio/attr.main.html
Normal file
@@ -0,0 +1,97 @@
|
||||
<!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="API documentation for the Rust `main` attr in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, main"><title>tokio::main - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc attr"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "main", ty: "attr", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio_macros/lib.rs.html#155" title="goto source code">[src]</a></span><span class="in-band">Attribute Macro <a href="index.html">tokio</a>::<wbr><a class="attr" href="">main</a></span></h1><pre class="rust attr">#[main]</pre><div class="docblock"><p>Marks async function to be executed by the selected runtime. This macro
|
||||
helps set up a <code>Runtime</code> without requiring the user to use
|
||||
<a href="../tokio/runtime/struct.Runtime.html">Runtime</a> or
|
||||
<a href="../tokio/runtime/struct.Builder.html">Builder</a> directly.</p>
|
||||
<p>Note: This macro is designed to be simplistic and targets applications that
|
||||
do not require a complex setup. If the provided functionality is not
|
||||
sufficient, you may be interested in using
|
||||
<a href="../tokio/runtime/struct.Builder.html">Builder</a>, which provides a more
|
||||
powerful interface.</p>
|
||||
<p>Note: This macro can be used on any function and not just the <code>main</code>
|
||||
function. Using it on a non-main function makes the function behave as if it
|
||||
was synchronous by starting a new runtime each time it is called. If the
|
||||
function is called often, it is preferable to create the runtime using the
|
||||
runtime builder so the runtime can be reused across calls.</p>
|
||||
<h1 id="multi-threaded-runtime" class="section-header"><a href="#multi-threaded-runtime">Multi-threaded runtime</a></h1>
|
||||
<p>To use the multi-threaded runtime, the macro can be configured using</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>(<span class="ident">flavor</span> <span class="op">=</span> <span class="string">"multi_thread"</span>, <span class="ident">worker_threads</span> <span class="op">=</span> <span class="number">10</span>)]</span></pre></div>
|
||||
<p>The <code>worker_threads</code> option configures the number of worker threads, and
|
||||
defaults to the number of cpus on the system. This is the default flavor.</p>
|
||||
<p>Note: The multi-threaded runtime requires the <code>rt-multi-thread</code> feature
|
||||
flag.</p>
|
||||
<h1 id="current-thread-runtime" class="section-header"><a href="#current-thread-runtime">Current thread runtime</a></h1>
|
||||
<p>To use the single-threaded runtime known as the <code>current_thread</code> runtime,
|
||||
the macro can be configured using</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>(<span class="ident">flavor</span> <span class="op">=</span> <span class="string">"current_thread"</span>)]</span></pre></div>
|
||||
<h2 id="function-arguments" class="section-header"><a href="#function-arguments">Function arguments:</a></h2>
|
||||
<p>Arguments are allowed for any functions aside from <code>main</code> which is special</p>
|
||||
<h2 id="usage" class="section-header"><a href="#usage">Usage</a></h2><h3 id="using-the-multi-thread-runtime" class="section-header"><a href="#using-the-multi-thread-runtime">Using the multi-thread runtime</a></h3>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
}</pre></div>
|
||||
<p>Equivalent code not using <code>#[tokio::main]</code></p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">enable_all</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>()
|
||||
.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
})
|
||||
}</pre></div>
|
||||
<h3 id="using-current-thread-runtime" class="section-header"><a href="#using-current-thread-runtime">Using current thread runtime</a></h3>
|
||||
<p>The basic scheduler is single-threaded.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>(<span class="ident">flavor</span> <span class="op">=</span> <span class="string">"current_thread"</span>)]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
}</pre></div>
|
||||
<p>Equivalent code not using <code>#[tokio::main]</code></p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_current_thread</span>()
|
||||
.<span class="ident">enable_all</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>()
|
||||
.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
})
|
||||
}</pre></div>
|
||||
<h3 id="set-number-of-worker-threads" class="section-header"><a href="#set-number-of-worker-threads">Set number of worker threads</a></h3>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>(<span class="ident">worker_threads</span> <span class="op">=</span> <span class="number">2</span>)]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
}</pre></div>
|
||||
<p>Equivalent code not using <code>#[tokio::main]</code></p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">worker_threads</span>(<span class="number">2</span>)
|
||||
.<span class="ident">enable_all</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>()
|
||||
.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello world"</span>);
|
||||
})
|
||||
}</pre></div>
|
||||
<h3 id="note" class="section-header"><a href="#note">NOTE:</a></h3>
|
||||
<p>If you rename the Tokio crate in your dependencies this macro will not work.
|
||||
If you must rename the current version of Tokio because you're also using an
|
||||
older version of Tokio, you <em>must</em> make the current version of Tokio
|
||||
available as <code>tokio</code> in the module where this macro is expanded.</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
24
doc/tokio/attr.test.html
Normal file
24
doc/tokio/attr.test.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!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="API documentation for the Rust `test` attr in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, test"><title>tokio::test - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc attr"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "test", ty: "attr", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio_macros/lib.rs.html#235" title="goto source code">[src]</a></span><span class="in-band">Attribute Macro <a href="index.html">tokio</a>::<wbr><a class="attr" href="">test</a></span></h1><pre class="rust attr">#[test]</pre><div class="docblock"><p>Marks async function to be executed by runtime, suitable to test environment</p>
|
||||
<h2 id="usage" class="section-header"><a href="#usage">Usage</a></h2><h3 id="multi-thread-runtime" class="section-header"><a href="#multi-thread-runtime">Multi-thread runtime</a></h3>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">test</span>(<span class="ident">flavor</span> <span class="op">=</span> <span class="string">"multi_thread"</span>, <span class="ident">worker_threads</span> <span class="op">=</span> <span class="number">1</span>)]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_test</span>() {
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="bool-val">true</span>);
|
||||
}</pre></div>
|
||||
<h3 id="using-default" class="section-header"><a href="#using-default">Using default</a></h3>
|
||||
<p>The default test runtime is single-threaded.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">test</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_test</span>() {
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="bool-val">true</span>);
|
||||
}</pre></div>
|
||||
<h3 id="note" class="section-header"><a href="#note">NOTE:</a></h3>
|
||||
<p>If you rename the Tokio crate in your dependencies this macro will not work.
|
||||
If you must rename the current version of Tokio because you're also using an
|
||||
older version of Tokio, you <em>must</em> make the current version of Tokio
|
||||
available as <code>tokio</code> in the module where this macro is expanded.</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
99
doc/tokio/fn.spawn.html
Normal file
99
doc/tokio/fn.spawn.html
Normal file
@@ -0,0 +1,99 @@
|
||||
<!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="API documentation for the Rust `spawn` fn in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, spawn"><title>tokio::spawn - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "spawn", ty: "fn", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/task/spawn.rs.html#126-135" title="goto source code">[src]</a></span><span class="in-band">Function <a href="index.html">tokio</a>::<wbr><a class="fn" href="">spawn</a></span></h1><pre class="rust fn">pub fn spawn<T>(task: T) -> <a class="struct" href="../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></h3><code class="content"><span class="where fmt-newline">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../tokio/task/struct.JoinError.html" title="struct tokio::task::JoinError">JoinError</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> T::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, </span></pre><div class="docblock"><p>Spawns a new asynchronous task, returning a
|
||||
<a href="../tokio/task/struct.JoinHandle.html"><code>JoinHandle</code></a> for it.</p>
|
||||
<p>Spawning a task enables the task to execute concurrently to other tasks. The
|
||||
spawned task may execute on the current thread, or it may be sent to a
|
||||
different thread to be executed. The specifics depend on the current
|
||||
<a href="../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a> configuration.</p>
|
||||
<p>There is no guarantee that a spawned task will execute to completion.
|
||||
When a runtime is shutdown, all outstanding tasks are dropped,
|
||||
regardless of the lifecycle of that task.</p>
|
||||
<p>This function must be called from the context of a Tokio runtime. Tasks running on
|
||||
the Tokio runtime are always inside its context, but you can also enter the context
|
||||
using the <a href="../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> method.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>In this example, a server is started and <code>spawn</code> is used to start a new task
|
||||
that processes each received connection.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::{<span class="ident">TcpListener</span>, <span class="ident">TcpStream</span>};
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">process</span>(<span class="ident">socket</span>: <span class="ident">TcpStream</span>) {
|
||||
<span class="comment">// ...</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="ident">socket</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="comment">// Process each socket concurrently.</span>
|
||||
<span class="ident">process</span>(<span class="ident">socket</span>).<span class="ident">await</span>
|
||||
});
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>Panics if called from <strong>outside</strong> of the Tokio runtime.</p>
|
||||
<h1 id="using-send-values-from-a-task" class="section-header"><a href="#using-send-values-from-a-task">Using <code>!Send</code> values from a task</a></h1>
|
||||
<p>The task supplied to <code>spawn</code> must implement <code>Send</code>. However, it is
|
||||
possible to <strong>use</strong> <code>!Send</code> values from the task as long as they only
|
||||
exist between calls to <code>.await</code>.</p>
|
||||
<p>For example, this will work:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">task</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Rc</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">use_rc</span>(<span class="ident">rc</span>: <span class="ident">Rc</span><span class="op"><</span>()<span class="op">></span>) {
|
||||
<span class="comment">// Do stuff w/ rc</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> {
|
||||
<span class="comment">// Force the `Rc` to stay in a scope with no `.await`</span>
|
||||
{
|
||||
<span class="kw">let</span> <span class="ident">rc</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(());
|
||||
<span class="ident">use_rc</span>(<span class="ident">rc</span>.<span class="ident">clone</span>());
|
||||
}
|
||||
|
||||
<span class="ident">task</span>::<span class="ident">yield_now</span>().<span class="ident">await</span>;
|
||||
}).<span class="ident">await</span>.<span class="ident">unwrap</span>();
|
||||
}</pre></div>
|
||||
<p>This will <strong>not</strong> work:</p>
|
||||
|
||||
<div class='information'><div class='tooltip compile_fail'>ⓘ<span class='tooltiptext'>This example deliberately fails to compile</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered compile_fail">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">task</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Rc</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">use_rc</span>(<span class="ident">rc</span>: <span class="ident">Rc</span><span class="op"><</span>()<span class="op">></span>) {
|
||||
<span class="comment">// Do stuff w/ rc</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> {
|
||||
<span class="kw">let</span> <span class="ident">rc</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(());
|
||||
|
||||
<span class="ident">task</span>::<span class="ident">yield_now</span>().<span class="ident">await</span>;
|
||||
|
||||
<span class="ident">use_rc</span>(<span class="ident">rc</span>.<span class="ident">clone</span>());
|
||||
}).<span class="ident">await</span>.<span class="ident">unwrap</span>();
|
||||
}</pre></div>
|
||||
<p>Holding on to a <code>!Send</code> value across calls to <code>.await</code> will result in
|
||||
an unfriendly compile error message similar to:</p>
|
||||
<pre><code class="language-text">`[... some type ...]` cannot be sent between threads safely
|
||||
</code></pre>
|
||||
<p>or:</p>
|
||||
<pre><code class="language-text">error[E0391]: cycle detected when processing `main`
|
||||
</code></pre>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
254
doc/tokio/index.html
Normal file
254
doc/tokio/index.html
Normal file
@@ -0,0 +1,254 @@
|
||||
<!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="API documentation for the Rust `tokio` crate."><meta name="keywords" content="rust, rustlang, rust-lang, tokio"><title>tokio - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate tokio</p><div class="block version"><p>Version 1.0.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all tokio's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#functions">Functions</a></li></ul></div><p class="location"></p><script>window.sidebarCurrent = {name: "tokio", ty: "mod", relpath: "../"};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/lib.rs.html#1-481" title="goto source code">[src]</a></span><span class="in-band">Crate <a class="mod" href="">tokio</a></span></h1><div class="docblock"><p>A runtime for writing reliable network applications without compromising speed.</p>
|
||||
<p>Tokio is an event-driven, non-blocking I/O platform for writing asynchronous
|
||||
applications with the Rust programming language. At a high level, it
|
||||
provides a few major components:</p>
|
||||
<ul>
|
||||
<li>Tools for <a href="#working-with-tasks">working with asynchronous tasks</a>, including
|
||||
<a href="crate::sync">synchronization primitives and channels</a> and <a href="../tokio/time/index.html">timeouts, sleeps, and
|
||||
intervals</a>.</li>
|
||||
<li>APIs for <a href="#asynchronous-io">performing asynchronous I/O</a>, including <a href="../tokio/net/index.html">TCP and UDP</a> sockets,
|
||||
<a href="crate::fs">filesystem</a> operations, and <a href="crate::process">process</a> and <a href="crate::signal">signal</a> management.</li>
|
||||
<li>A <a href="../tokio/runtime/index.html">runtime</a> for executing asynchronous code, including a task scheduler,
|
||||
an I/O driver backed by the operating system's event queue (epoll, kqueue,
|
||||
IOCP, etc...), and a high performance timer.</li>
|
||||
</ul>
|
||||
<p>Guide level documentation is found on the <a href="https://tokio.rs/tokio/tutorial">website</a>.</p>
|
||||
<h1 id="a-tour-of-tokio" class="section-header"><a href="#a-tour-of-tokio">A Tour of Tokio</a></h1>
|
||||
<p>Tokio consists of a number of modules that provide a range of functionality
|
||||
essential for implementing asynchronous applications in Rust. In this
|
||||
section, we will take a brief tour of Tokio, summarizing the major APIs and
|
||||
their uses.</p>
|
||||
<p>The easiest way to get started is to enable all features. Do this by
|
||||
enabling the <code>full</code> feature flag:</p>
|
||||
<pre><code class="language-toml">tokio = { version = "1", features = ["full"] }
|
||||
</code></pre>
|
||||
<h3 id="authoring-applications" class="section-header"><a href="#authoring-applications">Authoring applications</a></h3>
|
||||
<p>Tokio is great for writing applications and most users in this case shouldn't
|
||||
worry too much about what features they should pick. If you're unsure, we suggest
|
||||
going with <code>full</code> to ensure that you don't run into any road blocks while you're
|
||||
building your application.</p>
|
||||
<h4 id="example" class="section-header"><a href="#example">Example</a></h4>
|
||||
<p>This example shows the quickest way to get started with Tokio.</p>
|
||||
<pre><code class="language-toml">tokio = { version = "1", features = ["full"] }
|
||||
</code></pre>
|
||||
<h3 id="authoring-libraries" class="section-header"><a href="#authoring-libraries">Authoring libraries</a></h3>
|
||||
<p>As a library author your goal should be to provide the lighest weight crate
|
||||
that is based on Tokio. To achieve this you should ensure that you only enable
|
||||
the features you need. This allows users to pick up your crate without having
|
||||
to enable unnecessary features.</p>
|
||||
<h4 id="example-1" class="section-header"><a href="#example-1">Example</a></h4>
|
||||
<p>This example shows how you may want to import features for a library that just
|
||||
needs to <code>tokio::spawn</code> and use a <code>TcpStream</code>.</p>
|
||||
<pre><code class="language-toml">tokio = { version = "1", features = ["rt", "net"] }
|
||||
</code></pre>
|
||||
<h2 id="working-with-tasks" class="section-header"><a href="#working-with-tasks">Working With Tasks</a></h2>
|
||||
<p>Asynchronous programs in Rust are based around lightweight, non-blocking
|
||||
units of execution called <a href="#working-with-tasks"><em>tasks</em></a>. The <a href="../tokio/task/index.html"><code>tokio::task</code></a> module provides
|
||||
important tools for working with tasks:</p>
|
||||
<ul>
|
||||
<li>The <a href="../tokio/fn.spawn.html"><code>spawn</code></a> function and <a href="../tokio/task/struct.JoinHandle.html"><code>JoinHandle</code></a> type, for scheduling a new task
|
||||
on the Tokio runtime and awaiting the output of a spawned task, respectively,</li>
|
||||
<li>Functions for <a href="task/index.html#blocking-and-yielding">running blocking operations</a> in an asynchronous
|
||||
task context.</li>
|
||||
</ul>
|
||||
<p>The <a href="../tokio/task/index.html"><code>tokio::task</code></a> module is present only when the "rt" feature flag
|
||||
is enabled.</p>
|
||||
<p>The <a href="crate::sync"><code>tokio::sync</code></a> module contains synchronization primitives to use when
|
||||
needing to communicate or share data. These include:</p>
|
||||
<ul>
|
||||
<li>channels (<a href="crate::sync::oneshot"><code>oneshot</code></a>, <a href="crate::sync::mpsc"><code>mpsc</code></a>, and <a href="crate::sync::watch"><code>watch</code></a>), for sending values
|
||||
between tasks,</li>
|
||||
<li>a non-blocking <a href="crate::sync::Mutex"><code>Mutex</code></a>, for controlling access to a shared, mutable
|
||||
value,</li>
|
||||
<li>an asynchronous <a href="crate::sync::Barrier"><code>Barrier</code></a> type, for multiple tasks to synchronize before
|
||||
beginning a computation.</li>
|
||||
</ul>
|
||||
<p>The <code>tokio::sync</code> module is present only when the "sync" feature flag is
|
||||
enabled.</p>
|
||||
<p>The <a href="../tokio/time/index.html"><code>tokio::time</code></a> module provides utilities for tracking time and
|
||||
scheduling work. This includes functions for setting <a href="../tokio/time/fn.timeout.html">timeouts</a> for
|
||||
tasks, <a href="../tokio/time/fn.sleep.html">sleeping</a> work to run in the future, or <a href="../tokio/time/fn.interval.html">repeating an operation at an
|
||||
interval</a>.</p>
|
||||
<p>In order to use <code>tokio::time</code>, the "time" feature flag must be enabled.</p>
|
||||
<p>Finally, Tokio provides a <em>runtime</em> for executing asynchronous tasks. Most
|
||||
applications can use the <a href="attr.main.html"><code>#[tokio::main]</code></a> macro to run their code on the
|
||||
Tokio runtime. However, this macro provides only basic configuration options. As
|
||||
an alternative, the <a href="../tokio/runtime/index.html"><code>tokio::runtime</code></a> module provides more powerful APIs for configuring
|
||||
and managing runtimes. You should use that module if the <code>#[tokio::main]</code> macro doesn't
|
||||
provide the functionality you need.</p>
|
||||
<p>Using the runtime requires the "rt" or "rt-multi-thread" feature flags, to
|
||||
enable the basic <a href="runtime/index.html#basic-scheduler">single-threaded scheduler</a> and the <a href="runtime/index.html#threaded-scheduler">thread-pool
|
||||
scheduler</a>, respectively. See the <a href="runtime/index.html#runtime-scheduler"><code>runtime</code> module
|
||||
documentation</a> for details. In addition, the "macros" feature
|
||||
flag enables the <code>#[tokio::main]</code> and <code>#[tokio::test]</code> attributes.</p>
|
||||
<h2 id="cpu-bound-tasks-and-blocking-code" class="section-header"><a href="#cpu-bound-tasks-and-blocking-code">CPU-bound tasks and blocking code</a></h2>
|
||||
<p>Tokio is able to concurrently run many tasks on a few threads by repeatedly
|
||||
swapping the currently running task on each thread. However, this kind of
|
||||
swapping can only happen at <code>.await</code> points, so code that spends a long time
|
||||
without reaching an <code>.await</code> will prevent other tasks from running. To
|
||||
combat this, Tokio provides two kinds of threads: Core threads and blocking
|
||||
threads. The core threads are where all asynchronous code runs, and Tokio
|
||||
will by default spawn one for each CPU core. The blocking threads are
|
||||
spawned on demand, can be used to run blocking code that would otherwise
|
||||
block other tasks from running and are kept alive when not used for a certain
|
||||
amount of time which can be configured with <a href="../tokio/runtime/struct.Builder.html#method.thread_keep_alive"><code>thread_keep_alive</code></a>.
|
||||
Since it is not possible for Tokio to swap out blocking tasks, like it
|
||||
can do with asynchronous code, the upper limit on the number of blocking
|
||||
threads is very large. These limits can be configured on the <a href="../tokio/runtime/struct.Builder.html"><code>Builder</code></a>.</p>
|
||||
<p>To spawn a blocking task, you should use the <a href="../tokio/task/fn.spawn_blocking.html"><code>spawn_blocking</code></a> function.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="comment">// This is running on a core thread.</span>
|
||||
|
||||
<span class="kw">let</span> <span class="ident">blocking_task</span> <span class="op">=</span> <span class="ident">tokio</span>::<span class="ident">task</span>::<span class="ident">spawn_blocking</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="comment">// This is running on a blocking thread.</span>
|
||||
<span class="comment">// Blocking here is ok.</span>
|
||||
});
|
||||
|
||||
<span class="comment">// We can wait for the blocking task like this:</span>
|
||||
<span class="comment">// If the blocking task panics, the unwrap below will propagate the</span>
|
||||
<span class="comment">// panic.</span>
|
||||
<span class="ident">blocking_task</span>.<span class="ident">await</span>.<span class="ident">unwrap</span>();
|
||||
}</pre></div>
|
||||
<p>If your code is CPU-bound and you wish to limit the number of threads used
|
||||
to run it, you should run it on another thread pool such as <a href="https://docs.rs/rayon">rayon</a>. You
|
||||
can use an <a href="crate::sync::oneshot"><code>oneshot</code></a> channel to send the result back to Tokio when the
|
||||
rayon task finishes.</p>
|
||||
<h2 id="asynchronous-io" class="section-header"><a href="#asynchronous-io">Asynchronous IO</a></h2>
|
||||
<p>As well as scheduling and running tasks, Tokio provides everything you need
|
||||
to perform input and output asynchronously.</p>
|
||||
<p>The <a href="../tokio/io/index.html"><code>tokio::io</code></a> module provides Tokio's asynchronous core I/O primitives,
|
||||
the <a href="../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a>, <a href="../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a>, and <a href="../tokio/io/trait.AsyncBufRead.html"><code>AsyncBufRead</code></a> traits. In addition,
|
||||
when the "io-util" feature flag is enabled, it also provides combinators and
|
||||
functions for working with these traits, forming as an asynchronous
|
||||
counterpart to <a href="https://doc.rust-lang.org/nightly/std/io/index.html"><code>std::io</code></a>.</p>
|
||||
<p>Tokio also includes APIs for performing various kinds of I/O and interacting
|
||||
with the operating system asynchronously. These include:</p>
|
||||
<ul>
|
||||
<li><a href="../tokio/net/index.html"><code>tokio::net</code></a>, which contains non-blocking versions of <a href="../tokio/net/tcp/index.html">TCP</a>, <a href="../tokio/net/struct.UdpSocket.html">UDP</a>, and
|
||||
<a href="../tokio/net/unix/index.html">Unix Domain Sockets</a> (enabled by the "net" feature flag),</li>
|
||||
<li><a href="crate::fs"><code>tokio::fs</code></a>, similar to <a href="https://doc.rust-lang.org/nightly/std/fs/index.html"><code>std::fs</code></a> but for performing filesystem I/O
|
||||
asynchronously (enabled by the "fs" feature flag),</li>
|
||||
<li><a href="crate::signal"><code>tokio::signal</code></a>, for asynchronously handling Unix and Windows OS signals
|
||||
(enabled by the "signal" feature flag),</li>
|
||||
<li><a href="crate::process"><code>tokio::process</code></a>, for spawning and managing child processes (enabled by
|
||||
the "process" feature flag).</li>
|
||||
</ul>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>A simple TCP echo server:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="ident">AsyncReadExt</span>, <span class="ident">AsyncWriteExt</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">socket</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// In a loop, read data from the socket and write the data back.</span>
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span> {
|
||||
<span class="comment">// socket closed</span>
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="kw">if</span> <span class="ident">n</span> <span class="op">=</span><span class="op">=</span> <span class="number">0</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span>,
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> <span class="ident">n</span>,
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">eprintln</span><span class="macro">!</span>(<span class="string">"failed to read from socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">// Write the data back</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span><span class="ident">buf</span>[<span class="number">0</span>..<span class="ident">n</span>]).<span class="ident">await</span> {
|
||||
<span class="macro">eprintln</span><span class="macro">!</span>(<span class="string">"failed to write to socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}</pre></div>
|
||||
<h2 id="feature-flags" class="section-header"><a href="#feature-flags">Feature flags</a></h2>
|
||||
<p>Tokio uses a set of <a href="https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section">feature flags</a> to reduce the amount of compiled code. It
|
||||
is possible to just enable certain features over others. By default, Tokio
|
||||
does not enable any features but allows one to enable a subset for their use
|
||||
case. Below is a list of the available feature flags. You may also notice
|
||||
above each function, struct and trait there is listed one or more feature flags
|
||||
that are required for that item to be used. If you are new to Tokio it is
|
||||
recommended that you use the <code>full</code> feature flag which will enable all public APIs.
|
||||
Beware though that this will pull in many extra dependencies that you may not
|
||||
need.</p>
|
||||
<ul>
|
||||
<li><code>full</code>: Enables all Tokio public API features listed below.</li>
|
||||
<li><code>rt</code>: Enables <code>tokio::spawn</code>, the basic (current thread) scheduler,
|
||||
and non-scheduler utilities.</li>
|
||||
<li><code>rt-multi-thread</code>: Enables the heavier, multi-threaded, work-stealing scheduler.</li>
|
||||
<li><code>io-util</code>: Enables the IO based <code>Ext</code> traits.</li>
|
||||
<li><code>io-std</code>: Enable <code>Stdout</code>, <code>Stdin</code> and <code>Stderr</code> types.</li>
|
||||
<li><code>net</code>: Enables <code>tokio::net</code> types such as <code>TcpStream</code>, <code>UnixStream</code> and <code>UdpSocket</code>,
|
||||
as well as (on Unix-like systems) <code>AsyncFd</code></li>
|
||||
<li><code>time</code>: Enables <code>tokio::time</code> types and allows the schedulers to enable
|
||||
the built in timer.</li>
|
||||
<li><code>process</code>: Enables <code>tokio::process</code> types.</li>
|
||||
<li><code>macros</code>: Enables <code>#[tokio::main]</code> and <code>#[tokio::test]</code> macros.</li>
|
||||
<li><code>sync</code>: Enables all <code>tokio::sync</code> types.</li>
|
||||
<li><code>signal</code>: Enables all <code>tokio::signal</code> types.</li>
|
||||
<li><code>fs</code>: Enables <code>tokio::fs</code> types.</li>
|
||||
<li><code>test-util</code>: Enables testing based infrastructure for the Tokio runtime.</li>
|
||||
</ul>
|
||||
<p><em>Note: <code>AsyncRead</code> and <code>AsyncWrite</code> traits do not require any features and are
|
||||
always available.</em></p>
|
||||
<h3 id="internal-features" class="section-header"><a href="#internal-features">Internal features</a></h3>
|
||||
<p>These features do not expose any new API, but influence internal
|
||||
implementation aspects of Tokio, and can pull in additional
|
||||
dependencies.</p>
|
||||
<ul>
|
||||
<li><code>parking_lot</code>: As a potential optimization, use the <em>parking_lot</em> crate's
|
||||
synchronization primitives internally. MSRV may increase according to the
|
||||
<em>parking_lot</em> release in use.</li>
|
||||
</ul>
|
||||
<h3 id="unstable-features" class="section-header"><a href="#unstable-features">Unstable features</a></h3>
|
||||
<p>These feature flags enable <strong>unstable</strong> features. The public API may break in 1.x
|
||||
releases. To enable these features, the <code>--cfg tokio_unstable</code> must be passed to
|
||||
<code>rustc</code> when compiling. This is easiest done using the <code>RUSTFLAGS</code> env variable:
|
||||
<code>RUSTFLAGS="--cfg tokio_unstable"</code>.</p>
|
||||
<ul>
|
||||
<li><code>tracing</code>: Enables tracing events.</li>
|
||||
</ul>
|
||||
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="io/index.html" title="tokio::io mod">io</a></td><td class="docblock-short"><p>Traits, helpers, and type definitions for asynchronous I/O functionality.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="net/index.html" title="tokio::net mod">net</a></td><td class="docblock-short"><p>TCP/UDP/Unix bindings for <code>tokio</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="runtime/index.html" title="tokio::runtime mod">runtime</a></td><td class="docblock-short"><p>The Tokio runtime.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="stream/index.html" title="tokio::stream mod">stream</a></td><td class="docblock-short"><p>Due to the <code>Stream</code> trait's inclusion in <code>std</code> landing later than Tokio's 1.0
|
||||
release, most of the Tokio stream utilities have been moved into the <a href="https://docs.rs/tokio-stream"><code>tokio-stream</code></a>
|
||||
crate.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="task/index.html" title="tokio::task mod">task</a></td><td class="docblock-short"><p>Asynchronous green-threads.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="time/index.html" title="tokio::time mod">time</a></td><td class="docblock-short"><p>Utilities for tracking time.</p>
|
||||
</td></tr></table><h2 id="macros" class="section-header"><a href="#macros">Macros</a></h2>
|
||||
<table><tr class="module-item"><td><a class="macro" href="macro.join.html" title="tokio::join macro">join</a></td><td class="docblock-short"><p>Wait on multiple concurrent branches, returning when <strong>all</strong> branches
|
||||
complete.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="macro" href="macro.pin.html" title="tokio::pin macro">pin</a></td><td class="docblock-short"><p>Pins a value on the stack.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="macro" href="macro.select.html" title="tokio::select macro">select</a></td><td class="docblock-short"><p>Wait on multiple concurrent branches, returning when the <strong>first</strong> branch
|
||||
completes, cancelling the remaining branches.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="macro" href="macro.task_local.html" title="tokio::task_local macro">task_local</a></td><td class="docblock-short"><p>Declares a new task-local key of type <a href="../tokio/task/struct.LocalKey.html"><code>tokio::task::LocalKey</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="macro" href="macro.try_join.html" title="tokio::try_join macro">try_join</a></td><td class="docblock-short"><p>Wait on multiple concurrent branches, returning when <strong>all</strong> branches
|
||||
complete with <code>Ok(_)</code> or on the first <code>Err(_)</code>.</p>
|
||||
</td></tr></table><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
|
||||
<table><tr class="module-item"><td><a class="fn" href="fn.spawn.html" title="tokio::spawn fn">spawn</a></td><td class="docblock-short"><p>Spawns a new asynchronous task, returning a
|
||||
<a href="../tokio/task/struct.JoinHandle.html"><code>JoinHandle</code></a> for it.</p>
|
||||
</td></tr></table><h2 id="attributes" class="section-header"><a href="#attributes">Attribute Macros</a></h2>
|
||||
<table><tr class="module-item"><td><a class="attr" href="attr.main.html" title="tokio::main attr">main</a></td><td class="docblock-short"><p>Marks async function to be executed by the selected runtime. This macro
|
||||
helps set up a <code>Runtime</code> without requiring the user to use
|
||||
<a href="../tokio/runtime/struct.Runtime.html">Runtime</a> or
|
||||
<a href="../tokio/runtime/struct.Builder.html">Builder</a> directly.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="attr" href="attr.test.html" title="tokio::test attr">test</a></td><td class="docblock-short"><p>Marks async function to be executed by runtime, suitable to test environment</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/io/async_buf_read/trait.AsyncBufRead.html
Normal file
10
doc/tokio/io/async_buf_read/trait.AsyncBufRead.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/trait.AsyncBufRead.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/trait.AsyncBufRead.html">../../../tokio/io/trait.AsyncBufRead.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/trait.AsyncBufRead.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_fd/struct.AsyncFd.html
Normal file
10
doc/tokio/io/async_fd/struct.AsyncFd.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/unix/struct.AsyncFd.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/unix/struct.AsyncFd.html">../../../tokio/io/unix/struct.AsyncFd.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/unix/struct.AsyncFd.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_fd/struct.AsyncFdReadyGuard.html
Normal file
10
doc/tokio/io/async_fd/struct.AsyncFdReadyGuard.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/unix/struct.AsyncFdReadyGuard.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html">../../../tokio/io/unix/struct.AsyncFdReadyGuard.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_fd/struct.AsyncFdReadyMutGuard.html
Normal file
10
doc/tokio/io/async_fd/struct.AsyncFdReadyMutGuard.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html">../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_fd/struct.TryIoError.html
Normal file
10
doc/tokio/io/async_fd/struct.TryIoError.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/unix/struct.TryIoError.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/unix/struct.TryIoError.html">../../../tokio/io/unix/struct.TryIoError.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/unix/struct.TryIoError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_read/trait.AsyncRead.html
Normal file
10
doc/tokio/io/async_read/trait.AsyncRead.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/trait.AsyncRead.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/trait.AsyncRead.html">../../../tokio/io/trait.AsyncRead.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/trait.AsyncRead.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_seek/trait.AsyncSeek.html
Normal file
10
doc/tokio/io/async_seek/trait.AsyncSeek.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/trait.AsyncSeek.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/trait.AsyncSeek.html">../../../tokio/io/trait.AsyncSeek.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/trait.AsyncSeek.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/async_write/trait.AsyncWrite.html
Normal file
10
doc/tokio/io/async_write/trait.AsyncWrite.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/trait.AsyncWrite.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/trait.AsyncWrite.html">../../../tokio/io/trait.AsyncWrite.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/trait.AsyncWrite.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/driver/interest/struct.Interest.html
Normal file
10
doc/tokio/io/driver/interest/struct.Interest.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/io/struct.Interest.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/io/struct.Interest.html">../../../../tokio/io/struct.Interest.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/io/struct.Interest.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/io/driver/ready/struct.Ready.html
Normal file
10
doc/tokio/io/driver/ready/struct.Ready.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/io/struct.Ready.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/io/struct.Ready.html">../../../../tokio/io/struct.Ready.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/io/struct.Ready.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
139
doc/tokio/io/index.html
Normal file
139
doc/tokio/io/index.html
Normal file
@@ -0,0 +1,139 @@
|
||||
<!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="API documentation for the Rust `io` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, io"><title>tokio::io - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module io</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"><a href="../index.html">tokio</a></p><script>window.sidebarCurrent = {name: "io", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/io/mod.rs.html#1-267" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../index.html">tokio</a>::<wbr><a class="mod" href="">io</a></span></h1><div class="docblock"><p>Traits, helpers, and type definitions for asynchronous I/O functionality.</p>
|
||||
<p>This module is the asynchronous version of <code>std::io</code>. Primarily, it
|
||||
defines two traits, <a href="../../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a>, which are asynchronous
|
||||
versions of the <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html"><code>Read</code></a> and <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html"><code>Write</code></a> traits in the standard library.</p>
|
||||
<h1 id="asyncread-and-asyncwrite" class="section-header"><a href="#asyncread-and-asyncwrite">AsyncRead and AsyncWrite</a></h1>
|
||||
<p>Like the standard library's <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html"><code>Read</code></a> and <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html"><code>Write</code></a> traits, <a href="../../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a> and
|
||||
<a href="../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> provide the most general interface for reading and writing
|
||||
input and output. Unlike the standard library's traits, however, they are
|
||||
<em>asynchronous</em> — meaning that reading from or writing to a <code>tokio::io</code>
|
||||
type will <em>yield</em> to the Tokio scheduler when IO is not ready, rather than
|
||||
blocking. This allows other tasks to run while waiting on IO.</p>
|
||||
<p>Another difference is that <code>AsyncRead</code> and <code>AsyncWrite</code> only contain
|
||||
core methods needed to provide asynchronous reading and writing
|
||||
functionality. Instead, utility methods are defined in the <a href="trait@AsyncReadExt"><code>AsyncReadExt</code></a>
|
||||
and <a href="trait@AsyncWriteExt"><code>AsyncWriteExt</code></a> extension traits. These traits are automatically
|
||||
implemented for all values that implement <code>AsyncRead</code> and <code>AsyncWrite</code>
|
||||
respectively.</p>
|
||||
<p>End users will rarely interact directly with <code>AsyncRead</code> and
|
||||
<code>AsyncWrite</code>. Instead, they will use the async functions defined in the
|
||||
extension traits. Library authors are expected to implement <code>AsyncRead</code>
|
||||
and <code>AsyncWrite</code> in order to provide types that behave like byte streams.</p>
|
||||
<p>Even with these differences, Tokio's <code>AsyncRead</code> and <code>AsyncWrite</code> traits
|
||||
can be used in almost exactly the same manner as the standard library's
|
||||
<code>Read</code> and <code>Write</code>. Most types in the standard library that implement <code>Read</code>
|
||||
and <code>Write</code> have asynchronous equivalents in <code>tokio</code> that implement
|
||||
<code>AsyncRead</code> and <code>AsyncWrite</code>, such as <a href="crate::fs::File"><code>File</code></a> and <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>.</p>
|
||||
<p>For example, the standard library documentation introduces <code>Read</code> by
|
||||
<a href="https://doc.rust-lang.org/nightly/std/io/index.html#read-and-write">demonstrating</a> reading some bytes from a <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html"><code>std::fs::File</code></a>. We
|
||||
can do the same with <a href="crate::fs::File"><code>tokio::fs::File</code></a>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">AsyncReadExt</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buffer</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
|
||||
<span class="comment">// read up to 10 bytes</span>
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">f</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buffer</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"The bytes: {:?}"</span>, <span class="kw-2">&</span><span class="ident">buffer</span>[..<span class="ident">n</span>]);
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<h2 id="buffered-readers-and-writers" class="section-header"><a href="#buffered-readers-and-writers">Buffered Readers and Writers</a></h2>
|
||||
<p>Byte-based interfaces are unwieldy and can be inefficient, as we'd need to be
|
||||
making near-constant calls to the operating system. To help with this,
|
||||
<code>std::io</code> comes with <a href="https://doc.rust-lang.org/nightly/std/io/index.html#bufreader-and-bufwriter">support for <em>buffered</em> readers and writers</a>,
|
||||
and therefore, <code>tokio::io</code> does as well.</p>
|
||||
<p>Tokio provides an async version of the <a href="https://doc.rust-lang.org/nightly/std/io/trait.BufRead.html"><code>std::io::BufRead</code></a> trait,
|
||||
<a href="../../tokio/io/trait.AsyncBufRead.html"><code>AsyncBufRead</code></a>; and async <a href="crate::io::BufReader"><code>BufReader</code></a> and <a href="crate::io::BufWriter"><code>BufWriter</code></a> structs, which
|
||||
wrap readers and writers. These wrappers use a buffer, reducing the number
|
||||
of calls and providing nicer methods for accessing exactly what you want.</p>
|
||||
<p>For example, <a href="crate::io::BufReader"><code>BufReader</code></a> works with the <a href="../../tokio/io/trait.AsyncBufRead.html"><code>AsyncBufRead</code></a> trait to add
|
||||
extra methods to any async reader:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">BufReader</span>, <span class="ident">AsyncBufReadExt</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">reader</span> <span class="op">=</span> <span class="ident">BufReader</span>::<span class="ident">new</span>(<span class="ident">f</span>);
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buffer</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">new</span>();
|
||||
|
||||
<span class="comment">// read a line into buffer</span>
|
||||
<span class="ident">reader</span>.<span class="ident">read_line</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buffer</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">buffer</span>);
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p><a href="crate::io::BufWriter"><code>BufWriter</code></a> doesn't add any new ways of writing; it just buffers every call
|
||||
to <a href="crate::io::AsyncWriteExt::write"><code>write</code></a>. However, you <strong>must</strong> flush
|
||||
<a href="crate::io::BufWriter"><code>BufWriter</code></a> to ensure that any buffered data is written.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">BufWriter</span>, <span class="ident">AsyncWriteExt</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">writer</span> <span class="op">=</span> <span class="ident">BufWriter</span>::<span class="ident">new</span>(<span class="ident">f</span>);
|
||||
|
||||
<span class="comment">// Write a byte to the buffer.</span>
|
||||
<span class="ident">writer</span>.<span class="ident">write</span>(<span class="kw-2">&</span>[<span class="number">42u8</span>]).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Flush the buffer before it goes out of scope.</span>
|
||||
<span class="ident">writer</span>.<span class="ident">flush</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
} <span class="comment">// Unless flushed or shut down, the contents of the buffer is discarded on drop.</span>
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<h2 id="implementing-asyncread-and-asyncwrite" class="section-header"><a href="#implementing-asyncread-and-asyncwrite">Implementing AsyncRead and AsyncWrite</a></h2>
|
||||
<p>Because they are traits, we can implement <a href="../../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> for
|
||||
our own types, as well. Note that these traits must only be implemented for
|
||||
non-blocking I/O types that integrate with the futures type system. In
|
||||
other words, these types must never block the thread, and instead the
|
||||
current task is notified when the I/O resource is ready.</p>
|
||||
<h2 id="conversion-to-and-from-sinkstream" class="section-header"><a href="#conversion-to-and-from-sinkstream">Conversion to and from Sink/Stream</a></h2>
|
||||
<p>It is often convenient to encapsulate the reading and writing of
|
||||
bytes and instead work with a <a href="https://docs.rs/futures/0.3/futures/sink/trait.Sink.html"><code>Sink</code></a> or <a href="https://docs.rs/futures/0.3/futures/stream/trait.Stream.html"><code>Stream</code></a> of some data
|
||||
type that is encoded as bytes and/or decoded from bytes. Tokio
|
||||
provides some utility traits in the <a href="https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html">tokio-util</a> crate that
|
||||
abstract the asynchronous buffering that is required and allows
|
||||
you to write <a href="https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Encoder.html"><code>Encoder</code></a> and <a href="https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Decoder.html"><code>Decoder</code></a> functions working with a
|
||||
buffer of bytes, and then use that <a href="https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html">"codec"</a> to transform anything
|
||||
that implements <a href="../../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> into a <code>Sink</code>/<code>Stream</code> of
|
||||
your structured data.</p>
|
||||
<h1 id="standard-input-and-output" class="section-header"><a href="#standard-input-and-output">Standard input and output</a></h1>
|
||||
<p>Tokio provides asynchronous APIs to standard <a href="fn@stdin">input</a>, <a href="fn@stdout">output</a>, and <a href="fn@stderr">error</a>.
|
||||
These APIs are very similar to the ones provided by <code>std</code>, but they also
|
||||
implement <a href="../../tokio/io/trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a>.</p>
|
||||
<p>Note that the standard input / output APIs <strong>must</strong> be used from the
|
||||
context of the Tokio runtime, as they require Tokio-specific features to
|
||||
function. Calling these functions outside of a Tokio runtime will panic.</p>
|
||||
<h1 id="std-re-exports" class="section-header"><a href="#std-re-exports"><code>std</code> re-exports</a></h1>
|
||||
<p>Additionally, <a href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html"><code>Error</code></a>, <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html"><code>ErrorKind</code></a>, <a href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html"><code>Result</code></a>, and <a href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html"><code>SeekFrom</code></a> are
|
||||
re-exported from <code>std::io</code> for ease of use.</p>
|
||||
</div><h2 id="reexports" class="section-header"><a href="#reexports">Re-exports</a></h2>
|
||||
<table><tr><td><code>pub use std::io::<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>;</code></td></tr><tr><td><code>pub use std::io::<a class="enum" href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html" title="enum std::io::error::ErrorKind">ErrorKind</a>;</code></td></tr><tr><td><code>pub use std::io::<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>;</code></td></tr><tr><td><code>pub use std::io::<a class="enum" href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>;</code></td></tr></table><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="unix/index.html" title="tokio::io::unix mod">unix</a></td><td class="docblock-short"><p>Asynchronous IO structures specific to Unix-like operating systems.</p>
|
||||
</td></tr></table><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.Interest.html" title="tokio::io::Interest struct">Interest</a></td><td class="docblock-short"><p>Readiness event interest</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ReadBuf.html" title="tokio::io::ReadBuf struct">ReadBuf</a></td><td class="docblock-short"><p>A wrapper around a byte buffer that is incrementally filled and initialized.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Ready.html" title="tokio::io::Ready struct">Ready</a></td><td class="docblock-short"><p>Describes the readiness state of an I/O resources.</p>
|
||||
</td></tr></table><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2>
|
||||
<table><tr class="module-item"><td><a class="trait" href="trait.AsyncBufRead.html" title="tokio::io::AsyncBufRead trait">AsyncBufRead</a></td><td class="docblock-short"><p>Reads bytes asynchronously.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.AsyncRead.html" title="tokio::io::AsyncRead trait">AsyncRead</a></td><td class="docblock-short"><p>Reads bytes from a source.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.AsyncSeek.html" title="tokio::io::AsyncSeek trait">AsyncSeek</a></td><td class="docblock-short"><p>Seek bytes asynchronously.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.AsyncWrite.html" title="tokio::io::AsyncWrite trait">AsyncWrite</a></td><td class="docblock-short"><p>Writes bytes asynchronously.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/io/read_buf/struct.ReadBuf.html
Normal file
10
doc/tokio/io/read_buf/struct.ReadBuf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/io/struct.ReadBuf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/io/struct.ReadBuf.html">../../../tokio/io/struct.ReadBuf.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/io/struct.ReadBuf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
doc/tokio/io/sidebar-items.js
Normal file
1
doc/tokio/io/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"mod":[["unix","Asynchronous IO structures specific to Unix-like operating systems."]],"struct":[["Interest","Readiness event interest"],["ReadBuf","A wrapper around a byte buffer that is incrementally filled and initialized."],["Ready","Describes the readiness state of an I/O resources."]],"trait":[["AsyncBufRead","Reads bytes asynchronously."],["AsyncRead","Reads bytes from a source."],["AsyncSeek","Seek bytes asynchronously."],["AsyncWrite","Writes bytes asynchronously."]]});
|
||||
63
doc/tokio/io/struct.Interest.html
Normal file
63
doc/tokio/io/struct.Interest.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<!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="API documentation for the Rust `Interest` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Interest"><title>tokio::io::Interest - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Interest</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.add">add</a><a href="#method.is_readable">is_readable</a><a href="#method.is_writable">is_writable</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-BitOr%3CInterest%3E">BitOr<Interest></a><a href="#impl-BitOrAssign%3CInterest%3E">BitOrAssign<Interest></a><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-Eq">Eq</a><a href="#impl-PartialEq%3CInterest%3E">PartialEq<Interest></a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a></p><script>window.sidebarCurrent = {name: "Interest", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#14" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a>::<wbr><a class="struct" href="">Interest</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Interest(_);</pre></div><div class="docblock"><p>Readiness event interest</p>
|
||||
<p>Specifies the readiness events the caller is interested in when awaiting on
|
||||
I/O resource readiness states.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#16-90" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedconstant.READABLE" class="associatedconstant"><code>pub const <a href="#associatedconstant.READABLE" class="constant"><b>READABLE</b></a>: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#20" title="goto source code">[src]</a></h4><div class="docblock"><p>Interest in all readable events.</p>
|
||||
<p>Readable interest includes read-closed events.</p>
|
||||
</div><h4 id="associatedconstant.WRITABLE" class="associatedconstant"><code>pub const <a href="#associatedconstant.WRITABLE" class="constant"><b>WRITABLE</b></a>: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#25" title="goto source code">[src]</a></h4><div class="docblock"><p>Interest in all writable events</p>
|
||||
<p>Writable interest includes write-closed events.</p>
|
||||
</div><h4 id="method.is_readable" class="method"><code>pub const fn <a href="#method.is_readable" class="fnname">is_readable</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#40-42" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns true if the value includes readable interest.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Interest</span>::<span class="ident">READABLE</span>.<span class="ident">is_readable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Interest</span>::<span class="ident">WRITABLE</span>.<span class="ident">is_readable</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">both</span> <span class="op">=</span> <span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>;
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">both</span>.<span class="ident">is_readable</span>());</pre></div>
|
||||
</div><h4 id="method.is_writable" class="method"><code>pub const fn <a href="#method.is_writable" class="fnname">is_writable</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#57-59" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns true if the value includes writable interest.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Interest</span>::<span class="ident">READABLE</span>.<span class="ident">is_writable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Interest</span>::<span class="ident">WRITABLE</span>.<span class="ident">is_writable</span>());
|
||||
|
||||
<span class="kw">let</span> <span class="ident">both</span> <span class="op">=</span> <span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>;
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">both</span>.<span class="ident">is_writable</span>());</pre></div>
|
||||
</div><h4 id="method.add" class="method"><code>pub const fn <a href="#method.add" class="fnname">add</a>(self, other: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#74-76" title="goto source code">[src]</a></h4><div class="docblock"><p>Add together two <code>Interst</code> values.</p>
|
||||
<p>This function works from a <code>const</code> context.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
|
||||
<span class="kw">const</span> <span class="ident">BOTH</span>: <span class="ident">Interest</span> <span class="op">=</span> <span class="ident">Interest</span>::<span class="ident">READABLE</span>.<span class="ident">add</span>(<span class="ident">Interest</span>::<span class="ident">WRITABLE</span>);
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">BOTH</span>.<span class="ident">is_readable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">BOTH</span>.<span class="ident">is_writable</span>());</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-BitOr%3CInterest%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html" title="trait core::ops::bit::BitOr">BitOr</a><<a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-BitOr%3CInterest%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#92-99" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#associatedtype.Output" class="type">Output</a> = Self</code></h4><div class='docblock'><p>The resulting type after applying the <code>|</code> operator.</p>
|
||||
</div><h4 id="method.bitor" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#tymethod.bitor" class="fnname">bitor</a>(self, other: Self) -> Self</code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#96-98" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>|</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#tymethod.bitor">Read more</a></p>
|
||||
</div></div><h3 id="impl-BitOrAssign%3CInterest%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html" title="trait core::ops::bit::BitOrAssign">BitOrAssign</a><<a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-BitOrAssign%3CInterest%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#101-106" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bitor_assign" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html#tymethod.bitor_assign" class="fnname">bitor_assign</a>(&mut self, other: Self)</code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#103-105" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>|=</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html#tymethod.bitor_assign">Read more</a></p>
|
||||
</div></div><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Copy" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Copy" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-PartialEq%3CInterest%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-PartialEq%3CInterest%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
|
||||
by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
|
||||
</div><h4 id="method.ne" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
|
||||
</div></div><h3 id="impl-StructuralEq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-StructuralEq" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-StructuralPartialEq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-StructuralPartialEq" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/interest.rs.html#13" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||||
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||||
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
72
doc/tokio/io/struct.ReadBuf.html
Normal file
72
doc/tokio/io/struct.ReadBuf.html
Normal file
@@ -0,0 +1,72 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `ReadBuf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, ReadBuf"><title>tokio::io::ReadBuf - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct ReadBuf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.advance">advance</a><a href="#method.assume_init">assume_init</a><a href="#method.capacity">capacity</a><a href="#method.clear">clear</a><a href="#method.filled">filled</a><a href="#method.filled_mut">filled_mut</a><a href="#method.initialize_unfilled">initialize_unfilled</a><a href="#method.initialize_unfilled_to">initialize_unfilled_to</a><a href="#method.initialized">initialized</a><a href="#method.initialized_mut">initialized_mut</a><a href="#method.new">new</a><a href="#method.put_slice">put_slice</a><a href="#method.remaining">remaining</a><a href="#method.set_filled">set_filled</a><a href="#method.take">take</a><a href="#method.unfilled_mut">unfilled_mut</a><a href="#method.uninit">uninit</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a></p><script>window.sidebarCurrent = {name: "ReadBuf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#27-31" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a>::<wbr><a class="struct" href="">ReadBuf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ReadBuf<'a> { /* fields omitted */ }</pre></div><div class="docblock"><p>A wrapper around a byte buffer that is incrementally filled and initialized.</p>
|
||||
<p>This type is a sort of "double cursor". It tracks three regions in the
|
||||
buffer: a region at the beginning of the buffer that has been logically
|
||||
filled with data, a region that has been initialized at some point but not
|
||||
yet logically filled, and a region at the end that may be uninitialized.
|
||||
The filled region is guaranteed to be a subset of the initialized region.</p>
|
||||
<p>In summary, the contents of the buffer can be visualized as:</p>
|
||||
<pre><code class="language-not_rust">[ capacity ]
|
||||
[ filled | unfilled ]
|
||||
[ initialized | uninitialized ]
|
||||
</code></pre>
|
||||
<p>It is undefined behavior to de-initialize any bytes from the uninitialized
|
||||
region, since it is merely unknown whether this region is uninitialized or
|
||||
not, and if part of it turns out to be initialized, it must stay initialized.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<'a> <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#33-256" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#36-44" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new <code>ReadBuf</code> from a fully initialized buffer.</p>
|
||||
</div><h4 id="method.uninit" class="method"><code>pub fn <a href="#method.uninit" class="fnname">uninit</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a mut [</a><a class="union" href="https://doc.rust-lang.org/nightly/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#50-56" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new <code>ReadBuf</code> from a fully uninitialized buffer.</p>
|
||||
<p>Use <code>assume_init</code> if part of the buffer is known to be already inintialized.</p>
|
||||
</div><h4 id="method.capacity" class="method"><code>pub fn <a href="#method.capacity" class="fnname">capacity</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#60-62" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the total capacity of the buffer.</p>
|
||||
</div><h4 id="method.filled" class="method"><code>pub fn <a href="#method.filled" class="fnname">filled</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#66-72" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a shared reference to the filled portion of the buffer.</p>
|
||||
</div><h4 id="method.filled_mut" class="method"><code>pub fn <a href="#method.filled_mut" class="fnname">filled_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#76-82" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the filled portion of the buffer.</p>
|
||||
</div><h4 id="method.take" class="method"><code>pub fn <a href="#method.take" class="fnname">take</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#86-90" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a new <code>ReadBuf</code> comprised of the unfilled section up to <code>n</code>.</p>
|
||||
</div><h4 id="method.initialized" class="method"><code>pub fn <a href="#method.initialized" class="fnname">initialized</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#96-102" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a shared reference to the initialized portion of the buffer.</p>
|
||||
<p>This includes the filled portion.</p>
|
||||
</div><h4 id="method.initialized_mut" class="method"><code>pub fn <a href="#method.initialized_mut" class="fnname">initialized_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#108-114" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the initialized portion of the buffer.</p>
|
||||
<p>This includes the filled portion.</p>
|
||||
</div><h4 id="method.unfilled_mut" class="method"><code>pub unsafe fn <a href="#method.unfilled_mut" class="fnname">unfilled_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="union" href="https://doc.rust-lang.org/nightly/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#124-126" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the unfilled part of the buffer without ensuring that it has been fully
|
||||
initialized.</p>
|
||||
<h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1>
|
||||
<p>The caller must not de-initialize portions of the buffer that have already been initialized.
|
||||
This includes any bytes in the region marked as uninitialized by <code>ReadBuf</code>.</p>
|
||||
</div><h4 id="method.initialize_unfilled" class="method"><code>pub fn <a href="#method.initialize_unfilled" class="fnname">initialize_unfilled</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#133-135" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the unfilled part of the buffer, ensuring it is fully initialized.</p>
|
||||
<p>Since <code>ReadBuf</code> tracks the region of the buffer that has been initialized, this is effectively "free" after
|
||||
the first use.</p>
|
||||
</div><h4 id="method.initialize_unfilled_to" class="method"><code>pub fn <a href="#method.initialize_unfilled_to" class="fnname">initialize_unfilled_to</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#144-163" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the first <code>n</code> bytes of the unfilled part of the buffer, ensuring it is
|
||||
fully initialized.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>Panics if <code>self.remaining()</code> is less than <code>n</code>.</p>
|
||||
</div><h4 id="method.remaining" class="method"><code>pub fn <a href="#method.remaining" class="fnname">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#167-169" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the number of bytes at the end of the slice that have not yet been filled.</p>
|
||||
</div><h4 id="method.clear" class="method"><code>pub fn <a href="#method.clear" class="fnname">clear</a>(&mut self)</code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#175-177" title="goto source code">[src]</a></h4><div class="docblock"><p>Clears the buffer, resetting the filled region to empty.</p>
|
||||
<p>The number of initialized bytes is not changed, and the contents of the buffer are not modified.</p>
|
||||
</div><h4 id="method.advance" class="method"><code>pub fn <a href="#method.advance" class="fnname">advance</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#187-190" title="goto source code">[src]</a></h4><div class="docblock"><p>Advances the size of the filled region of the buffer.</p>
|
||||
<p>The number of initialized bytes is not changed.</p>
|
||||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||||
<p>Panics if the filled region of the buffer would become larger than the initialized region.</p>
|
||||
</div><h4 id="method.set_filled" class="method"><code>pub fn <a href="#method.set_filled" class="fnname">set_filled</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#203-209" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the size of the filled region of the buffer.</p>
|
||||
<p>The number of initialized bytes is not changed.</p>
|
||||
<p>Note that this can be used to <em>shrink</em> the filled region of the buffer in addition to growing it (for
|
||||
example, by a <code>AsyncRead</code> implementation that compresses data in-place).</p>
|
||||
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
|
||||
<p>Panics if the filled region of the buffer would become larger than the intialized region.</p>
|
||||
</div><h4 id="method.assume_init" class="method"><code>pub unsafe fn <a href="#method.assume_init" class="fnname">assume_init</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#220-225" title="goto source code">[src]</a></h4><div class="docblock"><p>Asserts that the first <code>n</code> unfilled bytes of the buffer are initialized.</p>
|
||||
<p><code>ReadBuf</code> assumes that bytes are never de-initialized, so this method does nothing when called with fewer
|
||||
bytes than are already known to be initialized.</p>
|
||||
<h1 id="safety-1" class="section-header"><a href="#safety-1">Safety</a></h1>
|
||||
<p>The caller must ensure that <code>n</code> unfilled bytes of the buffer have already been initialized.</p>
|
||||
</div><h4 id="method.put_slice" class="method"><code>pub fn <a href="#method.put_slice" class="fnname">put_slice</a>(&mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#233-255" title="goto source code">[src]</a></h4><div class="docblock"><p>Appends data to the buffer, advancing the written position and possibly also the initialized position.</p>
|
||||
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
|
||||
<p>Panics if <code>self.remaining()</code> is less than <code>buf.len()</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#258-266" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/io/read_buf.rs.html#259-265" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
86
doc/tokio/io/struct.Ready.html
Normal file
86
doc/tokio/io/struct.Ready.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!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="API documentation for the Rust `Ready` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Ready"><title>tokio::io::Ready - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Ready</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.is_empty">is_empty</a><a href="#method.is_read_closed">is_read_closed</a><a href="#method.is_readable">is_readable</a><a href="#method.is_writable">is_writable</a><a href="#method.is_write_closed">is_write_closed</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-BitAnd%3CReady%3E">BitAnd<Ready></a><a href="#impl-BitOr%3CReady%3E">BitOr<Ready></a><a href="#impl-BitOrAssign%3CReady%3E">BitOrAssign<Ready></a><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-PartialEq%3CReady%3E">PartialEq<Ready></a><a href="#impl-PartialOrd%3CReady%3E">PartialOrd<Ready></a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a><a href="#impl-Sub%3CReady%3E">Sub<Ready></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a></p><script>window.sidebarCurrent = {name: "Ready", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#16" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a>::<wbr><a class="struct" href="">Ready</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Ready(_);</pre></div><div class="docblock"><p>Describes the readiness state of an I/O resources.</p>
|
||||
<p><code>Ready</code> tracks which operation an I/O resource is ready to perform.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#18-164" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedconstant.EMPTY" class="associatedconstant"><code>pub const <a href="#associatedconstant.EMPTY" class="constant"><b>EMPTY</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#20" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the empty <code>Ready</code> set.</p>
|
||||
</div><h4 id="associatedconstant.READABLE" class="associatedconstant"><code>pub const <a href="#associatedconstant.READABLE" class="constant"><b>READABLE</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#23" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Ready</code> representing readable readiness.</p>
|
||||
</div><h4 id="associatedconstant.WRITABLE" class="associatedconstant"><code>pub const <a href="#associatedconstant.WRITABLE" class="constant"><b>WRITABLE</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#26" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Ready</code> representing writable readiness.</p>
|
||||
</div><h4 id="associatedconstant.READ_CLOSED" class="associatedconstant"><code>pub const <a href="#associatedconstant.READ_CLOSED" class="constant"><b>READ_CLOSED</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#29" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Ready</code> representing read closed readiness.</p>
|
||||
</div><h4 id="associatedconstant.WRITE_CLOSED" class="associatedconstant"><code>pub const <a href="#associatedconstant.WRITE_CLOSED" class="constant"><b>WRITE_CLOSED</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#32" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Ready</code> representing write closed readiness.</p>
|
||||
</div><h4 id="associatedconstant.ALL" class="associatedconstant"><code>pub const <a href="#associatedconstant.ALL" class="constant"><b>ALL</b></a>: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#35" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Ready</code> representing readiness for all operations.</p>
|
||||
</div><h4 id="method.is_empty" class="method"><code>pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#70-72" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns true if <code>Ready</code> is the empty set</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Ready</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">EMPTY</span>.<span class="ident">is_empty</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">READABLE</span>.<span class="ident">is_empty</span>());</pre></div>
|
||||
</div><h4 id="method.is_readable" class="method"><code>pub fn <a href="#method.is_readable" class="fnname">is_readable</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#86-88" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the value includes <code>readable</code></p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Ready</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">EMPTY</span>.<span class="ident">is_readable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">READABLE</span>.<span class="ident">is_readable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">READ_CLOSED</span>.<span class="ident">is_readable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">WRITABLE</span>.<span class="ident">is_readable</span>());</pre></div>
|
||||
</div><h4 id="method.is_writable" class="method"><code>pub fn <a href="#method.is_writable" class="fnname">is_writable</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#102-104" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the value includes writable <code>readiness</code></p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Ready</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">EMPTY</span>.<span class="ident">is_writable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">READABLE</span>.<span class="ident">is_writable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">WRITABLE</span>.<span class="ident">is_writable</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">WRITE_CLOSED</span>.<span class="ident">is_writable</span>());</pre></div>
|
||||
</div><h4 id="method.is_read_closed" class="method"><code>pub fn <a href="#method.is_read_closed" class="fnname">is_read_closed</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#117-119" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the value includes read-closed <code>readiness</code></p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Ready</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">EMPTY</span>.<span class="ident">is_read_closed</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">READABLE</span>.<span class="ident">is_read_closed</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">READ_CLOSED</span>.<span class="ident">is_read_closed</span>());</pre></div>
|
||||
</div><h4 id="method.is_write_closed" class="method"><code>pub fn <a href="#method.is_write_closed" class="fnname">is_write_closed</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#132-134" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the value includes write-closed <code>readiness</code></p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Ready</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">EMPTY</span>.<span class="ident">is_write_closed</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Ready</span>::<span class="ident">WRITABLE</span>.<span class="ident">is_write_closed</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Ready</span>::<span class="ident">WRITE_CLOSED</span>.<span class="ident">is_write_closed</span>());</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-BitAnd%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html" title="trait core::ops::bit::BitAnd">BitAnd</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-BitAnd%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#212-219" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code></h4><div class='docblock'><p>The resulting type after applying the <code>&</code> operator.</p>
|
||||
</div><h4 id="method.bitand" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html#tymethod.bitand" class="fnname">bitand</a>(self, other: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#216-218" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>&</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html#tymethod.bitand">Read more</a></p>
|
||||
</div></div><h3 id="impl-BitOr%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html" title="trait core::ops::bit::BitOr">BitOr</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-BitOr%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#196-203" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code></h4><div class='docblock'><p>The resulting type after applying the <code>|</code> operator.</p>
|
||||
</div><h4 id="method.bitor" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#tymethod.bitor" class="fnname">bitor</a>(self, other: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#200-202" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>|</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#tymethod.bitor">Read more</a></p>
|
||||
</div></div><h3 id="impl-BitOrAssign%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html" title="trait core::ops::bit::BitOrAssign">BitOrAssign</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-BitOrAssign%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#205-210" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bitor_assign" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html#tymethod.bitor_assign" class="fnname">bitor_assign</a>(&mut self, other: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>)</code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#207-209" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>|=</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOrAssign.html#tymethod.bitor_assign">Read more</a></p>
|
||||
</div></div><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Copy" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Copy" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#230-239" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#231-238" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-PartialEq%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-PartialEq%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
|
||||
by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
|
||||
</div><h4 id="method.ne" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
|
||||
</div></div><h3 id="impl-PartialOrd%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-PartialOrd%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.partial_cmp" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fnname">partial_cmp</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
|
||||
</div><h4 id="method.lt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt" class="fnname">lt</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
|
||||
</div><h4 id="method.le" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le" class="fnname">le</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code>
|
||||
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
|
||||
</div><h4 id="method.gt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt" class="fnname">gt</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
|
||||
</div><h4 id="method.ge" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge" class="fnname">ge</a>(&self, other: &<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code>
|
||||
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
|
||||
</div></div><h3 id="impl-StructuralPartialEq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-StructuralPartialEq" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#15" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sub%3CReady%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Sub%3CReady%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#221-228" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code></h4><div class='docblock'><p>The resulting type after applying the <code>-</code> operator.</p>
|
||||
</div><h4 id="method.sub" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#tymethod.sub" class="fnname">sub</a>(self, other: <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>) -> <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a class="srclink" href="../../src/tokio/io/driver/ready.rs.html#225-227" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the <code>-</code> operation. <a href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#tymethod.sub">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||||
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||||
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
39
doc/tokio/io/trait.AsyncBufRead.html
Normal file
39
doc/tokio/io/trait.AsyncBufRead.html
Normal file
File diff suppressed because one or more lines are too long
45
doc/tokio/io/trait.AsyncRead.html
Normal file
45
doc/tokio/io/trait.AsyncRead.html
Normal file
File diff suppressed because one or more lines are too long
31
doc/tokio/io/trait.AsyncSeek.html
Normal file
31
doc/tokio/io/trait.AsyncSeek.html
Normal file
File diff suppressed because one or more lines are too long
132
doc/tokio/io/trait.AsyncWrite.html
Normal file
132
doc/tokio/io/trait.AsyncWrite.html
Normal file
File diff suppressed because one or more lines are too long
17
doc/tokio/io/unix/index.html
Normal file
17
doc/tokio/io/unix/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!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="API documentation for the Rust `unix` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, unix"><title>tokio::io::unix - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module unix</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a></p><script>window.sidebarCurrent = {name: "unix", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/io/mod.rs.html#223-226" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a class="mod" href="">unix</a></span></h1><div class="docblock"><p>Asynchronous IO structures specific to Unix-like operating systems.</p>
|
||||
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.AsyncFd.html" title="tokio::io::unix::AsyncFd struct">AsyncFd</a></td><td class="docblock-short"><p>Associates an IO object backed by a Unix file descriptor with the tokio
|
||||
reactor, allowing for readiness to be polled. The file descriptor must be of
|
||||
a type that can be used with the OS polling facilities (ie, <code>poll</code>, <code>epoll</code>,
|
||||
<code>kqueue</code>, etc), such as a network socket or pipe.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.AsyncFdReadyGuard.html" title="tokio::io::unix::AsyncFdReadyGuard struct">AsyncFdReadyGuard</a></td><td class="docblock-short"><p>Represents an IO-ready event detected on a particular file descriptor that
|
||||
has not yet been acknowledged. This is a <code>must_use</code> structure to help ensure
|
||||
that you do not forget to explicitly clear (or not clear) the event.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.AsyncFdReadyMutGuard.html" title="tokio::io::unix::AsyncFdReadyMutGuard struct">AsyncFdReadyMutGuard</a></td><td class="docblock-short"><p>Represents an IO-ready event detected on a particular file descriptor that
|
||||
has not yet been acknowledged. This is a <code>must_use</code> structure to help ensure
|
||||
that you do not forget to explicitly clear (or not clear) the event.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.TryIoError.html" title="tokio::io::unix::TryIoError struct">TryIoError</a></td><td class="docblock-short"><p>The error type returned by <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html#method.try_io"><code>try_io</code></a>.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
1
doc/tokio/io/unix/sidebar-items.js
Normal file
1
doc/tokio/io/unix/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["AsyncFd","Associates an IO object backed by a Unix file descriptor with the tokio reactor, allowing for readiness to be polled. The file descriptor must be of a type that can be used with the OS polling facilities (ie, `poll`, `epoll`, `kqueue`, etc), such as a network socket or pipe."],["AsyncFdReadyGuard","Represents an IO-ready event detected on a particular file descriptor that has not yet been acknowledged. This is a `must_use` structure to help ensure that you do not forget to explicitly clear (or not clear) the event."],["AsyncFdReadyMutGuard","Represents an IO-ready event detected on a particular file descriptor that has not yet been acknowledged. This is a `must_use` structure to help ensure that you do not forget to explicitly clear (or not clear) the event."],["TryIoError","The error type returned by `try_io`."]]});
|
||||
217
doc/tokio/io/unix/struct.AsyncFd.html
Normal file
217
doc/tokio/io/unix/struct.AsyncFd.html
Normal file
@@ -0,0 +1,217 @@
|
||||
<!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="API documentation for the Rust `AsyncFd` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncFd"><title>tokio::io::unix::AsyncFd - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct AsyncFd</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.get_mut">get_mut</a><a href="#method.get_ref">get_ref</a><a href="#method.into_inner">into_inner</a><a href="#method.new">new</a><a href="#method.poll_read_ready">poll_read_ready</a><a href="#method.poll_read_ready_mut">poll_read_ready_mut</a><a href="#method.poll_write_ready">poll_write_ready</a><a href="#method.poll_write_ready_mut">poll_write_ready_mut</a><a href="#method.readable">readable</a><a href="#method.readable_mut">readable_mut</a><a href="#method.with_interest">with_interest</a><a href="#method.writable">writable</a><a href="#method.writable_mut">writable_mut</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-Drop">Drop</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "AsyncFd", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#135-138" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">AsyncFd</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct AsyncFd<T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> { /* fields omitted */ }</pre></div><div class="docblock"><p>Associates an IO object backed by a Unix file descriptor with the tokio
|
||||
reactor, allowing for readiness to be polled. The file descriptor must be of
|
||||
a type that can be used with the OS polling facilities (ie, <code>poll</code>, <code>epoll</code>,
|
||||
<code>kqueue</code>, etc), such as a network socket or pipe.</p>
|
||||
<p>Creating an AsyncFd registers the file descriptor with the current tokio
|
||||
Reactor, allowing you to directly await the file descriptor being readable
|
||||
or writable. Once registered, the file descriptor remains registered until
|
||||
the AsyncFd is dropped.</p>
|
||||
<p>The AsyncFd takes ownership of an arbitrary object to represent the IO
|
||||
object. It is intended that this object will handle closing the file
|
||||
descriptor when it is dropped, avoiding resource leaks and ensuring that the
|
||||
AsyncFd can clean up the registration before closing the file descriptor.
|
||||
The <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.into_inner" title="AsyncFd::into_inner"><code>AsyncFd::into_inner</code></a> function can be used to extract the inner object
|
||||
to retake control from the tokio IO reactor.</p>
|
||||
<p>The inner object is required to implement <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="AsRawFd"><code>AsRawFd</code></a>. This file descriptor
|
||||
must not change while <a href="../../../tokio/io/unix/struct.AsyncFd.html" title="AsyncFd"><code>AsyncFd</code></a> owns the inner object. Changing the file
|
||||
descriptor results in unspecified behavior in the IO driver, which may
|
||||
include breaking notifications for other sockets/etc.</p>
|
||||
<p>Polling for readiness is done by calling the async functions <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a>
|
||||
and <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.writable"><code>writable</code></a>. These functions complete when the associated readiness
|
||||
condition is observed. Any number of tasks can query the same <code>AsyncFd</code> in
|
||||
parallel, on the same or different conditions.</p>
|
||||
<p>On some platforms, the readiness detecting mechanism relies on
|
||||
edge-triggered notifications. This means that the OS will only notify Tokio
|
||||
when the file descriptor transitions from not-ready to ready. Tokio
|
||||
internally tracks when it has received a ready notification, and when
|
||||
readiness checking functions like <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a> and <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.writable"><code>writable</code></a> are called,
|
||||
if the readiness flag is set, these async functions will complete
|
||||
immediately.</p>
|
||||
<p>This however does mean that it is critical to ensure that this ready flag is
|
||||
cleared when (and only when) the file descriptor ceases to be ready. The
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html"><code>AsyncFdReadyGuard</code></a> returned from readiness checking functions serves this
|
||||
function; after calling a readiness-checking async function, you must use
|
||||
this <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html"><code>AsyncFdReadyGuard</code></a> to signal to tokio whether the file descriptor is no
|
||||
longer in a ready state.</p>
|
||||
<h2 id="use-with-to-a-poll-based-api" class="section-header"><a href="#use-with-to-a-poll-based-api">Use with to a poll-based API</a></h2>
|
||||
<p>In some cases it may be desirable to use <code>AsyncFd</code> from APIs similar to
|
||||
<a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream::poll_read_ready</code></a>. The <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready" title="AsyncFd::poll_read_ready"><code>AsyncFd::poll_read_ready</code></a> and
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready" title="AsyncFd::poll_write_ready"><code>AsyncFd::poll_write_ready</code></a> functions are provided for this purpose.
|
||||
Because these functions don't create a future to hold their state, they have
|
||||
the limitation that only one task can wait on each direction (read or write)
|
||||
at a time.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>This example shows how to turn <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="std::net::TcpStream"><code>std::net::TcpStream</code></a> asynchronous using
|
||||
<code>AsyncFd</code>. It implements <code>read</code> as an async fn, and <code>AsyncWrite</code> as a trait
|
||||
to show how to implement both approaches.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">ready</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">Read</span>, <span class="ident">Write</span>};
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">pin</span>::<span class="ident">Pin</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">task</span>::{<span class="ident">Context</span>, <span class="ident">Poll</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWrite</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">unix</span>::<span class="ident">AsyncFd</span>;
|
||||
|
||||
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">AsyncTcpStream</span> {
|
||||
<span class="ident">inner</span>: <span class="ident">AsyncFd</span><span class="op"><</span><span class="ident">TcpStream</span><span class="op">></span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">AsyncTcpStream</span> {
|
||||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">new</span>(<span class="ident">tcp</span>: <span class="ident">TcpStream</span>) <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span><span class="self">Self</span><span class="op">></span> {
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self</span> {
|
||||
<span class="ident">inner</span>: <span class="ident">AsyncFd</span>::<span class="ident">new</span>(<span class="ident">tcp</span>)<span class="question-mark">?</span>,
|
||||
})
|
||||
}
|
||||
|
||||
<span class="kw">pub</span> <span class="ident">async</span> <span class="kw">fn</span> <span class="ident">read</span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">out</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> [<span class="ident">u8</span>]) <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">usize</span><span class="op">></span> {
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">guard</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">guard</span>.<span class="ident">try_io</span>(<span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="ident">inner</span>.<span class="ident">get_ref</span>().<span class="ident">read</span>(<span class="ident">out</span>)) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">result</span>) <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">result</span>,
|
||||
<span class="prelude-val">Err</span>(<span class="ident">_would_block</span>) <span class="op">=</span><span class="op">></span> <span class="kw">continue</span>,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">AsyncWrite</span> <span class="kw">for</span> <span class="ident">AsyncTcpStream</span> {
|
||||
<span class="kw">fn</span> <span class="ident">poll_write</span>(
|
||||
<span class="self">self</span>: <span class="ident">Pin</span><span class="op"><</span><span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="op">></span>,
|
||||
<span class="ident">cx</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>,
|
||||
<span class="ident">buf</span>: <span class="kw-2">&</span>[<span class="ident">u8</span>]
|
||||
) <span class="op">-</span><span class="op">></span> <span class="ident">Poll</span><span class="op"><</span><span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">usize</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">guard</span> <span class="op">=</span> <span class="macro">ready</span><span class="macro">!</span>(<span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">poll_write_ready</span>(<span class="ident">cx</span>))<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">guard</span>.<span class="ident">try_io</span>(<span class="op">|</span><span class="ident">inner</span><span class="op">|</span> <span class="ident">inner</span>.<span class="ident">get_ref</span>().<span class="ident">write</span>(<span class="ident">buf</span>)) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">result</span>) <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="ident">result</span>),
|
||||
<span class="prelude-val">Err</span>(<span class="ident">_would_block</span>) <span class="op">=</span><span class="op">></span> <span class="kw">continue</span>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">poll_flush</span>(
|
||||
<span class="self">self</span>: <span class="ident">Pin</span><span class="op"><</span><span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="op">></span>,
|
||||
<span class="ident">cx</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>,
|
||||
) <span class="op">-</span><span class="op">></span> <span class="ident">Poll</span><span class="op"><</span><span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// tcp flush is a no-op</span>
|
||||
<span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="prelude-val">Ok</span>(()))
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">poll_shutdown</span>(
|
||||
<span class="self">self</span>: <span class="ident">Pin</span><span class="op"><</span><span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">Self</span><span class="op">></span>,
|
||||
<span class="ident">cx</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">Context</span><span class="op"><</span><span class="lifetime">'_</span><span class="op">></span>,
|
||||
) <span class="op">-</span><span class="op">></span> <span class="ident">Poll</span><span class="op"><</span><span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span><span class="op">></span> {
|
||||
<span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">get_ref</span>().<span class="ident">shutdown</span>(<span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">Shutdown</span>::<span class="ident">Write</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">Poll</span>::<span class="ident">Ready</span>(<span class="prelude-val">Ok</span>(()))
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#164-456" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(inner: T) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><Self> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>, </span></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#171-176" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates an AsyncFd backed by (and taking ownership of) an object
|
||||
implementing <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="AsRawFd"><code>AsRawFd</code></a>. The backing file descriptor is cached at the
|
||||
time of creation.</p>
|
||||
<p>This method must be called in the context of a tokio runtime.</p>
|
||||
</div><h4 id="method.with_interest" class="method"><code>pub fn <a href="#method.with_interest" class="fnname">with_interest</a>(inner: T, interest: <a class="struct" href="../../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><Self> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>, </span></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#181-186" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new instance as <code>new</code> with additional ability to customize interest,
|
||||
allowing to specify whether file descriptor will be polled for read, write or both.</p>
|
||||
</div><h4 id="method.get_ref" class="method"><code>pub fn <a href="#method.get_ref" class="fnname">get_ref</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#206-208" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a shared reference to the backing object of this <a href="../../../tokio/io/unix/struct.AsyncFd.html" title="AsyncFd"><code>AsyncFd</code></a></p>
|
||||
</div><h4 id="method.get_mut" class="method"><code>pub fn <a href="#method.get_mut" class="fnname">get_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#212-214" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a mutable reference to the backing object of this <a href="../../../tokio/io/unix/struct.AsyncFd.html" title="AsyncFd"><code>AsyncFd</code></a></p>
|
||||
</div><h4 id="method.into_inner" class="method"><code>pub fn <a href="#method.into_inner" class="fnname">into_inner</a>(self) -> T</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#228-230" title="goto source code">[src]</a></h4><div class="docblock"><p>Deregisters this file descriptor and returns ownership of the backing
|
||||
object.</p>
|
||||
</div><h4 id="method.poll_read_ready" class="method"><code>pub fn <a href="#method.poll_read_ready" class="fnname">poll_read_ready</a><'a>(<br> &'a self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T>>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#259-270" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for read readiness.</p>
|
||||
<p>If the file descriptor is not currently ready for reading, this method
|
||||
will store a clone of the <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html"><code>Waker</code></a> from the provided <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html"><code>Context</code></a>. When the
|
||||
file descriptor becomes ready for reading, <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html#method.wake"><code>Waker::wake</code></a> will be called.</p>
|
||||
<p>Note that on multiple calls to <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready"><code>poll_read_ready</code></a> or
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready_mut"><code>poll_read_ready_mut</code></a>, only the <code>Waker</code> from the <code>Context</code> passed to the
|
||||
most recent call is scheduled to receive a wakeup. (However,
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready"><code>poll_write_ready</code></a> retains a second, independent waker).</p>
|
||||
<p>This method is intended for cases where creating and pinning a future
|
||||
via <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a> is not feasible. Where possible, using <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<p>This method takes <code>&self</code>, so it is possible to call this method
|
||||
concurrently with other methods on this struct. This method only
|
||||
provides shared access to the inner IO resource when handling the
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a>.</p>
|
||||
</div><h4 id="method.poll_read_ready_mut" class="method"><code>pub fn <a href="#method.poll_read_ready_mut" class="fnname">poll_read_ready_mut</a><'a>(<br> &'a mut self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T>>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#297-308" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for read readiness.</p>
|
||||
<p>If the file descriptor is not currently ready for reading, this method
|
||||
will store a clone of the <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html"><code>Waker</code></a> from the provided <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html"><code>Context</code></a>. When the
|
||||
file descriptor becomes ready for reading, <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html#method.wake"><code>Waker::wake</code></a> will be called.</p>
|
||||
<p>Note that on multiple calls to <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready"><code>poll_read_ready</code></a> or
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready_mut"><code>poll_read_ready_mut</code></a>, only the <code>Waker</code> from the <code>Context</code> passed to the
|
||||
most recent call is scheduled to receive a wakeup. (However,
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready"><code>poll_write_ready</code></a> retains a second, independent waker).</p>
|
||||
<p>This method is intended for cases where creating and pinning a future
|
||||
via <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a> is not feasible. Where possible, using <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>readable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<p>This method takes <code>&mut self</code>, so it is possible to access the inner IO
|
||||
resource mutably when handling the <a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a>.</p>
|
||||
</div><h4 id="method.poll_write_ready" class="method"><code>pub fn <a href="#method.poll_write_ready" class="fnname">poll_write_ready</a><'a>(<br> &'a self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T>>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#337-348" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for write readiness.</p>
|
||||
<p>If the file descriptor is not currently ready for writing, this method
|
||||
will store a clone of the <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html"><code>Waker</code></a> from the provided <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html"><code>Context</code></a>. When the
|
||||
file descriptor becomes ready for writing, <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html#method.wake"><code>Waker::wake</code></a> will be called.</p>
|
||||
<p>Note that on multiple calls to <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready"><code>poll_write_ready</code></a> or
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready_mut"><code>poll_write_ready_mut</code></a>, only the <code>Waker</code> from the <code>Context</code> passed to the
|
||||
most recent call is scheduled to receive a wakeup. (However,
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready"><code>poll_read_ready</code></a> retains a second, independent waker).</p>
|
||||
<p>This method is intended for cases where creating and pinning a future
|
||||
via <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>writable</code></a> is not feasible. Where possible, using <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>writable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<p>This method takes <code>&self</code>, so it is possible to call this method
|
||||
concurrently with other methods on this struct. This method only
|
||||
provides shared access to the inner IO resource when handling the
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a>.</p>
|
||||
</div><h4 id="method.poll_write_ready_mut" class="method"><code>pub fn <a href="#method.poll_write_ready_mut" class="fnname">poll_write_ready_mut</a><'a>(<br> &'a mut self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T>>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#375-386" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for write readiness.</p>
|
||||
<p>If the file descriptor is not currently ready for writing, this method
|
||||
will store a clone of the <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html"><code>Waker</code></a> from the provided <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html"><code>Context</code></a>. When the
|
||||
file descriptor becomes ready for writing, <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html#method.wake"><code>Waker::wake</code></a> will be called.</p>
|
||||
<p>Note that on multiple calls to <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready"><code>poll_write_ready</code></a> or
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_write_ready_mut"><code>poll_write_ready_mut</code></a>, only the <code>Waker</code> from the <code>Context</code> passed to the
|
||||
most recent call is scheduled to receive a wakeup. (However,
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFd.html#method.poll_read_ready"><code>poll_read_ready</code></a> retains a second, independent waker).</p>
|
||||
<p>This method is intended for cases where creating and pinning a future
|
||||
via <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>writable</code></a> is not feasible. Where possible, using <a href="../../../tokio/io/unix/struct.AsyncFd.html#method.readable"><code>writable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<p>This method takes <code>&mut self</code>, so it is possible to access the inner IO
|
||||
resource mutably when handling the <a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a>.</p>
|
||||
</div><h4 id="method.readable" class="method"><code>pub async fn <a href="#method.readable" class="fnname">readable</a><'a>(&'a self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#418-420" title="goto source code">[src]</a></h4><div class="docblock"><p>Waits for the file descriptor to become readable, returning a
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a> that must be dropped to resume read-readiness
|
||||
polling.</p>
|
||||
<p>This method takes <code>&self</code>, so it is possible to call this method
|
||||
concurrently with other methods on this struct. This method only
|
||||
provides shared access to the inner IO resource when handling the
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a>.</p>
|
||||
</div><h4 id="method.readable_mut" class="method"><code>pub async fn <a href="#method.readable_mut" class="fnname">readable_mut</a><'a>(<br> &'a mut self<br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#429-431" title="goto source code">[src]</a></h4><div class="docblock"><p>Waits for the file descriptor to become readable, returning a
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a> that must be dropped to resume read-readiness
|
||||
polling.</p>
|
||||
<p>This method takes <code>&mut self</code>, so it is possible to access the inner IO
|
||||
resource mutably when handling the <a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a>.</p>
|
||||
</div><h4 id="method.writable" class="method"><code>pub async fn <a href="#method.writable" class="fnname">writable</a><'a>(&'a self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#442-444" title="goto source code">[src]</a></h4><div class="docblock"><p>Waits for the file descriptor to become writable, returning a
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a> that must be dropped to resume write-readiness
|
||||
polling.</p>
|
||||
<p>This method takes <code>&self</code>, so it is possible to call this method
|
||||
concurrently with other methods on this struct. This method only
|
||||
provides shared access to the inner IO resource when handling the
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a>.</p>
|
||||
</div><h4 id="method.writable_mut" class="method"><code>pub async fn <a href="#method.writable_mut" class="fnname">writable_mut</a><'a>(<br> &'a mut self<br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#453-455" title="goto source code">[src]</a></h4><div class="docblock"><p>Waits for the file descriptor to become writable, returning a
|
||||
<a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a> that must be dropped to resume write-readiness
|
||||
polling.</p>
|
||||
<p>This method takes <code>&mut self</code>, so it is possible to access the inner IO
|
||||
resource mutably when handling the <a href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="AsyncFdReadyMutGuard"><code>AsyncFdReadyMutGuard</code></a>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#458-462" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#459-461" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#464-470" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#465-469" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Drop" class="impl"><code class="in-band">impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl-Drop" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#472-476" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.drop" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#473-475" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>, </span></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><T></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
42
doc/tokio/io/unix/struct.AsyncFdReadyGuard.html
Normal file
42
doc/tokio/io/unix/struct.AsyncFdReadyGuard.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!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="API documentation for the Rust `AsyncFdReadyGuard` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncFdReadyGuard"><title>tokio::io::unix::AsyncFdReadyGuard - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct AsyncFdReadyGuard</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.clear_ready">clear_ready</a><a href="#method.retain_ready">retain_ready</a><a href="#method.try_io">try_io</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "AsyncFdReadyGuard", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#146-149" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">AsyncFdReadyGuard</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct"><span class="docblock attributes top-attr">#[must_use =
|
||||
"You must explicitly choose whether to clear the readiness state by calling a method on ReadyGuard"]</span>pub struct AsyncFdReadyGuard<'a, T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> { /* fields omitted */ }</pre></div><div class="docblock"><p>Represents an IO-ready event detected on a particular file descriptor that
|
||||
has not yet been acknowledged. This is a <code>must_use</code> structure to help ensure
|
||||
that you do not forget to explicitly clear (or not clear) the event.</p>
|
||||
<p>This type exposes an immutable reference to the underlying IO object.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<'a, Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, Inner></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#478-537" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clear_ready" class="method"><code>pub fn <a href="#method.clear_ready" class="fnname">clear_ready</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#489-493" title="goto source code">[src]</a></h4><div class="docblock"><p>Indicates to tokio that the file descriptor is no longer ready. The
|
||||
internal readiness flag will be cleared, and tokio will wait for the
|
||||
next edge-triggered readiness notification from the OS.</p>
|
||||
<p>It is critical that this function not be called unless your code
|
||||
<em>actually observes</em> that the file descriptor is <em>not</em> ready. Do not call
|
||||
it simply because, for example, a read succeeded; it should be called
|
||||
when a read is observed to block.</p>
|
||||
</div><h4 id="method.retain_ready" class="method"><code>pub fn <a href="#method.retain_ready" class="fnname">retain_ready</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#500-502" title="goto source code">[src]</a></h4><div class="docblock"><p>This method should be invoked when you intentionally want to keep the
|
||||
ready flag asserted.</p>
|
||||
<p>While this function is itself a no-op, it satisfies the <code>#[must_use]</code>
|
||||
constraint on the <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a> type.</p>
|
||||
</div><h4 id="method.try_io" class="method"><code>pub fn <a href="#method.try_io" class="fnname">try_io</a><R>(<br> &mut self, <br> f: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&<a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><Inner>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><R><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><R>, <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#520-536" title="goto source code">[src]</a></h4><div class="docblock"><p>Performs the provided IO operation.</p>
|
||||
<p>If <code>f</code> returns a <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> error, the readiness state associated
|
||||
with this file descriptor is cleared, and the method returns
|
||||
<code>Err(TryIoError::WouldBlock)</code>. You will typically need to poll the
|
||||
<code>AsyncFd</code> again when this happens.</p>
|
||||
<p>This method helps ensure that the readiness state of the underlying file
|
||||
descriptor remains in sync with the tokio-side readiness state, by
|
||||
clearing the tokio-side state only when a <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> condition
|
||||
occurs. It is the responsibility of the caller to ensure that <code>f</code>
|
||||
returns <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> only if the file descriptor that originated this
|
||||
<code>AsyncFdReadyGuard</code> no longer expresses the readiness state that was queried to
|
||||
create this <code>AsyncFdReadyGuard</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a, T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#600-606" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#601-605" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a, T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>, </span></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>, </span></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a, T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="struct tokio::io::unix::AsyncFdReadyGuard">AsyncFdReadyGuard</a><'a, T></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
42
doc/tokio/io/unix/struct.AsyncFdReadyMutGuard.html
Normal file
42
doc/tokio/io/unix/struct.AsyncFdReadyMutGuard.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!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="API documentation for the Rust `AsyncFdReadyMutGuard` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncFdReadyMutGuard"><title>tokio::io::unix::AsyncFdReadyMutGuard - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct AsyncFdReadyMutGuard</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.clear_ready">clear_ready</a><a href="#method.retain_ready">retain_ready</a><a href="#method.try_io">try_io</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "AsyncFdReadyMutGuard", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#157-160" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">AsyncFdReadyMutGuard</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct"><span class="docblock attributes top-attr">#[must_use =
|
||||
"You must explicitly choose whether to clear the readiness state by calling a method on ReadyGuard"]</span>pub struct AsyncFdReadyMutGuard<'a, T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> { /* fields omitted */ }</pre></div><div class="docblock"><p>Represents an IO-ready event detected on a particular file descriptor that
|
||||
has not yet been acknowledged. This is a <code>must_use</code> structure to help ensure
|
||||
that you do not forget to explicitly clear (or not clear) the event.</p>
|
||||
<p>This type exposes a mutable reference to the underlying IO object.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<'a, Inner: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, Inner></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#539-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clear_ready" class="method"><code>pub fn <a href="#method.clear_ready" class="fnname">clear_ready</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#550-554" title="goto source code">[src]</a></h4><div class="docblock"><p>Indicates to tokio that the file descriptor is no longer ready. The
|
||||
internal readiness flag will be cleared, and tokio will wait for the
|
||||
next edge-triggered readiness notification from the OS.</p>
|
||||
<p>It is critical that this function not be called unless your code
|
||||
<em>actually observes</em> that the file descriptor is <em>not</em> ready. Do not call
|
||||
it simply because, for example, a read succeeded; it should be called
|
||||
when a read is observed to block.</p>
|
||||
</div><h4 id="method.retain_ready" class="method"><code>pub fn <a href="#method.retain_ready" class="fnname">retain_ready</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#561-563" title="goto source code">[src]</a></h4><div class="docblock"><p>This method should be invoked when you intentionally want to keep the
|
||||
ready flag asserted.</p>
|
||||
<p>While this function is itself a no-op, it satisfies the <code>#[must_use]</code>
|
||||
constraint on the <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html" title="AsyncFdReadyGuard"><code>AsyncFdReadyGuard</code></a> type.</p>
|
||||
</div><h4 id="method.try_io" class="method"><code>pub fn <a href="#method.try_io" class="fnname">try_io</a><R>(<br> &mut self, <br> f: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&mut <a class="struct" href="../../../tokio/io/unix/struct.AsyncFd.html" title="struct tokio::io::unix::AsyncFd">AsyncFd</a><Inner>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><R><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><R>, <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a>></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#581-597" title="goto source code">[src]</a></h4><div class="docblock"><p>Performs the provided IO operation.</p>
|
||||
<p>If <code>f</code> returns a <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> error, the readiness state associated
|
||||
with this file descriptor is cleared, and the method returns
|
||||
<code>Err(TryIoError::WouldBlock)</code>. You will typically need to poll the
|
||||
<code>AsyncFd</code> again when this happens.</p>
|
||||
<p>This method helps ensure that the readiness state of the underlying file
|
||||
descriptor remains in sync with the tokio-side readiness state, by
|
||||
clearing the tokio-side state only when a <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> condition
|
||||
occurs. It is the responsibility of the caller to ensure that <code>f</code>
|
||||
returns <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> only if the file descriptor that originated this
|
||||
<code>AsyncFdReadyGuard</code> no longer expresses the readiness state that was queried to
|
||||
create this <code>AsyncFdReadyGuard</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a, T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#608-614" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#609-613" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a, T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>, </span></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a, T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.AsyncFdReadyMutGuard.html" title="struct tokio::io::unix::AsyncFdReadyMutGuard">AsyncFdReadyMutGuard</a><'a, T></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
16
doc/tokio/io/unix/struct.TryIoError.html
Normal file
16
doc/tokio/io/unix/struct.TryIoError.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!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="API documentation for the Rust `TryIoError` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, TryIoError"><title>tokio::io::unix::TryIoError - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct TryIoError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "TryIoError", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#623" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">TryIoError</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct TryIoError(_);</pre></div><div class="docblock"><p>The error type returned by <a href="../../../tokio/io/unix/struct.AsyncFdReadyGuard.html#method.try_io"><code>try_io</code></a>.</p>
|
||||
<p>This error indicates that the IO resource returned a <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>WouldBlock</code></a> error.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#622" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/io/async_fd.rs.html#622" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/io/unix/struct.TryIoError.html" title="struct tokio::io::unix::TryIoError">TryIoError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/macro.join!.html
Normal file
10
doc/tokio/macro.join!.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.join.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.join.html">macro.join.html</a>...</p>
|
||||
<script>location.replace("macro.join.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
58
doc/tokio/macro.join.html
Normal file
58
doc/tokio/macro.join.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!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="API documentation for the Rust `join` macro in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, join"><title>tokio::join - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc macro"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "join", ty: "macro", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/macros/join.rs.html#57-119" title="goto source code">[src]</a></span><span class="in-band">Macro <a href="index.html">tokio</a>::<wbr><a class="macro" href="">join</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><div class="example-wrap"><pre class="rust macro">
|
||||
<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">join</span> {
|
||||
(@ {
|
||||
<span class="comment">// One `_` for each branch in the `join!` macro. This is not used once</span>
|
||||
<span class="comment">// normalization is complete.</span>
|
||||
( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">count</span>:<span class="ident">tt</span>)<span class="op">*</span> )
|
||||
|
||||
<span class="comment">// Normalized join! branches</span>
|
||||
$( ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">skip</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>, )<span class="op">*</span>
|
||||
|
||||
}) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>),<span class="op">*</span> $(,)<span class="question-mark">?</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
}</pre></div>
|
||||
</div><div class="docblock"><p>Wait on multiple concurrent branches, returning when <strong>all</strong> branches
|
||||
complete.</p>
|
||||
<p>The <code>join!</code> macro must be used inside of async functions, closures, and
|
||||
blocks.</p>
|
||||
<p>The <code>join!</code> macro takes a list of async expressions and evaluates them
|
||||
concurrently on the same task. Each async expression evaluates to a future
|
||||
and the futures from each expression are multiplexed on the current task.</p>
|
||||
<p>When working with async expressions returning <code>Result</code>, <code>join!</code> will wait
|
||||
for <strong>all</strong> branches complete regardless if any complete with <code>Err</code>. Use
|
||||
<a href="../tokio/macro.try_join.html"><code>try_join!</code></a> to return early when <code>Err</code> is encountered.</p>
|
||||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
|
||||
<p>The supplied futures are stored inline and does not require allocating a
|
||||
<code>Vec</code>.</p>
|
||||
<h3 id="runtime-characteristics" class="section-header"><a href="#runtime-characteristics">Runtime characteristics</a></h3>
|
||||
<p>By running all async expressions on the current task, the expressions are
|
||||
able to run <strong>concurrently</strong> but not in <strong>parallel</strong>. This means all
|
||||
expressions are run on the same thread and if one branch blocks the thread,
|
||||
all other expressions will be unable to continue. If parallelism is
|
||||
required, spawn each async expression using <a href="../tokio/fn.spawn.html"><code>tokio::spawn</code></a> and pass the
|
||||
join handle to <code>join!</code>.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Basic join with two branches</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">do_stuff_async</span>() {
|
||||
<span class="comment">// async work</span>
|
||||
}
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">more_async_work</span>() {
|
||||
<span class="comment">// more here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> (<span class="ident">first</span>, <span class="ident">second</span>) <span class="op">=</span> <span class="ident">tokio</span>::<span class="macro">join</span><span class="macro">!</span>(
|
||||
<span class="ident">do_stuff_async</span>(),
|
||||
<span class="ident">more_async_work</span>());
|
||||
|
||||
<span class="comment">// do something with the values</span>
|
||||
}</pre></div>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/macro.pin!.html
Normal file
10
doc/tokio/macro.pin!.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.pin.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.pin.html">macro.pin.html</a>...</p>
|
||||
<script>location.replace("macro.pin.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
114
doc/tokio/macro.pin.html
Normal file
114
doc/tokio/macro.pin.html
Normal file
@@ -0,0 +1,114 @@
|
||||
<!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="API documentation for the Rust `pin` macro in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, pin"><title>tokio::pin - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc macro"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "pin", ty: "macro", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/macros/pin.rs.html#125-144" title="goto source code">[src]</a></span><span class="in-band">Macro <a href="index.html">tokio</a>::<wbr><a class="macro" href="">pin</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><div class="example-wrap"><pre class="rust macro">
|
||||
<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">pin</span> {
|
||||
($(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">x</span>:<span class="ident">ident</span>),<span class="kw-2">*</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
($(
|
||||
<span class="kw">let</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">x</span>:<span class="ident">ident</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">init</span>:<span class="ident">expr</span>;
|
||||
)<span class="kw-2">*</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
}</pre></div>
|
||||
</div><div class="docblock"><p>Pins a value on the stack.</p>
|
||||
<p>Calls to <code>async fn</code> return anonymous <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html"><code>Future</code></a> values that are <code>!Unpin</code>.
|
||||
These values must be pinned before they can be polled. Calling <code>.await</code> will
|
||||
handle this, but consumes the future. If it is required to call <code>.await</code> on
|
||||
a <code>&mut _</code> reference, the caller is responsible for pinning the future.</p>
|
||||
<p>Pinning may be done by allocating with <a href="#"><code>Box::pin</code></a> or by using the stack
|
||||
with the <code>pin!</code> macro.</p>
|
||||
<p>The following will <strong>fail to compile</strong>:</p>
|
||||
|
||||
<div class='information'><div class='tooltip compile_fail'>ⓘ<span class='tooltiptext'>This example deliberately fails to compile</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered compile_fail">
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||||
<span class="comment">// async logic here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">my_async_fn</span>();
|
||||
(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future</span>).<span class="ident">await</span>;
|
||||
}</pre></div>
|
||||
<p>To make this work requires pinning:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">pin</span>;
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||||
<span class="comment">// async logic here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">my_async_fn</span>();
|
||||
<span class="macro">pin</span><span class="macro">!</span>(<span class="ident">future</span>);
|
||||
|
||||
(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future</span>).<span class="ident">await</span>;
|
||||
}</pre></div>
|
||||
<p>Pinning is useful when using <code>select!</code> and stream operators that require <code>T: Stream + Unpin</code>.</p>
|
||||
<h1 id="usage" class="section-header"><a href="#usage">Usage</a></h1>
|
||||
<p>The <code>pin!</code> macro takes <strong>identifiers</strong> as arguments. It does <strong>not</strong> work
|
||||
with expressions.</p>
|
||||
<p>The following does not compile as an expression is passed to <code>pin!</code>.</p>
|
||||
|
||||
<div class='information'><div class='tooltip compile_fail'>ⓘ<span class='tooltiptext'>This example deliberately fails to compile</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered compile_fail">
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||||
<span class="comment">// async logic here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">future</span> <span class="op">=</span> <span class="macro">pin</span><span class="macro">!</span>(<span class="ident">my_async_fn</span>());
|
||||
(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future</span>).<span class="ident">await</span>;
|
||||
}</pre></div>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Using with select:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::{<span class="ident">pin</span>, <span class="ident">select</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio_stream</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">stream</span>, <span class="ident">StreamExt</span>};
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||||
<span class="comment">// async logic here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">my_async_fn</span>();
|
||||
<span class="macro">pin</span><span class="macro">!</span>(<span class="ident">future</span>);
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="comment">// Stop looping `future` will be polled after completion</span>
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Some</span>(<span class="ident">val</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"got value = {}"</span>, <span class="ident">val</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<p>Because assigning to a variable followed by pinning is common, there is also
|
||||
a variant of the macro that supports doing both in one go.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::{<span class="ident">pin</span>, <span class="ident">select</span>};
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||||
<span class="comment">// async logic here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="macro">pin</span><span class="macro">!</span> {
|
||||
<span class="kw">let</span> <span class="ident">future1</span> <span class="op">=</span> <span class="ident">my_async_fn</span>();
|
||||
<span class="kw">let</span> <span class="ident">future2</span> <span class="op">=</span> <span class="ident">my_async_fn</span>();
|
||||
}
|
||||
|
||||
<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future1</span> <span class="op">=</span><span class="op">></span> {}
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">future2</span> <span class="op">=</span><span class="op">></span> {}
|
||||
}
|
||||
}</pre></div>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/macro.select!.html
Normal file
10
doc/tokio/macro.select!.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.select.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.select.html">macro.select.html</a>...</p>
|
||||
<script>location.replace("macro.select.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
279
doc/tokio/macro.select.html
Normal file
279
doc/tokio/macro.select.html
Normal file
@@ -0,0 +1,279 @@
|
||||
<!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="API documentation for the Rust `select` macro in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, select"><title>tokio::select - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc macro"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "select", ty: "macro", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/macros/select.rs.html#288-487" title="goto source code">[src]</a></span><span class="in-band">Macro <a href="index.html">tokio</a>::<wbr><a class="macro" href="">select</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><div class="example-wrap"><pre class="rust macro">
|
||||
<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">select</span> {
|
||||
(@ {
|
||||
<span class="comment">// One `_` for each branch in the `select!` macro. Passing this to</span>
|
||||
<span class="comment">// `count!` converts $skip to an integer.</span>
|
||||
( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">count</span>:<span class="ident">tt</span>)<span class="op">*</span> )
|
||||
|
||||
<span class="comment">// Normalized select branches. `( $skip )` is a set of `_` characters.</span>
|
||||
<span class="comment">// There is one `_` for each select branch **before** this one. Given</span>
|
||||
<span class="comment">// that all input futures are stored in a tuple, $skip is useful for</span>
|
||||
<span class="comment">// generating a pattern to reference the future for the current branch.</span>
|
||||
<span class="comment">// $skip is also used as an argument to `count!`, returning the index of</span>
|
||||
<span class="comment">// the current select branch.</span>
|
||||
$( ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">skip</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="macro-nonterminal">$</span><span class="macro-nonterminal">bind</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">fut</span>:<span class="ident">expr</span>, <span class="kw">if</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">c</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">handle</span>:<span class="ident">expr</span>, )<span class="op">+</span>
|
||||
|
||||
<span class="comment">// Fallback expression used when all select branches have been disabled.</span>
|
||||
; <span class="macro-nonterminal">$</span><span class="kw">else</span>:<span class="macro-nonterminal">expr</span>
|
||||
|
||||
}) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="kw">else</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="kw">else</span>:<span class="macro-nonterminal">expr</span> $(,)<span class="question-mark">?</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span>, <span class="kw">if</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">c</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">block</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">block</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span>, <span class="kw">if</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">c</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">block</span> $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">block</span> $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span>, <span class="kw">if</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">c</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">expr</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">expr</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span>, <span class="kw">if</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">c</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">expr</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">f</span>:<span class="ident">expr</span> <span class="op">=</span><span class="op">></span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">h</span>:<span class="ident">expr</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
( <span class="macro-nonterminal">$</span><span class="macro-nonterminal">p</span>:<span class="ident">pat</span> <span class="op">=</span> $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
() <span class="op">=</span><span class="op">></span> { ... };
|
||||
}</pre></div>
|
||||
</div><div class="docblock"><p>Wait on multiple concurrent branches, returning when the <strong>first</strong> branch
|
||||
completes, cancelling the remaining branches.</p>
|
||||
<p>The <code>select!</code> macro must be used inside of async functions, closures, and
|
||||
blocks.</p>
|
||||
<p>The <code>select!</code> macro accepts one or more branches with the following pattern:</p>
|
||||
<pre><code class="language-text"><pattern> = <async expression> (, if <precondition>)? => <handler>,
|
||||
</code></pre>
|
||||
<p>Additionally, the <code>select!</code> macro may include a single, optional <code>else</code>
|
||||
branch, which evaluates if none of the other branches match their patterns:</p>
|
||||
<pre><code class="language-text">else <expression>
|
||||
</code></pre>
|
||||
<p>The macro aggregates all <code><async expression></code> expressions and runs them
|
||||
concurrently on the <strong>current</strong> task. Once the <strong>first</strong> expression
|
||||
completes with a value that matches its <code><pattern></code>, the <code>select!</code> macro
|
||||
returns the result of evaluating the completed branch's <code><handler></code>
|
||||
expression.</p>
|
||||
<p>Additionally, each branch may include an optional <code>if</code> precondition. This
|
||||
precondition is evaluated <strong>before</strong> the <code><async expression></code>. If the
|
||||
precondition returns <code>false</code>, the branch is entirely disabled. This
|
||||
capability is useful when using <code>select!</code> within a loop.</p>
|
||||
<p>The complete lifecycle of a <code>select!</code> expression is as follows:</p>
|
||||
<ol>
|
||||
<li>Evaluate all provided <code><precondition></code> expressions. If the precondition
|
||||
returns <code>false</code>, disable the branch for the remainder of the current call
|
||||
to <code>select!</code>. Re-entering <code>select!</code> due to a loop clears the "disabled"
|
||||
state.</li>
|
||||
<li>Aggregate the <code><async expression></code>s from each branch, including the
|
||||
disabled ones. If the branch is disabled, <code><async expression></code> is still
|
||||
evaluated, but the resulting future is not polled.</li>
|
||||
<li>Concurrently await on the results for all remaining <code><async expression></code>s.</li>
|
||||
<li>Once an <code><async expression></code> returns a value, attempt to apply the value
|
||||
to the provided <code><pattern></code>, if the pattern matches, evaluate <code><handler></code>
|
||||
and return. If the pattern <strong>does not</strong> match, disable the current branch
|
||||
and for the remainder of the current call to <code>select!</code>. Continue from step 3.</li>
|
||||
<li>If <strong>all</strong> branches are disabled, evaluate the <code>else</code> expression. If none
|
||||
is provided, panic.</li>
|
||||
</ol>
|
||||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1><h3 id="runtime-characteristics" class="section-header"><a href="#runtime-characteristics">Runtime characteristics</a></h3>
|
||||
<p>By running all async expressions on the current task, the expressions are
|
||||
able to run <strong>concurrently</strong> but not in <strong>parallel</strong>. This means all
|
||||
expressions are run on the same thread and if one branch blocks the thread,
|
||||
all other expressions will be unable to continue. If parallelism is
|
||||
required, spawn each async expression using <a href="../tokio/fn.spawn.html"><code>tokio::spawn</code></a> and pass the
|
||||
join handle to <code>select!</code>.</p>
|
||||
<h3 id="avoid-racy-if-preconditions" class="section-header"><a href="#avoid-racy-if-preconditions">Avoid racy <code>if</code> preconditions</a></h3>
|
||||
<p>Given that <code>if</code> preconditions are used to disable <code>select!</code> branches, some
|
||||
caution must be used to avoid missing values.</p>
|
||||
<p>For example, here is <strong>incorrect</strong> usage of <code>sleep</code> with <code>if</code>. The objective
|
||||
is to repeatedly run an asynchronous task for up to 50 milliseconds.
|
||||
However, there is a potential for the <code>sleep</code> completion to be missed.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>};
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">some_async_work</span>() {
|
||||
<span class="comment">// do work</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">sleep</span> <span class="op">=</span> <span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">50</span>));
|
||||
<span class="ident">tokio</span>::<span class="macro">pin</span><span class="macro">!</span>(<span class="ident">sleep</span>);
|
||||
|
||||
<span class="kw">while</span> <span class="op">!</span><span class="ident">sleep</span>.<span class="ident">is_elapsed</span>() {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">sleep</span>, <span class="kw">if</span> <span class="op">!</span><span class="ident">sleep</span>.<span class="ident">is_elapsed</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"operation timed out"</span>);
|
||||
}
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="ident">some_async_work</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"operation completed"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<p>In the above example, <code>sleep.is_elapsed()</code> may return <code>true</code> even if
|
||||
<code>sleep.poll()</code> never returned <code>Ready</code>. This opens up a potential race
|
||||
condition where <code>sleep</code> expires between the <code>while !sleep.is_elapsed()</code>
|
||||
check and the call to <code>select!</code> resulting in the <code>some_async_work()</code> call to
|
||||
run uninterrupted despite the sleep having elapsed.</p>
|
||||
<p>One way to write the above example without the race would be:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>};
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">some_async_work</span>() {
|
||||
<span class="comment">// do work</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">sleep</span> <span class="op">=</span> <span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">50</span>));
|
||||
<span class="ident">tokio</span>::<span class="macro">pin</span><span class="macro">!</span>(<span class="ident">sleep</span>);
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">sleep</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"operation timed out"</span>);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="ident">some_async_work</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"operation completed"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<h3 id="fairness" class="section-header"><a href="#fairness">Fairness</a></h3>
|
||||
<p><code>select!</code> randomly picks a branch to check first. This provides some level
|
||||
of fairness when calling <code>select!</code> in a loop with branches that are always
|
||||
ready.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p><code>select!</code> panics if all branches are disabled <strong>and</strong> there is no provided
|
||||
<code>else</code> branch. A branch is disabled when the provided <code>if</code> precondition
|
||||
returns <code>false</code> <strong>or</strong> when the pattern does not match the result of `<async
|
||||
expression>.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Basic select with two branches.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">do_stuff_async</span>() {
|
||||
<span class="comment">// async work</span>
|
||||
}
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">more_async_work</span>() {
|
||||
<span class="comment">// more here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="ident">do_stuff_async</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"do_stuff_async() completed first"</span>)
|
||||
}
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="ident">more_async_work</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"more_async_work() completed first"</span>)
|
||||
}
|
||||
};
|
||||
}</pre></div>
|
||||
<p>Basic stream selecting.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio_stream</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">stream</span>, <span class="ident">StreamExt</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream1</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream2</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">next</span> <span class="op">=</span> <span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="ident">v</span> <span class="op">=</span> <span class="ident">stream1</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> <span class="ident">v</span>.<span class="ident">unwrap</span>(),
|
||||
<span class="ident">v</span> <span class="op">=</span> <span class="ident">stream2</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> <span class="ident">v</span>.<span class="ident">unwrap</span>(),
|
||||
};
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">next</span> <span class="op">=</span><span class="op">=</span> <span class="number">1</span> <span class="op">|</span><span class="op">|</span> <span class="ident">next</span> <span class="op">=</span><span class="op">=</span> <span class="number">4</span>);
|
||||
}</pre></div>
|
||||
<p>Collect the contents of two streams. In this example, we rely on pattern
|
||||
matching and the fact that <code>stream::iter</code> is "fused", i.e. once the stream
|
||||
is complete, all calls to <code>next()</code> return <code>None</code>.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio_stream</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">stream</span>, <span class="ident">StreamExt</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream1</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream2</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">values</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="prelude-val">Some</span>(<span class="ident">v</span>) <span class="op">=</span> <span class="ident">stream1</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> <span class="ident">values</span>.<span class="ident">push</span>(<span class="ident">v</span>),
|
||||
<span class="prelude-val">Some</span>(<span class="ident">v</span>) <span class="op">=</span> <span class="ident">stream2</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> <span class="ident">values</span>.<span class="ident">push</span>(<span class="ident">v</span>),
|
||||
<span class="kw">else</span> <span class="op">=</span><span class="op">></span> <span class="kw">break</span>,
|
||||
}
|
||||
}
|
||||
|
||||
<span class="ident">values</span>.<span class="ident">sort</span>();
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], <span class="kw-2">&</span><span class="ident">values</span>[..]);
|
||||
}</pre></div>
|
||||
<p>Using the same future in multiple <code>select!</code> expressions can be done by passing
|
||||
a reference to the future. Doing so requires the future to be <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html"><code>Unpin</code></a>. A
|
||||
future can be made <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html"><code>Unpin</code></a> by either using <a href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html#method.pin"><code>Box::pin</code></a> or stack pinning.</p>
|
||||
<p>Here, a stream is consumed for at most 1 second.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio_stream</span>::{<span class="self">self</span> <span class="kw">as</span> <span class="ident">stream</span>, <span class="ident">StreamExt</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">time</span>::{<span class="self">self</span>, <span class="ident">Duration</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
|
||||
<span class="kw">let</span> <span class="ident">sleep</span> <span class="op">=</span> <span class="ident">time</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_secs</span>(<span class="number">1</span>));
|
||||
<span class="ident">tokio</span>::<span class="macro">pin</span><span class="macro">!</span>(<span class="ident">sleep</span>);
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="ident">maybe_v</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">next</span>() <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">v</span>) <span class="op">=</span> <span class="ident">maybe_v</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"got = {}"</span>, <span class="ident">v</span>);
|
||||
} <span class="kw">else</span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
}
|
||||
<span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">sleep</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"timeout"</span>);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<p>Joining two values using <code>select!</code>.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">sync</span>::<span class="ident">oneshot</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> (<span class="ident">tx1</span>, <span class="kw-2">mut</span> <span class="ident">rx1</span>) <span class="op">=</span> <span class="ident">oneshot</span>::<span class="ident">channel</span>();
|
||||
<span class="kw">let</span> (<span class="ident">tx2</span>, <span class="kw-2">mut</span> <span class="ident">rx2</span>) <span class="op">=</span> <span class="ident">oneshot</span>::<span class="ident">channel</span>();
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="ident">tx1</span>.<span class="ident">send</span>(<span class="string">"first"</span>).<span class="ident">unwrap</span>();
|
||||
});
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="ident">tx2</span>.<span class="ident">send</span>(<span class="string">"second"</span>).<span class="ident">unwrap</span>();
|
||||
});
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">a</span> <span class="op">=</span> <span class="prelude-val">None</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> <span class="prelude-val">None</span>;
|
||||
|
||||
<span class="kw">while</span> <span class="ident">a</span>.<span class="ident">is_none</span>() <span class="op">|</span><span class="op">|</span> <span class="ident">b</span>.<span class="ident">is_none</span>() {
|
||||
<span class="ident">tokio</span>::<span class="macro">select</span><span class="macro">!</span> {
|
||||
<span class="ident">v1</span> <span class="op">=</span> (<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">rx1</span>), <span class="kw">if</span> <span class="ident">a</span>.<span class="ident">is_none</span>() <span class="op">=</span><span class="op">></span> <span class="ident">a</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">v1</span>.<span class="ident">unwrap</span>()),
|
||||
<span class="ident">v2</span> <span class="op">=</span> (<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">rx2</span>), <span class="kw">if</span> <span class="ident">b</span>.<span class="ident">is_none</span>() <span class="op">=</span><span class="op">></span> <span class="ident">b</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="ident">v2</span>.<span class="ident">unwrap</span>()),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> (<span class="ident">a</span>.<span class="ident">unwrap</span>(), <span class="ident">b</span>.<span class="ident">unwrap</span>());
|
||||
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">res</span>.<span class="number">0</span>, <span class="string">"first"</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">res</span>.<span class="number">1</span>, <span class="string">"second"</span>);
|
||||
}</pre></div>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/macro.task_local!.html
Normal file
10
doc/tokio/macro.task_local!.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.task_local.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.task_local.html">macro.task_local.html</a>...</p>
|
||||
<script>location.replace("macro.task_local.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
24
doc/tokio/macro.task_local.html
Normal file
24
doc/tokio/macro.task_local.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!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="API documentation for the Rust `task_local` macro in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, task_local"><title>tokio::task_local - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc macro"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "task_local", ty: "macro", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/task/task_local.rs.html#35-47" title="goto source code">[src]</a></span><span class="in-band">Macro <a href="index.html">tokio</a>::<wbr><a class="macro" href="">task_local</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><div class="example-wrap"><pre class="rust macro">
|
||||
<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">task_local</span> {
|
||||
() <span class="op">=</span><span class="op">></span> { ... };
|
||||
($(<span class="attribute">#[<span class="macro-nonterminal">$</span><span class="macro-nonterminal">attr</span>:<span class="ident">meta</span>]</span>)<span class="op">*</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">vis</span>:<span class="ident">vis</span> <span class="kw">static</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">name</span>:<span class="ident">ident</span>: <span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">ty</span>; $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">rest</span>:<span class="ident">tt</span>)<span class="kw-2">*</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
($(<span class="attribute">#[<span class="macro-nonterminal">$</span><span class="macro-nonterminal">attr</span>:<span class="ident">meta</span>]</span>)<span class="op">*</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">vis</span>:<span class="ident">vis</span> <span class="kw">static</span> <span class="macro-nonterminal">$</span><span class="macro-nonterminal">name</span>:<span class="ident">ident</span>: <span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">ty</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
}</pre></div>
|
||||
</div><div class="docblock"><p>Declares a new task-local key of type <a href="../tokio/task/struct.LocalKey.html"><code>tokio::task::LocalKey</code></a>.</p>
|
||||
<h1 id="syntax" class="section-header"><a href="#syntax">Syntax</a></h1>
|
||||
<p>The macro wraps any number of static declarations and makes them local to the current task.
|
||||
Publicity and attributes for each static is preserved. For example:</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="macro">task_local</span><span class="macro">!</span> {
|
||||
<span class="kw">pub</span> <span class="kw">static</span> <span class="ident">ONE</span>: <span class="ident">u32</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">allow</span>(<span class="ident">unused</span>)]</span>
|
||||
<span class="kw">static</span> <span class="ident">TWO</span>: <span class="ident">f32</span>;
|
||||
}</pre></div>
|
||||
<p>See <a href="../tokio/task/struct.LocalKey.html">LocalKey documentation</a> for more
|
||||
information.</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/macro.try_join!.html
Normal file
10
doc/tokio/macro.try_join!.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.try_join.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.try_join.html">macro.try_join.html</a>...</p>
|
||||
<script>location.replace("macro.try_join.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
64
doc/tokio/macro.try_join.html
Normal file
64
doc/tokio/macro.try_join.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<!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="API documentation for the Rust `try_join` macro in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, try_join"><title>tokio::try_join - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc macro"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../tokio/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="index.html">tokio</a></p><script>window.sidebarCurrent = {name: "try_join", ty: "macro", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tokio/macros/try_join.rs.html#64-132" title="goto source code">[src]</a></span><span class="in-band">Macro <a href="index.html">tokio</a>::<wbr><a class="macro" href="">try_join</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><div class="example-wrap"><pre class="rust macro">
|
||||
<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">try_join</span> {
|
||||
(@ {
|
||||
<span class="comment">// One `_` for each branch in the `try_join!` macro. This is not used once</span>
|
||||
<span class="comment">// normalization is complete.</span>
|
||||
( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">count</span>:<span class="ident">tt</span>)<span class="op">*</span> )
|
||||
|
||||
<span class="comment">// Normalized try_join! branches</span>
|
||||
$( ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">skip</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>, )<span class="op">*</span>
|
||||
|
||||
}) <span class="op">=</span><span class="op">></span> { ... };
|
||||
(@ { ( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">s</span>:<span class="ident">tt</span>)<span class="op">*</span> ) $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">t</span>:<span class="ident">tt</span>)<span class="op">*</span> } <span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>, $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">r</span>:<span class="ident">tt</span>)<span class="op">*</span> ) <span class="op">=</span><span class="op">></span> { ... };
|
||||
( $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">e</span>:<span class="ident">expr</span>),<span class="op">*</span> $(,)<span class="question-mark">?</span>) <span class="op">=</span><span class="op">></span> { ... };
|
||||
}</pre></div>
|
||||
</div><div class="docblock"><p>Wait on multiple concurrent branches, returning when <strong>all</strong> branches
|
||||
complete with <code>Ok(_)</code> or on the first <code>Err(_)</code>.</p>
|
||||
<p>The <code>try_join!</code> macro must be used inside of async functions, closures, and
|
||||
blocks.</p>
|
||||
<p>Similar to <a href="../tokio/macro.join.html"><code>join!</code></a>, the <code>try_join!</code> macro takes a list of async
|
||||
expressions and evaluates them concurrently on the same task. Each async
|
||||
expression evaluates to a future and the futures from each expression are
|
||||
multiplexed on the current task. The <code>try_join!</code> macro returns when <strong>all</strong>
|
||||
branches return with <code>Ok</code> or when the <strong>first</strong> branch returns with <code>Err</code>.</p>
|
||||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
|
||||
<p>The supplied futures are stored inline and does not require allocating a
|
||||
<code>Vec</code>.</p>
|
||||
<h3 id="runtime-characteristics" class="section-header"><a href="#runtime-characteristics">Runtime characteristics</a></h3>
|
||||
<p>By running all async expressions on the current task, the expressions are
|
||||
able to run <strong>concurrently</strong> but not in <strong>parallel</strong>. This means all
|
||||
expressions are run on the same thread and if one branch blocks the thread,
|
||||
all other expressions will be unable to continue. If parallelism is
|
||||
required, spawn each async expression using <a href="../tokio/fn.spawn.html"><code>tokio::spawn</code></a> and pass the
|
||||
join handle to <code>try_join!</code>.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Basic try_join with two branches.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">do_stuff_async</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="kw-2">&</span><span class="lifetime">'static</span> <span class="ident">str</span><span class="op">></span> {
|
||||
<span class="comment">// async work</span>
|
||||
}
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">more_async_work</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="kw-2">&</span><span class="lifetime">'static</span> <span class="ident">str</span><span class="op">></span> {
|
||||
<span class="comment">// more here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">tokio</span>::<span class="macro">try_join</span><span class="macro">!</span>(
|
||||
<span class="ident">do_stuff_async</span>(),
|
||||
<span class="ident">more_async_work</span>());
|
||||
|
||||
<span class="kw">match</span> <span class="ident">res</span> {
|
||||
<span class="prelude-val">Ok</span>((<span class="ident">first</span>, <span class="ident">second</span>)) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="comment">// do something with the values</span>
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"processing failed; error = {}"</span>, <span class="ident">err</span>);
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "tokio";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
10
doc/tokio/net/addr/trait.ToSocketAddrs.html
Normal file
10
doc/tokio/net/addr/trait.ToSocketAddrs.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/net/trait.ToSocketAddrs.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/net/trait.ToSocketAddrs.html">../../../tokio/net/trait.ToSocketAddrs.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/net/trait.ToSocketAddrs.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
24
doc/tokio/net/fn.lookup_host.html
Normal file
24
doc/tokio/net/fn.lookup_host.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!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="API documentation for the Rust `lookup_host` fn in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, lookup_host"><title>tokio::net::lookup_host - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "lookup_host", ty: "fn", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/lookup_host.rs.html#32-37" title="goto source code">[src]</a></span><span class="in-band">Function <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="fn" href="">lookup_host</a></span></h1><pre class="rust fn">pub async fn lookup_host<T>(host: T) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>, </span></pre><div class="docblock"><p>Performs a DNS resolution.</p>
|
||||
<p>The returned iterator may not actually yield any values depending on the
|
||||
outcome of any resolution performed.</p>
|
||||
<p>This API is not intended to cover all DNS use cases. Anything beyond the
|
||||
basic use case should be done with a specialized library.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>To resolve a DNS entry:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">for</span> <span class="ident">addr</span> <span class="kw">in</span> <span class="ident">net</span>::<span class="ident">lookup_host</span>(<span class="string">"localhost:3000"</span>).<span class="ident">await</span><span class="question-mark">?</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"socket address is {}"</span>, <span class="ident">addr</span>);
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
32
doc/tokio/net/index.html
Normal file
32
doc/tokio/net/index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!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="API documentation for the Rust `net` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, net"><title>tokio::net - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module net</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class="location"><a href="../index.html">tokio</a></p><script>window.sidebarCurrent = {name: "net", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/mod.rs.html#1-48" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../index.html">tokio</a>::<wbr><a class="mod" href="">net</a></span></h1><div class="docblock"><p>TCP/UDP/Unix bindings for <code>tokio</code>.</p>
|
||||
<p>This module contains the TCP/UDP/Unix networking types, similar to the standard
|
||||
library, which can be used to implement networking protocols.</p>
|
||||
<h1 id="organization" class="section-header"><a href="#organization">Organization</a></h1>
|
||||
<ul>
|
||||
<li><a href="../../tokio/net/struct.TcpListener.html"><code>TcpListener</code></a> and <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a> provide functionality for communication over TCP</li>
|
||||
<li><a href="../../tokio/net/struct.UdpSocket.html"><code>UdpSocket</code></a> provides functionality for communication over UDP</li>
|
||||
<li><a href="../../tokio/net/struct.UnixListener.html"><code>UnixListener</code></a> and <a href="../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a> provide functionality for communication over a
|
||||
Unix Domain Stream Socket <strong>(available on Unix only)</strong></li>
|
||||
<li><a href="../../tokio/net/struct.UnixDatagram.html"><code>UnixDatagram</code></a> provides functionality for communication
|
||||
over Unix Domain Datagram Socket <strong>(available on Unix only)</strong></li>
|
||||
</ul>
|
||||
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="tcp/index.html" title="tokio::net::tcp mod">tcp</a></td><td class="docblock-short"><p>TCP utility types</p>
|
||||
</td></tr><tr class="module-item"><td><a class="mod" href="unix/index.html" title="tokio::net::unix mod">unix</a></td><td class="docblock-short"><p>Unix domain socket utility types</p>
|
||||
</td></tr></table><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.TcpListener.html" title="tokio::net::TcpListener struct">TcpListener</a></td><td class="docblock-short"><p>A TCP socket server, listening for connections.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.TcpSocket.html" title="tokio::net::TcpSocket struct">TcpSocket</a></td><td class="docblock-short"><p>A TCP socket that has not yet been converted to a <code>TcpStream</code> or
|
||||
<code>TcpListener</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.TcpStream.html" title="tokio::net::TcpStream struct">TcpStream</a></td><td class="docblock-short"><p>A TCP stream between a local and a remote socket.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.UdpSocket.html" title="tokio::net::UdpSocket struct">UdpSocket</a></td><td class="docblock-short"><p>A UDP socket</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.UnixDatagram.html" title="tokio::net::UnixDatagram struct">UnixDatagram</a></td><td class="docblock-short"><p>An I/O object representing a Unix datagram socket.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.UnixListener.html" title="tokio::net::UnixListener struct">UnixListener</a></td><td class="docblock-short"><p>A Unix socket which can accept connections from other Unix sockets.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.UnixStream.html" title="tokio::net::UnixStream struct">UnixStream</a></td><td class="docblock-short"><p>A structure representing a connected Unix socket.</p>
|
||||
</td></tr></table><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2>
|
||||
<table><tr class="module-item"><td><a class="trait" href="trait.ToSocketAddrs.html" title="tokio::net::ToSocketAddrs trait">ToSocketAddrs</a></td><td class="docblock-short"><p>Converts or resolves without blocking to one or more <code>SocketAddr</code> values.</p>
|
||||
</td></tr></table><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
|
||||
<table><tr class="module-item"><td><a class="fn" href="fn.lookup_host.html" title="tokio::net::lookup_host fn">lookup_host</a></td><td class="docblock-short"><p>Performs a DNS resolution.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/net/lookup_host/fn.lookup_host.html
Normal file
10
doc/tokio/net/lookup_host/fn.lookup_host.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/net/fn.lookup_host.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/net/fn.lookup_host.html">../../../tokio/net/fn.lookup_host.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/net/fn.lookup_host.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
doc/tokio/net/sidebar-items.js
Normal file
1
doc/tokio/net/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"fn":[["lookup_host","Performs a DNS resolution."]],"mod":[["tcp","TCP utility types"],["unix","Unix domain socket utility types"]],"struct":[["TcpListener","A TCP socket server, listening for connections."],["TcpSocket","A TCP socket that has not yet been converted to a `TcpStream` or `TcpListener`."],["TcpStream","A TCP stream between a local and a remote socket."],["UdpSocket","A UDP socket"],["UnixDatagram","An I/O object representing a Unix datagram socket."],["UnixListener","A Unix socket which can accept connections from other Unix sockets."],["UnixStream","A structure representing a connected Unix socket."]],"trait":[["ToSocketAddrs","Converts or resolves without blocking to one or more `SocketAddr` values."]]});
|
||||
181
doc/tokio/net/struct.TcpListener.html
Normal file
181
doc/tokio/net/struct.TcpListener.html
Normal file
@@ -0,0 +1,181 @@
|
||||
<!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="API documentation for the Rust `TcpListener` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, TcpListener"><title>tokio::net::TcpListener - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct TcpListener</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.accept">accept</a><a href="#method.bind">bind</a><a href="#method.from_std">from_std</a><a href="#method.local_addr">local_addr</a><a href="#method.poll_accept">poll_accept</a><a href="#method.set_ttl">set_ttl</a><a href="#method.ttl">ttl</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CTcpListener%3E">TryFrom<TcpListener></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "TcpListener", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#48-50" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">TcpListener</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct TcpListener { /* fields omitted */ }</pre></div><div class="docblock"><p>A TCP socket server, listening for connections.</p>
|
||||
<p>You can accept a new connection by using the <a href="../../tokio/net/struct.TcpListener.html#method.accept"><code>accept</code></a>
|
||||
method.</p>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>Note that accepting a connection can lead to various errors and not all
|
||||
of them are necessarily fatal ‒ for example having too many open file
|
||||
descriptors or the other side closing the connection while it waits in
|
||||
an accept queue. These would terminate the stream if not handled in any
|
||||
way.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Using <code>accept</code>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">process_socket</span><span class="op"><</span><span class="ident">T</span><span class="op">></span>(<span class="ident">socket</span>: <span class="ident">T</span>) {
|
||||
<span class="comment">// do work with socket here</span>
|
||||
}
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="ident">socket</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">process_socket</span>(<span class="ident">socket</span>).<span class="ident">await</span>;
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#53-302" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bind" class="method"><code>pub async fn <a href="#method.bind" class="fnname">bind</a><A: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>>(addr: A) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#92-110" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new TcpListener, which will be bound to the specified address.</p>
|
||||
<p>The returned listener is ready for accepting connections.</p>
|
||||
<p>Binding with a port number of 0 will request that the OS assigns a port
|
||||
to this listener. The port allocated can be queried via the <code>local_addr</code>
|
||||
method.</p>
|
||||
<p>The address type can be any implementor of the <a href="../../tokio/net/trait.ToSocketAddrs.html"><code>ToSocketAddrs</code></a> trait.
|
||||
Note that strings only implement this trait when the <strong><code>net</code></strong> feature
|
||||
is enabled, as strings may contain domain names that need to be resolved.</p>
|
||||
<p>If <code>addr</code> yields multiple addresses, bind will be attempted with each of
|
||||
the addresses until one succeeds and returns the listener. If none of
|
||||
the addresses succeed in creating a listener, the error returned from
|
||||
the last attempt (the last address) is returned.</p>
|
||||
<p>This function sets the <code>SO_REUSEADDR</code> option on the socket.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:2345"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// use the listener</span>
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.accept" class="method"><code>pub async fn <a href="#method.accept" class="fnname">accept</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#144-153" title="goto source code">[src]</a></h4><div class="docblock"><p>Accepts a new incoming connection from this listener.</p>
|
||||
<p>This function will yield once a new TCP connection is established. When
|
||||
established, the corresponding <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a> and the remote peer's
|
||||
address will be returned.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span> {
|
||||
<span class="prelude-val">Ok</span>((<span class="ident">_socket</span>, <span class="ident">addr</span>)) <span class="op">=</span><span class="op">></span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"new client: {:?}"</span>, <span class="ident">addr</span>),
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"couldn't get client: {:?}"</span>, <span class="ident">e</span>),
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_accept" class="method"><code>pub fn <a href="#method.poll_accept" class="fnname">poll_accept</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#161-176" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls to accept a new incoming connection to this listener.</p>
|
||||
<p>If there is no connection to accept, <code>Poll::Pending</code> is returned and the
|
||||
current task will be notified by a waker. Note that on multiple calls
|
||||
to <code>poll_accept</code>, only the <code>Waker</code> from the <code>Context</code> passed to the most
|
||||
recent call is scheduled to receive a wakeup.</p>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(listener: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#213-217" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>TcpListener</code> from a <code>std::net::TcpListener</code>.</p>
|
||||
<p>This function is intended to be used to wrap a TCP listener from the
|
||||
standard library in the Tokio equivalent. The conversion assumes nothing
|
||||
about the underlying listener; it is left up to the user to set it in
|
||||
non-blocking mode.</p>
|
||||
<p>This API is typically paired with the <code>socket2</code> crate and the <code>Socket</code>
|
||||
type to build up and customize a listener before it's shipped off to the
|
||||
backing event loop. This allows configuration of options like
|
||||
<code>SO_REUSEPORT</code>, binding to multiple addresses, etc.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">std_listener</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:0"</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">std_listener</span>.<span class="ident">set_nonblocking</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">from_std</span>(<span class="ident">std_listener</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#247-249" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the local address that this listener is bound to.</p>
|
||||
<p>This can be useful, for example, when binding to port 0 to figure out
|
||||
which port was actually bound.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">net</span>::{<span class="ident">Ipv4Addr</span>, <span class="ident">SocketAddr</span>, <span class="ident">SocketAddrV4</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">listener</span>.<span class="ident">local_addr</span>()<span class="question-mark">?</span>,
|
||||
<span class="ident">SocketAddr</span>::<span class="ident">V4</span>(<span class="ident">SocketAddrV4</span>::<span class="ident">new</span>(<span class="ident">Ipv4Addr</span>::<span class="ident">new</span>(<span class="number">127</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>), <span class="number">8080</span>)));
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.ttl" class="method"><code>pub fn <a href="#method.ttl" class="fnname">ttl</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#274-276" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IP_TTL</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.TcpListener.html#method.set_ttl"><code>set_ttl</code></a>.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:0"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">listener</span>.<span class="ident">set_ttl</span>(<span class="number">100</span>).<span class="ident">expect</span>(<span class="string">"could not set TTL"</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">listener</span>.<span class="ident">ttl</span>()<span class="question-mark">?</span>, <span class="number">100</span>);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.set_ttl" class="method"><code>pub fn <a href="#method.set_ttl" class="fnname">set_ttl</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#299-301" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value for the <code>IP_TTL</code> option on this socket.</p>
|
||||
<p>This value sets the time-to-live field that is used in every packet sent
|
||||
from this socket.</p>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:0"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">listener</span>.<span class="ident">set_ttl</span>(<span class="number">100</span>).<span class="ident">expect</span>(<span class="string">"could not set TTL"</span>);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#327-331" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#328-330" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#316-320" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#317-319" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CTcpListener%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-TryFrom%3CTcpListener%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#304-314" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="../../src/tokio/net/tcp/listener.rs.html#311-313" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.TcpListener.html#method.from_std"><code>TcpListener::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
341
doc/tokio/net/struct.TcpSocket.html
Normal file
341
doc/tokio/net/struct.TcpSocket.html
Normal file
@@ -0,0 +1,341 @@
|
||||
<!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="API documentation for the Rust `TcpSocket` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, TcpSocket"><title>tokio::net::TcpSocket - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct TcpSocket</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.bind">bind</a><a href="#method.connect">connect</a><a href="#method.listen">listen</a><a href="#method.local_addr">local_addr</a><a href="#method.new_v4">new_v4</a><a href="#method.new_v6">new_v6</a><a href="#method.recv_buffer_size">recv_buffer_size</a><a href="#method.reuseaddr">reuseaddr</a><a href="#method.reuseport">reuseport</a><a href="#method.send_buffer_size">send_buffer_size</a><a href="#method.set_recv_buffer_size">set_recv_buffer_size</a><a href="#method.set_reuseaddr">set_reuseaddr</a><a href="#method.set_reuseport">set_reuseport</a><a href="#method.set_send_buffer_size">set_send_buffer_size</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-FromRawFd">FromRawFd</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "TcpSocket", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#84-86" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">TcpSocket</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct TcpSocket { /* fields omitted */ }</pre></div><div class="docblock"><p>A TCP socket that has not yet been converted to a <code>TcpStream</code> or
|
||||
<code>TcpListener</code>.</p>
|
||||
<p><code>TcpSocket</code> wraps an operating system socket and enables the caller to
|
||||
configure the socket before establishing a TCP connection or accepting
|
||||
inbound connections. The caller is able to set socket option and explicitly
|
||||
bind the socket with a socket address.</p>
|
||||
<p>The underlying socket is closed when the <code>TcpSocket</code> value is dropped.</p>
|
||||
<p><code>TcpSocket</code> should only be used directly if the default configuration used
|
||||
by <code>TcpStream::connect</code> and <code>TcpListener::bind</code> does not meet the required
|
||||
use case.</p>
|
||||
<p>Calling <code>TcpStream::connect("127.0.0.1:8080")</code> is equivalent to:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">connect</span>(<span class="ident">addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>Calling <code>TcpListener::bind("127.0.0.1:8080")</code> is equivalent to:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="comment">// On platforms with Berkeley-derived sockets, this allows to quickly</span>
|
||||
<span class="comment">// rebind a socket, without needing to wait for the OS to clean up the</span>
|
||||
<span class="comment">// previous one.</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// On Windows, this allows rebinding sockets which are actively in use,</span>
|
||||
<span class="comment">// which allows “socket hijacking”, so we explicitly don't set it here.</span>
|
||||
<span class="comment">// https://docs.microsoft.com/en-us/windows/win32/winsock/using-so-reuseaddr-and-so-exclusiveaddruse</span>
|
||||
<span class="ident">socket</span>.<span class="ident">set_reuseaddr</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>Setting socket options not explicitly provided by <code>TcpSocket</code> may be done by
|
||||
accessing the <code>RawFd</code>/<code>RawSocket</code> using <a href="https://doc.rust-lang.org/std/os/unix/io/trait.AsRawFd.html"><code>AsRawFd</code></a>/<a href="https://doc.rust-lang.org/std/os/windows/io/trait.AsRawSocket.html"><code>AsRawSocket</code></a> and
|
||||
setting the option with a crate like <a href="https://docs.rs/socket2/"><code>socket2</code></a>.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#89-485" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new_v4" class="method"><code>pub fn <a href="#method.new_v4" class="fnname">new_v4</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#119-122" title="goto source code">[src]</a></h4><div class="docblock"><p>Create a new socket configured for IPv4.</p>
|
||||
<p>Calls <code>socket(2)</code> with <code>AF_INET</code> and <code>SOCK_STREAM</code>.</p>
|
||||
<h1 id="returns" class="section-header"><a href="#returns">Returns</a></h1>
|
||||
<p>On success, the newly created <code>TcpSocket</code> is returned. If an error is
|
||||
encountered, it is returned instead.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Create a new IPv4 socket and start listening.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">128</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.new_v6" class="method"><code>pub fn <a href="#method.new_v6" class="fnname">new_v6</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#153-156" title="goto source code">[src]</a></h4><div class="docblock"><p>Create a new socket configured for IPv6.</p>
|
||||
<p>Calls <code>socket(2)</code> with <code>AF_INET6</code> and <code>SOCK_STREAM</code>.</p>
|
||||
<h1 id="returns-1" class="section-header"><a href="#returns-1">Returns</a></h1>
|
||||
<p>On success, the newly created <code>TcpSocket</code> is returned. If an error is
|
||||
encountered, it is returned instead.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<p>Create a new IPv6 socket and start listening.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"[::1]:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v6</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">128</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.set_reuseaddr" class="method"><code>pub fn <a href="#method.set_reuseaddr" class="fnname">set_reuseaddr</a>(&self, reuseaddr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#184-186" title="goto source code">[src]</a></h4><div class="docblock"><p>Allow the socket to bind to an in-use address.</p>
|
||||
<p>Behavior is platform specific. Refer to the target platform's
|
||||
documentation for more details.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">set_reuseaddr</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.reuseaddr" class="method"><code>pub fn <a href="#method.reuseaddr" class="fnname">reuseaddr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#210-212" title="goto source code">[src]</a></h4><div class="docblock"><p>Retrieves the value set for <code>SO_REUSEADDR</code> on this socket</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">set_reuseaddr</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">socket</span>.<span class="ident">reuseaddr</span>().<span class="ident">unwrap</span>());
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.set_reuseport" class="method"><code>pub fn <a href="#method.set_reuseport" class="fnname">set_reuseport</a>(&self, reuseport: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#244-246" title="goto source code">[src]</a></h4><div class="docblock"><p>Allow the socket to bind to an in-use port. Only available for unix systems
|
||||
(excluding Solaris & Illumos).</p>
|
||||
<p>Behavior is platform specific. Refer to the target platform's
|
||||
documentation for more details.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">set_reuseport</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.reuseport" class="method"><code>pub fn <a href="#method.reuseport" class="fnname">reuseport</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#279-281" title="goto source code">[src]</a></h4><div class="docblock"><p>Allow the socket to bind to an in-use port. Only available for unix systems
|
||||
(excluding Solaris & Illumos).</p>
|
||||
<p>Behavior is platform specific. Refer to the target platform's
|
||||
documentation for more details.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">set_reuseport</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">socket</span>.<span class="ident">reuseport</span>().<span class="ident">unwrap</span>());
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.set_send_buffer_size" class="method"><code>pub fn <a href="#method.set_send_buffer_size" class="fnname">set_send_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#286-288" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the size of the TCP send buffer on this socket.</p>
|
||||
<p>On most operating systems, this sets the <code>SO_SNDBUF</code> socket option.</p>
|
||||
</div><h4 id="method.send_buffer_size" class="method"><code>pub fn <a href="#method.send_buffer_size" class="fnname">send_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#313-315" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the size of the TCP send buffer for this socket.</p>
|
||||
<p>On most operating systems, this is the value of the <code>SO_SNDBUF</code> socket
|
||||
option.</p>
|
||||
<p>Note that if <a href="#method.set_send_buffer_size"><code>set_send_buffer_size</code></a> has been called on this socket
|
||||
previously, the value returned by this function may not be the same as
|
||||
the argument provided to <code>set_send_buffer_size</code>. This is for the
|
||||
following reasons:</p>
|
||||
<ul>
|
||||
<li>Most operating systems have minimum and maximum allowed sizes for the
|
||||
send buffer, and will clamp the provided value if it is below the
|
||||
minimum or above the maximum. The minimum and maximum buffer sizes are
|
||||
OS-dependent.</li>
|
||||
<li>Linux will double the buffer size to account for internal bookkeeping
|
||||
data, and returns the doubled value from <code>getsockopt(2)</code>. As per <code>man 7 socket</code>:
|
||||
<blockquote>
|
||||
<p>Sets or gets the maximum socket send buffer in bytes. The
|
||||
kernel doubles this value (to allow space for bookkeeping
|
||||
overhead) when it is set using <code>setsockopt(2)</code>, and this doubled
|
||||
value is returned by <code>getsockopt(2)</code>.</p>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
</div><h4 id="method.set_recv_buffer_size" class="method"><code>pub fn <a href="#method.set_recv_buffer_size" class="fnname">set_recv_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#320-322" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the size of the TCP receive buffer on this socket.</p>
|
||||
<p>On most operating systems, this sets the <code>SO_RCVBUF</code> socket option.</p>
|
||||
</div><h4 id="method.recv_buffer_size" class="method"><code>pub fn <a href="#method.recv_buffer_size" class="fnname">recv_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#347-349" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the size of the TCP receive buffer for this socket.</p>
|
||||
<p>On most operating systems, this is the value of the <code>SO_RCVBUF</code> socket
|
||||
option.</p>
|
||||
<p>Note that if <a href="#method.set_recv_buffer_size"><code>set_recv_buffer_size</code></a> has been called on this socket
|
||||
previously, the value returned by this function may not be the same as
|
||||
the argument provided to <code>set_send_buffer_size</code>. This is for the
|
||||
following reasons:</p>
|
||||
<ul>
|
||||
<li>Most operating systems have minimum and maximum allowed sizes for the
|
||||
receive buffer, and will clamp the provided value if it is below the
|
||||
minimum or above the maximum. The minimum and maximum buffer sizes are
|
||||
OS-dependent.</li>
|
||||
<li>Linux will double the buffer size to account for internal bookkeeping
|
||||
data, and returns the doubled value from <code>getsockopt(2)</code>. As per <code>man 7 socket</code>:
|
||||
<blockquote>
|
||||
<p>Sets or gets the maximum socket send buffer in bytes. The
|
||||
kernel doubles this value (to allow space for bookkeeping
|
||||
overhead) when it is set using <code>setsockopt(2)</code>, and this doubled
|
||||
value is returned by <code>getsockopt(2)</code>.</p>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#373-375" title="goto source code">[src]</a></h4><div class="docblock"><p>Get the local address of this socket.</p>
|
||||
<p>Will fail on windows if called before <code>bind</code>.</p>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">socket</span>.<span class="ident">local_addr</span>().<span class="ident">unwrap</span>().<span class="ident">to_string</span>(), <span class="string">"127.0.0.1:8080"</span>);
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.bind" class="method"><code>pub fn <a href="#method.bind" class="fnname">bind</a>(&self, addr: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#405-407" title="goto source code">[src]</a></h4><div class="docblock"><p>Bind the socket to the given address.</p>
|
||||
<p>This calls the <code>bind(2)</code> operating-system function. Behavior is
|
||||
platform specific. Refer to the target platform's documentation for more
|
||||
details.</p>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<p>Bind a socket before listening.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.connect" class="method"><code>pub async fn <a href="#method.connect" class="fnname">connect</a>(self, addr: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#441-444" title="goto source code">[src]</a></h4><div class="docblock"><p>Establish a TCP connection with a peer at the specified socket address.</p>
|
||||
<p>The <code>TcpSocket</code> is consumed. Once the connection is established, a
|
||||
connected <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a> is returned. If the connection fails, the
|
||||
encountered error is returned.</p>
|
||||
<p>This calls the <code>connect(2)</code> operating-system function. Behavior is
|
||||
platform specific. Refer to the target platform's documentation for more
|
||||
details.</p>
|
||||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||||
<p>Connecting to a peer.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">connect</span>(<span class="ident">addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.listen" class="method"><code>pub fn <a href="#method.listen" class="fnname">listen</a>(self, backlog: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpListener.html" title="struct tokio::net::TcpListener">TcpListener</a>></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#481-484" title="goto source code">[src]</a></h4><div class="docblock"><p>Convert the socket into a <code>TcpListener</code>.</p>
|
||||
<p><code>backlog</code> defines the maximum number of pending connections are queued
|
||||
by the operating system at any given time. Connection are removed from
|
||||
the queue with <a href="../../tokio/net/struct.TcpListener.html#method.accept"><code>TcpListener::accept</code></a>. When the queue is full, the
|
||||
operationg-system will start rejecting connections.</p>
|
||||
<p>This calls the <code>listen(2)</code> operating-system function, marking the socket
|
||||
as a passive socket. Behavior is platform specific. Refer to the target
|
||||
platform's documentation for more details.</p>
|
||||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||||
<p>Create a <code>TcpListener</code>.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpSocket</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:8080"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">TcpSocket</span>::<span class="ident">new_v4</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">listen</span>(<span class="number">1024</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#494-498" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#495-497" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#487-491" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#488-490" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-FromRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.FromRawFd.html" title="trait std::sys::unix::ext::io::FromRawFd">FromRawFd</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-FromRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#501-512" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from_raw_fd" class="method"><code>unsafe fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.FromRawFd.html#tymethod.from_raw_fd" class="fnname">from_raw_fd</a>(fd: <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a>) -> <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a class="srclink" href="../../src/tokio/net/tcp/socket.rs.html#508-511" title="goto source code">[src]</a></h4><div class="docblock"><p>Converts a <code>RawFd</code> to a <code>TcpSocket</code>.</p>
|
||||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
|
||||
<p>The caller is responsible for ensuring that the socket is in
|
||||
non-blocking mode.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpSocket.html" title="struct tokio::net::TcpSocket">TcpSocket</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
542
doc/tokio/net/struct.TcpStream.html
Normal file
542
doc/tokio/net/struct.TcpStream.html
Normal file
@@ -0,0 +1,542 @@
|
||||
<!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="API documentation for the Rust `TcpStream` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, TcpStream"><title>tokio::net::TcpStream - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct TcpStream</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.connect">connect</a><a href="#method.from_std">from_std</a><a href="#method.into_split">into_split</a><a href="#method.into_std">into_std</a><a href="#method.linger">linger</a><a href="#method.local_addr">local_addr</a><a href="#method.nodelay">nodelay</a><a href="#method.peek">peek</a><a href="#method.peer_addr">peer_addr</a><a href="#method.poll_peek">poll_peek</a><a href="#method.poll_read_ready">poll_read_ready</a><a href="#method.poll_write_ready">poll_write_ready</a><a href="#method.readable">readable</a><a href="#method.ready">ready</a><a href="#method.set_linger">set_linger</a><a href="#method.set_nodelay">set_nodelay</a><a href="#method.set_ttl">set_ttl</a><a href="#method.split">split</a><a href="#method.try_read">try_read</a><a href="#method.try_write">try_write</a><a href="#method.ttl">ttl</a><a href="#method.writable">writable</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-AsRef%3CTcpStream%3E">AsRef<TcpStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CTcpStream%3E">TryFrom<TcpStream></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "TcpStream", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#66-68" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">TcpStream</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct TcpStream { /* fields omitted */ }</pre></div><div class="docblock"><p>A TCP stream between a local and a remote socket.</p>
|
||||
<p>A TCP stream can either be created by connecting to an endpoint, via the
|
||||
<a href="../../tokio/net/struct.TcpStream.html#method.connect"><code>connect</code></a> method, or by <a href="../../tokio/net/struct.TcpListener.html#method.accept">accepting</a> a connection from a <a href="../../tokio/net/struct.TcpListener.html">listener</a>.</p>
|
||||
<p>Reading and writing to a <code>TcpStream</code> is usually done using the
|
||||
convenience methods found on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> and <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a>
|
||||
traits.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Write some data.</span>
|
||||
<span class="ident">stream</span>.<span class="ident">write_all</span>(<span class="string">b"hello world!"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>The <a href="fn@crate::io::AsyncWriteExt::write_all"><code>write_all</code></a> method is defined on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
<p>To shut down the stream in the write direction, you can call the
|
||||
<a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> method. This will cause the other peer to receive a read of
|
||||
length 0, indicating that no more data will be sent. This only closes
|
||||
the stream in one direction.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#71-954" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.connect" class="method"><code>pub async fn <a href="#method.connect" class="fnname">connect</a><A: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>>(addr: A) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#109-127" title="goto source code">[src]</a></h4><div class="docblock"><p>Opens a TCP connection to a remote host.</p>
|
||||
<p><code>addr</code> is an address of the remote host. Anything which implements the
|
||||
<a href="../../tokio/net/trait.ToSocketAddrs.html"><code>ToSocketAddrs</code></a> trait can be supplied as the address. Note that
|
||||
strings only implement this trait when the <strong><code>net</code></strong> feature is enabled,
|
||||
as strings may contain domain names that need to be resolved.</p>
|
||||
<p>If <code>addr</code> yields multiple addresses, connect will be attempted with each
|
||||
of the addresses until a connection is successful. If none of the
|
||||
addresses result in a successful connection, the error returned from the
|
||||
last connection attempt (the last address) is returned.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Write some data.</span>
|
||||
<span class="ident">stream</span>.<span class="ident">write_all</span>(<span class="string">b"hello world!"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>The <a href="fn@crate::io::AsyncWriteExt::write_all"><code>write_all</code></a> method is defined on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#187-191" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>TcpStream</code> from a <code>std::net::TcpStream</code>.</p>
|
||||
<p>This function is intended to be used to wrap a TCP stream from the
|
||||
standard library in the Tokio equivalent. The conversion assumes nothing
|
||||
about the underlying stream; it is left up to the user to set it in
|
||||
non-blocking mode.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">std_stream</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:34254"</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">std_stream</span>.<span class="ident">set_nonblocking</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">from_std</span>(<span class="ident">std_stream</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
</div><h4 id="method.into_std" class="method"><code>pub fn <a href="#method.into_std" class="fnname">into_std</a>(self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#227-243" title="goto source code">[src]</a></h4><div class="docblock"><p>Turn a <a href="../../tokio/net/struct.TcpStream.html"><code>tokio::net::TcpStream</code></a> into a <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html"><code>std::net::TcpStream</code></a>.</p>
|
||||
<p>The returned <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html"><code>std::net::TcpStream</code></a> will have <code>nonblocking mode</code> set as <code>true</code>.
|
||||
Use <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html#method.set_nonblocking"><code>set_nonblocking</code></a> to change the blocking mode if needed.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Read</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">data</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">12</span>];
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:34254"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> (<span class="ident">tokio_tcp_stream</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">std_tcp_stream</span> <span class="op">=</span> <span class="ident">tokio_tcp_stream</span>.<span class="ident">into_std</span>()<span class="question-mark">?</span>;
|
||||
<span class="ident">std_tcp_stream</span>.<span class="ident">set_nonblocking</span>(<span class="bool-val">false</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">std_tcp_stream</span>.<span class="ident">read_exact</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">data</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#259-261" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the local address that this stream is bound to.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">stream</span>.<span class="ident">local_addr</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.peer_addr" class="method"><code>pub fn <a href="#method.peer_addr" class="fnname">peer_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#277-279" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the remote address that this stream is connected to.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">stream</span>.<span class="ident">peer_addr</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.poll_peek" class="method"><code>pub fn <a href="#method.poll_peek" class="fnname">poll_peek</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#323-347" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to receive data on the socket, without removing that data from
|
||||
the queue, registering the current task for wakeup if data is not yet
|
||||
available.</p>
|
||||
<p>Note that on multiple calls to <code>poll_peek</code>, <code>poll_read</code> or
|
||||
<code>poll_read_ready</code>, only the <code>Waker</code> from the <code>Context</code> passed to the
|
||||
most recent call is scheduled to receive a wakeup. (However,
|
||||
<code>poll_write</code> retains a second, independent waker.)</p>
|
||||
<h1 id="return-value" class="section-header"><a href="#return-value">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if data is not yet available.</li>
|
||||
<li><code>Poll::Ready(Ok(n))</code> if data is available. <code>n</code> is the number of bytes peeked.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">ReadBuf</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">poll_fn</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8000"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">ReadBuf</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>);
|
||||
|
||||
<span class="ident">poll_fn</span>(<span class="op">|</span><span class="ident">cx</span><span class="op">|</span> {
|
||||
<span class="ident">stream</span>.<span class="ident">poll_peek</span>(<span class="ident">cx</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>)
|
||||
}).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.ready" class="method"><code>pub async fn <a href="#method.ready" class="fnname">ready</a><'_>(&'_ self, interest: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#409-412" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for any of the requested ready states.</p>
|
||||
<p>This function is usually paired with <code>try_read()</code> or <code>try_write()</code>. It
|
||||
can be used to concurrently read / write to the same socket on a single
|
||||
task without splitting the socket.</p>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<p>Concurrently read and write to the stream on the same task without
|
||||
splitting.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">ready</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">ready</span>(<span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_readable</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">data</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"read {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_writable</span>() {
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"write {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.readable" class="method"><code>pub async fn <a href="#method.readable" class="fnname">readable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#457-460" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become readable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::READABLE)</code> and is usually
|
||||
paired with <code>try_read()</code>.</p>
|
||||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">msg</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">msg</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="ident">msg</span>.<span class="ident">truncate</span>(<span class="ident">n</span>);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT = {:?}"</span>, <span class="ident">msg</span>);
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_read_ready" class="method"><code>pub fn <a href="#method.poll_read_ready" class="fnname">poll_read_ready</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#491-493" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for read readiness.</p>
|
||||
<p>If the tcp stream is not currently ready for reading, this method will
|
||||
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the tcp
|
||||
stream becomes ready for reading, <code>Waker::wake</code> will be called on the
|
||||
waker.</p>
|
||||
<p>Note that on multiple calls to <code>poll_read_ready</code>, <code>poll_read</code> or
|
||||
<code>poll_peek</code>, only the <code>Waker</code> from the <code>Context</code> passed to the most
|
||||
recent call is scheduled to receive a wakeup. (However,
|
||||
<code>poll_write_ready</code> retains a second, independent waker.)</p>
|
||||
<p>This function is intended for cases where creating and pinning a future
|
||||
via <a href="../../tokio/net/struct.TcpStream.html#method.readable"><code>readable</code></a> is not feasible. Where possible, using <a href="../../tokio/net/struct.TcpStream.html#method.readable"><code>readable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<h1 id="return-value-1" class="section-header"><a href="#return-value-1">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the tcp stream is not ready for reading.</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> if the tcp stream is ready for reading.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_read" class="method"><code>pub fn <a href="#method.try_read" class="fnname">try_read</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#554-560" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to read data from the stream into the provided buffer, returning how
|
||||
many bytes were read.</p>
|
||||
<p>Receives any pending data from the socket but does not wait for new data
|
||||
to arrive. On success, returns the number of bytes read. Because
|
||||
<code>try_read()</code> is non-blocking, the buffer does not have to be stored by
|
||||
the async task and can exist entirely on the stack.</p>
|
||||
<p>Usually, <a href="../../tokio/net/struct.TcpStream.html#method.readable"><code>readable()</code></a> or <a href="../../tokio/net/struct.TcpStream.html#method.ready"><code>ready()</code></a> is used with this function.</p>
|
||||
<h1 id="return" class="section-header"><a href="#return">Return</a></h1>
|
||||
<p>If data is successfully read, <code>Ok(n)</code> is returned, where <code>n</code> is the
|
||||
number of bytes read. <code>Ok(0)</code> indicates the stream's read half is closed
|
||||
and will no longer yield data. If the stream is not ready to read data
|
||||
<code>Err(io::ErrorKind::WouldBlock)</code> is returned.</p>
|
||||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Creating the buffer **after** the `await` prevents it from</span>
|
||||
<span class="comment">// being stored in the async task.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4096</span>];
|
||||
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="number">0</span>) <span class="op">=</span><span class="op">></span> <span class="kw">break</span>,
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"read {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.writable" class="method"><code>pub async fn <a href="#method.writable" class="fnname">writable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#601-604" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become writable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::WRITABLE)</code> and is usually
|
||||
paired with <code>try_write()</code>.</p>
|
||||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_write_ready" class="method"><code>pub fn <a href="#method.poll_write_ready" class="fnname">poll_write_ready</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#635-637" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for write readiness.</p>
|
||||
<p>If the tcp stream is not currently ready for writing, this method will
|
||||
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the tcp
|
||||
stream becomes ready for writing, <code>Waker::wake</code> will be called on the
|
||||
waker.</p>
|
||||
<p>Note that on multiple calls to <code>poll_write_ready</code> or <code>poll_write</code>, only
|
||||
the <code>Waker</code> from the <code>Context</code> passed to the most recent call is
|
||||
scheduled to receive a wakeup. (However, <code>poll_read_ready</code> retains a
|
||||
second, independent waker.)</p>
|
||||
<p>This function is intended for cases where creating and pinning a future
|
||||
via <a href="../../tokio/net/struct.TcpStream.html#method.writable"><code>writable</code></a> is not feasible. Where possible, using <a href="../../tokio/net/struct.TcpStream.html#method.writable"><code>writable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<h1 id="return-value-2" class="section-header"><a href="#return-value-2">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the tcp stream is not ready for writing.</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> if the tcp stream is ready for writing.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_write" class="method"><code>pub fn <a href="#method.try_write" class="fnname">try_write</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#687-693" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to write a buffer to the stream, returning how many bytes were
|
||||
written.</p>
|
||||
<p>The function will attempt to write the entire contents of <code>buf</code>, but
|
||||
only part of the buffer may be written.</p>
|
||||
<p>This function is usually paired with <code>writable()</code>.</p>
|
||||
<h1 id="return-1" class="section-header"><a href="#return-1">Return</a></h1>
|
||||
<p>If data is successfully written, <code>Ok(n)</code> is returned, where <code>n</code> is the
|
||||
number of bytes written. If the stream is not ready to write data,
|
||||
<code>Err(io::ErrorKind::WouldBlock)</code> is returned.</p>
|
||||
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.peek" class="method"><code>pub async fn <a href="#method.peek" class="fnname">peek</a><'_, '_>(&'_ self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#732-737" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||||
connected, without removing that data from the queue. On success,
|
||||
returns the number of bytes peeked.</p>
|
||||
<p>Successive calls return the same data. This is accomplished by passing
|
||||
<code>MSG_PEEK</code> as a flag to the underlying recv system call.</p>
|
||||
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncReadExt</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b1</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b2</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
|
||||
<span class="comment">// Peek at the data</span>
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">peek</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b1</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Read the data</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">n</span>, <span class="ident">stream</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b2</span>[..<span class="ident">n</span>]).<span class="ident">await</span><span class="question-mark">?</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">b1</span>[..<span class="ident">n</span>], <span class="kw-2">&</span><span class="ident">b2</span>[..<span class="ident">n</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>The <a href="fn@crate::io::AsyncReadExt::read"><code>read</code></a> method is defined on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div><h4 id="method.nodelay" class="method"><code>pub fn <a href="#method.nodelay" class="fnname">nodelay</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#766-768" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>TCP_NODELAY</code> option on this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.TcpStream.html#method.set_nodelay"><code>set_nodelay</code></a>.</p>
|
||||
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">stream</span>.<span class="ident">nodelay</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.set_nodelay" class="method"><code>pub fn <a href="#method.set_nodelay" class="fnname">set_nodelay</a>(&self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#790-792" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value of the <code>TCP_NODELAY</code> option on this socket.</p>
|
||||
<p>If set, this option disables the Nagle algorithm. This means that
|
||||
segments are always sent as soon as possible, even if there is only a
|
||||
small amount of data. When not set, data is buffered until there is a
|
||||
sufficient amount to send out, thereby avoiding the frequent sending of
|
||||
small packets.</p>
|
||||
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">stream</span>.<span class="ident">set_nodelay</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;</pre></div>
|
||||
</div><h4 id="method.linger" class="method"><code>pub fn <a href="#method.linger" class="fnname">linger</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#813-817" title="goto source code">[src]</a></h4><div class="docblock"><p>Reads the linger duration for this socket by getting the <code>SO_LINGER</code>
|
||||
option.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.TcpStream.html#method.set_linger"><code>set_linger</code></a>.</p>
|
||||
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">stream</span>.<span class="ident">linger</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.set_linger" class="method"><code>pub fn <a href="#method.set_linger" class="fnname">set_linger</a>(&self, dur: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#840-844" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the linger duration of this socket by setting the SO_LINGER option.</p>
|
||||
<p>This option controls the action taken when a stream has unsent messages and the stream is
|
||||
closed. If SO_LINGER is set, the system shall block the process until it can transmit the
|
||||
data or until the time expires.</p>
|
||||
<p>If SO_LINGER is not specified, and the stream is closed, the system handles the call in a
|
||||
way that allows the process to continue as quickly as possible.</p>
|
||||
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">stream</span>.<span class="ident">set_linger</span>(<span class="prelude-val">None</span>)<span class="question-mark">?</span>;</pre></div>
|
||||
</div><h4 id="method.ttl" class="method"><code>pub fn <a href="#method.ttl" class="fnname">ttl</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#876-878" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IP_TTL</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.TcpStream.html#method.set_ttl"><code>set_ttl</code></a>.</p>
|
||||
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">stream</span>.<span class="ident">ttl</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.set_ttl" class="method"><code>pub fn <a href="#method.set_ttl" class="fnname">set_ttl</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#897-899" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value for the <code>IP_TTL</code> option on this socket.</p>
|
||||
<p>This value sets the time-to-live field that is used in every packet sent
|
||||
from this socket.</p>
|
||||
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">stream</span>.<span class="ident">set_ttl</span>(<span class="number">123</span>)<span class="question-mark">?</span>;</pre></div>
|
||||
</div><h4 id="method.split" class="method"><code>pub fn <a href="#method.split" class="fnname">split</a><'a>(&'a mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a>, <a class="struct" href="../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#911-913" title="goto source code">[src]</a></h4><div class="docblock"><p>Splits a <code>TcpStream</code> into a read half and a write half, which can be used
|
||||
to read and write the stream concurrently.</p>
|
||||
<p>This method is more efficient than <a href="../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>, but the halves cannot be
|
||||
moved into independently spawned tasks.</p>
|
||||
</div><h4 id="method.into_split" class="method"><code>pub fn <a href="#method.into_split" class="fnname">into_split</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a>, <a class="struct" href="../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#926-928" title="goto source code">[src]</a></h4><div class="docblock"><p>Splits a <code>TcpStream</code> into a read half and a write half, which can be used
|
||||
to read and write the stream concurrently.</p>
|
||||
<p>Unlike <a href="../../tokio/net/struct.TcpStream.html#method.split"><code>split</code></a>, the owned halves can be moved to separate tasks, however
|
||||
this comes at the cost of a heap allocation.</p>
|
||||
<p><strong>Note:</strong> Dropping the write half will shut down the write half of the TCP
|
||||
stream. This is equivalent to calling <a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> on the <code>TcpStream</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1024-1028" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1025-1027" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-AsRef%3CTcpStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsRef%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/split.rs.html#182-186" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../src/tokio/net/tcp/split.rs.html#183-185" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CTcpStream%3E-1" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsRef%3CTcpStream%3E-1" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/split.rs.html#188-192" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../src/tokio/net/tcp/split.rs.html#189-191" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CTcpStream%3E-2" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsRef%3CTcpStream%3E-2" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/split_owned.rs.html#268-272" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../src/tokio/net/tcp/split_owned.rs.html#269-271" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CTcpStream%3E-3" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsRef%3CTcpStream%3E-3" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/split_owned.rs.html#274-278" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-3" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../src/tokio/net/tcp/split_owned.rs.html#275-277" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#970-978" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#971-977" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#980-1011" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#981-987" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#989-995" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#997-999" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1002-1005" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1007-1010" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1013-1017" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#1014-1016" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CTcpStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-TryFrom%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#956-966" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="../../src/tokio/net/tcp/stream.rs.html#963-965" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.TcpStream.html#method.from_std"><code>TcpStream::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
737
doc/tokio/net/struct.UdpSocket.html
Normal file
737
doc/tokio/net/struct.UdpSocket.html
Normal file
@@ -0,0 +1,737 @@
|
||||
<!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="API documentation for the Rust `UdpSocket` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, UdpSocket"><title>tokio::net::UdpSocket - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct UdpSocket</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.bind">bind</a><a href="#method.broadcast">broadcast</a><a href="#method.connect">connect</a><a href="#method.from_std">from_std</a><a href="#method.join_multicast_v4">join_multicast_v4</a><a href="#method.join_multicast_v6">join_multicast_v6</a><a href="#method.leave_multicast_v4">leave_multicast_v4</a><a href="#method.leave_multicast_v6">leave_multicast_v6</a><a href="#method.local_addr">local_addr</a><a href="#method.multicast_loop_v4">multicast_loop_v4</a><a href="#method.multicast_loop_v6">multicast_loop_v6</a><a href="#method.multicast_ttl_v4">multicast_ttl_v4</a><a href="#method.peek_from">peek_from</a><a href="#method.poll_peek_from">poll_peek_from</a><a href="#method.poll_recv">poll_recv</a><a href="#method.poll_recv_from">poll_recv_from</a><a href="#method.poll_send">poll_send</a><a href="#method.poll_send_to">poll_send_to</a><a href="#method.readable">readable</a><a href="#method.ready">ready</a><a href="#method.recv">recv</a><a href="#method.recv_from">recv_from</a><a href="#method.send">send</a><a href="#method.send_to">send_to</a><a href="#method.set_broadcast">set_broadcast</a><a href="#method.set_multicast_loop_v4">set_multicast_loop_v4</a><a href="#method.set_multicast_loop_v6">set_multicast_loop_v6</a><a href="#method.set_multicast_ttl_v4">set_multicast_ttl_v4</a><a href="#method.set_ttl">set_ttl</a><a href="#method.take_error">take_error</a><a href="#method.try_recv">try_recv</a><a href="#method.try_recv_from">try_recv_from</a><a href="#method.try_send">try_send</a><a href="#method.try_send_to">try_send_to</a><a href="#method.ttl">ttl</a><a href="#method.writable">writable</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CUdpSocket%3E">TryFrom<UdpSocket></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "UdpSocket", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/udp.rs.html#110-112" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">UdpSocket</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct UdpSocket { /* fields omitted */ }</pre></div><div class="docblock"><p>A UDP socket</p>
|
||||
<p>UDP is "connectionless", unlike TCP. Meaning, regardless of what address you've bound to, a <code>UdpSocket</code>
|
||||
is free to communicate with many different remotes. In tokio there are basically two main ways to use <code>UdpSocket</code>:</p>
|
||||
<ul>
|
||||
<li>one to many: <a href="../../tokio/net/struct.UdpSocket.html#method.bind"><code>bind</code></a> and use <a href="../../tokio/net/struct.UdpSocket.html#method.send_to"><code>send_to</code></a>
|
||||
and <a href="../../tokio/net/struct.UdpSocket.html#method.recv_from"><code>recv_from</code></a> to communicate with many different addresses</li>
|
||||
<li>one to one: <a href="../../tokio/net/struct.UdpSocket.html#method.connect"><code>connect</code></a> and associate with a single address, using <a href="../../tokio/net/struct.UdpSocket.html#method.send"><code>send</code></a>
|
||||
and <a href="../../tokio/net/struct.UdpSocket.html#method.recv"><code>recv</code></a> to communicate only with that remote address</li>
|
||||
</ul>
|
||||
<p><code>UdpSocket</code> can also be used concurrently to <code>send_to</code> and <code>recv_from</code> in different tasks,
|
||||
all that's required is that you <code>Arc<UdpSocket></code> and clone a reference for each task.</p>
|
||||
<h1 id="streams" class="section-header"><a href="#streams">Streams</a></h1>
|
||||
<p>If you need to listen over UDP and produce a <a href="https://docs.rs/futures/0.3/futures/stream/trait.Stream.html"><code>Stream</code></a>, you can look
|
||||
at <a href="https://docs.rs/tokio-util/latest/tokio_util/udp/struct.UdpFramed.html"><code>UdpFramed</code></a>.</p>
|
||||
<h1 id="example-one-to-many-bind" class="section-header"><a href="#example-one-to-many-bind">Example: one to many (bind)</a></h1>
|
||||
<p>Using <code>bind</code> we can create a simple echo server that sends and recv's with many different clients:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="ident">len</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes received from {:?}"</span>, <span class="ident">len</span>, <span class="ident">addr</span>);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">send_to</span>(<span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">len</span>], <span class="ident">addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes sent"</span>, <span class="ident">len</span>);
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-one-to-one-connect" class="section-header"><a href="#example-one-to-one-connect">Example: one to one (connect)</a></h1>
|
||||
<p>Or using <code>connect</code> we can echo with a single remote address using <code>send</code> and <code>recv</code>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">remote_addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:59611"</span>;
|
||||
<span class="ident">sock</span>.<span class="ident">connect</span>(<span class="ident">remote_addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes received from {:?}"</span>, <span class="ident">len</span>, <span class="ident">remote_addr</span>);
|
||||
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">send</span>(<span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">len</span>]).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes sent"</span>, <span class="ident">len</span>);
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-sendingreceiving-concurrently" class="section-header"><a href="#example-sendingreceiving-concurrently">Example: Sending/Receiving concurrently</a></h1>
|
||||
<p>Because <code>send_to</code> and <code>recv_from</code> take <code>&self</code>. It's perfectly alright to <code>Arc<UdpSocket></code>
|
||||
and share the references to multiple tasks, in order to send/receive concurrently. Here is
|
||||
a similar "echo" example but that supports concurrent sending/receiving:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::{<span class="ident">net</span>::<span class="ident">UdpSocket</span>, <span class="ident">sync</span>::<span class="ident">mpsc</span>};
|
||||
<span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">io</span>, <span class="ident">net</span>::<span class="ident">SocketAddr</span>, <span class="ident">sync</span>::<span class="ident">Arc</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">SocketAddr</span><span class="op">></span>().<span class="ident">unwrap</span>()).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">r</span> <span class="op">=</span> <span class="ident">Arc</span>::<span class="ident">new</span>(<span class="ident">sock</span>);
|
||||
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">r</span>.<span class="ident">clone</span>();
|
||||
<span class="kw">let</span> (<span class="ident">tx</span>, <span class="kw-2">mut</span> <span class="ident">rx</span>) <span class="op">=</span> <span class="ident">mpsc</span>::<span class="ident">channel</span>::<span class="op"><</span>(<span class="ident">Vec</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span>, <span class="ident">SocketAddr</span>)<span class="op">></span>(<span class="number">1_000</span>);
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="kw">while</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">bytes</span>, <span class="ident">addr</span>)) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv</span>().<span class="ident">await</span> {
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">send_to</span>(<span class="kw-2">&</span><span class="ident">bytes</span>, <span class="kw-2">&</span><span class="ident">addr</span>).<span class="ident">await</span>.<span class="ident">unwrap</span>();
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes sent"</span>, <span class="ident">len</span>);
|
||||
}
|
||||
});
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="ident">len</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">r</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?} bytes received from {:?}"</span>, <span class="ident">len</span>, <span class="ident">addr</span>);
|
||||
<span class="ident">tx</span>.<span class="ident">send</span>((<span class="ident">buf</span>[..<span class="ident">len</span>].<span class="ident">to_vec</span>(), <span class="ident">addr</span>)).<span class="ident">await</span>.<span class="ident">unwrap</span>();
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/udp.rs.html#115-1211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bind" class="method"><code>pub async fn <a href="#method.bind" class="fnname">bind</a><A: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>>(addr: A) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#133-150" title="goto source code">[src]</a></h4><div class="docblock"><p>This function will create a new UDP socket and attempt to bind it to
|
||||
the <code>addr</code> provided.</p>
|
||||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="comment">// use `sock`</span>
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#197-200" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>UdpSocket</code> from a previously bound <code>std::net::UdpSocket</code>.</p>
|
||||
<p>This function is intended to be used to wrap a UDP socket from the
|
||||
standard library in the Tokio equivalent. The conversion assumes nothing
|
||||
about the underlying socket; it is left up to the user to set it in
|
||||
non-blocking mode.</p>
|
||||
<p>This can be used in conjunction with socket2's <code>Socket</code> interface to
|
||||
configure a socket before it's handed off, such as setting options like
|
||||
<code>reuse_address</code> or binding to multiple addresses.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
<h1 id="example-1" class="section-header"><a href="#example-1">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"0.0.0.0:8080"</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">SocketAddr</span><span class="op">></span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">std_sock</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="ident">addr</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">std_sock</span>.<span class="ident">set_nonblocking</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">from_std</span>(<span class="ident">std_sock</span>)<span class="question-mark">?</span>;
|
||||
<span class="comment">// use `sock`</span></pre></div>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#219-221" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the local address that this socket is bound to.</p>
|
||||
<h1 id="example-2" class="section-header"><a href="#example-2">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">addr</span> <span class="op">=</span> <span class="string">"0.0.0.0:8080"</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">SocketAddr</span><span class="op">></span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="ident">addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="comment">// the address the socket is bound to</span>
|
||||
<span class="kw">let</span> <span class="ident">local_addr</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">local_addr</span>()<span class="question-mark">?</span>;</pre></div>
|
||||
</div><h4 id="method.connect" class="method"><code>pub async fn <a href="#method.connect" class="fnname">connect</a><A: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>, '_>(&'_ self, addr: A) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#247-264" title="goto source code">[src]</a></h4><div class="docblock"><p>Connects the UDP socket setting the default destination for send() and
|
||||
limiting packets that are read via recv from the address specified in
|
||||
<code>addr</code>.</p>
|
||||
<h1 id="example-3" class="section-header"><a href="#example-3">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">SocketAddr</span><span class="op">></span>().<span class="ident">unwrap</span>()).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">remote_addr</span> <span class="op">=</span> <span class="string">"127.0.0.1:59600"</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">SocketAddr</span><span class="op">></span>().<span class="ident">unwrap</span>();
|
||||
<span class="ident">sock</span>.<span class="ident">connect</span>(<span class="ident">remote_addr</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">32</span>];
|
||||
<span class="comment">// recv from remote_addr</span>
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="comment">// send to remote_addr</span>
|
||||
<span class="kw">let</span> <span class="ident">_len</span> <span class="op">=</span> <span class="ident">sock</span>.<span class="ident">send</span>(<span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">len</span>]).<span class="ident">await</span><span class="question-mark">?</span>;</pre></div>
|
||||
</div><h4 id="method.ready" class="method"><code>pub async fn <a href="#method.ready" class="fnname">ready</a><'_>(&'_ self, interest: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#325-328" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for any of the requested ready states.</p>
|
||||
<p>This function is usually paired with <code>try_recv()</code> or <code>try_send()</code>. It
|
||||
can be used to concurrently recv / send to the same socket on a single
|
||||
task without splitting the socket.</p>
|
||||
<p>The function may complete without the socket being ready. This is a
|
||||
false-positive and attempting an operation will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Concurrently receive from and send to the socket on the same task
|
||||
without splitting.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">Interest</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">ready</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">ready</span>(<span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_readable</span>() {
|
||||
<span class="comment">// The buffer is **not** included in the async task and will only exist</span>
|
||||
<span class="comment">// on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">data</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">data</span>[..]) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"received {:?}"</span>, <span class="kw-2">&</span><span class="ident">data</span>[..<span class="ident">n</span>]);
|
||||
}
|
||||
<span class="comment">// False-positive, continue</span>
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_writable</span>() {
|
||||
<span class="comment">// Write some data</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"sent {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="comment">// False-positive, continue</span>
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.writable" class="method"><code>pub async fn <a href="#method.writable" class="fnname">writable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#373-376" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become writable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::WRITABLE)</code> and is
|
||||
usually paired with <code>try_send()</code> or <code>try_send_to()</code>.</p>
|
||||
<p>The function may complete without the socket being writable. This is a
|
||||
false-positive and attempting a <code>try_send()</code> will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Bind socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to send data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.send" class="method"><code>pub async fn <a href="#method.send" class="fnname">send</a><'_, '_>(&'_ self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#409-414" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends data on the socket to the remote address that the socket is
|
||||
connected to.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UdpSocket.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||||
This method will fail if the socket is not connected.</p>
|
||||
<h1 id="return" class="section-header"><a href="#return">Return</a></h1>
|
||||
<p>On success, the number of bytes sent is returned, otherwise, the
|
||||
encountered error is returned.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Bind socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Send a message</span>
|
||||
<span class="ident">socket</span>.<span class="ident">send</span>(<span class="string">b"hello world"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_send" class="method"><code>pub fn <a href="#method.poll_send" class="fnname">poll_send</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#439-443" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to send data on the socket to the remote address to which it
|
||||
was previously <code>connect</code>ed.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UdpSocket.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||||
This method will fail if the socket is not connected.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the send direction,
|
||||
only the <code>Waker</code> from the <code>Context</code> passed to the most recent call will
|
||||
be scheduled to receive a wakeup.</p>
|
||||
<h1 id="return-value" class="section-header"><a href="#return-value">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not available to write</li>
|
||||
<li><code>Poll::Ready(Ok(n))</code> <code>n</code> is the number of bytes sent</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_send" class="method"><code>pub fn <a href="#method.try_send" class="fnname">try_send</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#493-497" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to send data on the socket to the remote address to which it is
|
||||
connected.</p>
|
||||
<p>When the socket buffer is full, <code>Err(io::ErrorKind::WouldBlock)</code> is
|
||||
returned. This function is usually paired with <code>writable()</code>.</p>
|
||||
<h1 id="returns" class="section-header"><a href="#returns">Returns</a></h1>
|
||||
<p>If successful, <code>Ok(n)</code> is returned, where <code>n</code> is the number of bytes
|
||||
sent. If the socket is not ready to send data,
|
||||
<code>Err(ErrorKind::WouldBlock)</code> is returned.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Bind a UDP socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to send data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.readable" class="method"><code>pub async fn <a href="#method.readable" class="fnname">readable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#547-550" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become readable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::READABLE)</code> and is usually
|
||||
paired with <code>try_recv()</code>.</p>
|
||||
<p>The function may complete without the socket being readable. This is a
|
||||
false-positive and attempting a <code>try_recv()</code> will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.recv" class="method"><code>pub async fn <a href="#method.recv" class="fnname">recv</a><'_, '_>(&'_ self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#582-587" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives a single datagram message on the socket from the remote address
|
||||
to which it is connected. On success, returns the number of bytes read.</p>
|
||||
<p>The function must be called with valid byte array <code>buf</code> of sufficient
|
||||
size to hold the message bytes. If a message is too long to fit in the
|
||||
supplied buffer, excess bytes may be discarded.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UdpSocket.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||||
This method will fail if the socket is not connected.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Bind socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"received {} bytes {:?}"</span>, <span class="ident">n</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_recv" class="method"><code>pub fn <a href="#method.poll_recv" class="fnname">poll_recv</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#612-628" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to receive a single datagram message on the socket from the remote
|
||||
address to which it is <code>connect</code>ed.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UdpSocket.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address. This method
|
||||
resolves to an error if the socket is not connected.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the recv direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value-1" class="section-header"><a href="#return-value-1">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to read</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> reads data <code>ReadBuf</code> if the socket is ready</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_recv" class="method"><code>pub fn <a href="#method.try_recv" class="fnname">try_recv</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#680-684" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to receive a single datagram message on the socket from the remote
|
||||
address to which it is connected. On success, returns the number of
|
||||
bytes read.</p>
|
||||
<p>The function must be called with valid byte array buf of sufficient size
|
||||
to hold the message bytes. If a message is too long to fit in the
|
||||
supplied buffer, excess bytes may be discarded.</p>
|
||||
<p>When there is no pending data, <code>Err(io::ErrorKind::WouldBlock)</code> is
|
||||
returned. This function is usually paired with <code>readable()</code>.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.send_to" class="method"><code>pub async fn <a href="#method.send_to" class="fnname">send_to</a><A: <a class="trait" href="../../tokio/net/trait.ToSocketAddrs.html" title="trait tokio::net::ToSocketAddrs">ToSocketAddrs</a>, '_, '_>(<br> &'_ self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> target: A<br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#716-726" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends data on the socket to the given address. On success, returns the
|
||||
number of bytes written.</p>
|
||||
<p>Address type can be any implementor of <a href="../../tokio/net/trait.ToSocketAddrs.html"><code>ToSocketAddrs</code></a> trait. See its
|
||||
documentation for concrete examples.</p>
|
||||
<p>It is possible for <code>addr</code> to yield multiple addresses, but <code>send_to</code>
|
||||
will only send data to the first address yielded by <code>addr</code>.</p>
|
||||
<p>This will return an error when the IP version of the local socket does
|
||||
not match that returned from <a href="../../tokio/net/trait.ToSocketAddrs.html"><code>ToSocketAddrs</code></a>.</p>
|
||||
<h1 id="example-4" class="section-header"><a href="#example-4">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">send_to</span>(<span class="string">b"hello world"</span>, <span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Sent {} bytes"</span>, <span class="ident">len</span>);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_send_to" class="method"><code>pub fn <a href="#method.poll_send_to" class="fnname">poll_send_to</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> target: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#745-754" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to send data on the socket to a given address.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the send direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value-2" class="section-header"><a href="#return-value-2">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to write</li>
|
||||
<li><code>Poll::Ready(Ok(n))</code> <code>n</code> is the number of bytes sent.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_send_to" class="method"><code>pub fn <a href="#method.try_send_to" class="fnname">try_send_to</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, target: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#803-807" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to send data on the socket to the given address, but if the send is
|
||||
blocked this will return right away.</p>
|
||||
<p>This function is usually paired with <code>writable()</code>.</p>
|
||||
<h1 id="returns-1" class="section-header"><a href="#returns-1">Returns</a></h1>
|
||||
<p>If successfull, returns the number of bytes sent</p>
|
||||
<p>Users should ensure that when the remote cannot receive, the
|
||||
<a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.WouldBlock"><code>ErrorKind::WouldBlock</code></a> is properly handled. An error can also occur
|
||||
if the IP version of the socket does not match that of <code>target</code>.</p>
|
||||
<h1 id="example-5" class="section-header"><a href="#example-5">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dst</span> <span class="op">=</span> <span class="string">"127.0.0.1:8081"</span>.<span class="ident">parse</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send_to</span>(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..], <span class="ident">dst</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">sent</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"sent {} bytes"</span>, <span class="ident">sent</span>);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="comment">// Writable false positive.</span>
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> <span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>()),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.recv_from" class="method"><code>pub async fn <a href="#method.recv_from" class="fnname">recv_from</a><'_, '_>(<br> &'_ self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#841-846" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives a single datagram message on the socket. On success, returns
|
||||
the number of bytes read and the origin.</p>
|
||||
<p>The function must be called with valid byte array <code>buf</code> of sufficient
|
||||
size to hold the message bytes. If a message is too long to fit in the
|
||||
supplied buffer, excess bytes may be discarded.</p>
|
||||
<h1 id="example-6" class="section-header"><a href="#example-6">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">32</span>];
|
||||
<span class="kw">let</span> (<span class="ident">len</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"received {:?} bytes from {:?}"</span>, <span class="ident">len</span>, <span class="ident">addr</span>);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_recv_from" class="method"><code>pub fn <a href="#method.poll_recv_from" class="fnname">poll_recv_from</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#865-885" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to receive a single datagram on the socket.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the recv direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value-3" class="section-header"><a href="#return-value-3">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to read</li>
|
||||
<li><code>Poll::Ready(Ok(addr))</code> reads data from <code>addr</code> into <code>ReadBuf</code> if the socket is ready</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_recv_from" class="method"><code>pub fn <a href="#method.try_recv_from" class="fnname">try_recv_from</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#936-940" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to receive a single datagram message on the socket. On success,
|
||||
returns the number of bytes read and the origin.</p>
|
||||
<p>The function must be called with valid byte array buf of sufficient size
|
||||
to hold the message bytes. If a message is too long to fit in the
|
||||
supplied buffer, excess bytes may be discarded.</p>
|
||||
<p>When there is no pending data, <code>Err(io::ErrorKind::WouldBlock)</code> is
|
||||
returned. This function is usually paired with <code>readable()</code>.</p>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="string">"127.0.0.1:8081"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>((<span class="ident">n</span>, <span class="ident">_addr</span>)) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.peek_from" class="method"><code>pub async fn <a href="#method.peek_from" class="fnname">peek_from</a><'_, '_>(<br> &'_ self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#972-977" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data from the socket, without removing it from the input queue.
|
||||
On success, returns the number of bytes read and the address from whence
|
||||
the data came.</p>
|
||||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
|
||||
<p>On Windows, if the data is larger than the buffer specified, the buffer
|
||||
is filled with the first part of the data, and peek_from returns the error
|
||||
WSAEMSGSIZE(10040). The excess data is lost.
|
||||
Make sure to always use a sufficiently large buffer to hold the
|
||||
maximum UDP packet size, which can be up to 65536 bytes in size.</p>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">32</span>];
|
||||
<span class="kw">let</span> (<span class="ident">len</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">peek_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"peeked {:?} bytes from {:?}"</span>, <span class="ident">len</span>, <span class="ident">addr</span>);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_peek_from" class="method"><code>pub fn <a href="#method.poll_peek_from" class="fnname">poll_peek_from</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1005-1025" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data from the socket, without removing it from the input queue.
|
||||
On success, returns the number of bytes read.</p>
|
||||
<h1 id="notes-1" class="section-header"><a href="#notes-1">Notes</a></h1>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the recv direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup</p>
|
||||
<p>On Windows, if the data is larger than the buffer specified, the buffer
|
||||
is filled with the first part of the data, and peek returns the error
|
||||
WSAEMSGSIZE(10040). The excess data is lost.
|
||||
Make sure to always use a sufficiently large buffer to hold the
|
||||
maximum UDP packet size, which can be up to 65536 bytes in size.</p>
|
||||
<h1 id="return-value-4" class="section-header"><a href="#return-value-4">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to read</li>
|
||||
<li><code>Poll::Ready(Ok(addr))</code> reads data from <code>addr</code> into <code>ReadBuf</code> if the socket is ready</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-4" class="section-header"><a href="#errors-4">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.broadcast" class="method"><code>pub fn <a href="#method.broadcast" class="fnname">broadcast</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1032-1034" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>SO_BROADCAST</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.set_broadcast"><code>set_broadcast</code></a>.</p>
|
||||
</div><h4 id="method.set_broadcast" class="method"><code>pub fn <a href="#method.set_broadcast" class="fnname">set_broadcast</a>(&self, on: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1040-1042" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value of the <code>SO_BROADCAST</code> option for this socket.</p>
|
||||
<p>When enabled, this socket is allowed to send packets to a broadcast
|
||||
address.</p>
|
||||
</div><h4 id="method.multicast_loop_v4" class="method"><code>pub fn <a href="#method.multicast_loop_v4" class="fnname">multicast_loop_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1049-1051" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.set_multicast_loop_v4"><code>set_multicast_loop_v4</code></a>.</p>
|
||||
</div><h4 id="method.set_multicast_loop_v4" class="method"><code>pub fn <a href="#method.set_multicast_loop_v4" class="fnname">set_multicast_loop_v4</a>(&self, on: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1060-1062" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
|
||||
<p>If enabled, multicast packets will be looped back to the local socket.</p>
|
||||
<h1 id="note" class="section-header"><a href="#note">Note</a></h1>
|
||||
<p>This may not have any affect on IPv6 sockets.</p>
|
||||
</div><h4 id="method.multicast_ttl_v4" class="method"><code>pub fn <a href="#method.multicast_ttl_v4" class="fnname">multicast_ttl_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1069-1071" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.set_multicast_ttl_v4"><code>set_multicast_ttl_v4</code></a>.</p>
|
||||
</div><h4 id="method.set_multicast_ttl_v4" class="method"><code>pub fn <a href="#method.set_multicast_ttl_v4" class="fnname">set_multicast_ttl_v4</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1082-1084" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
|
||||
<p>Indicates the time-to-live value of outgoing multicast packets for
|
||||
this socket. The default value is 1 which means that multicast packets
|
||||
don't leave the local network unless explicitly requested.</p>
|
||||
<h1 id="note-1" class="section-header"><a href="#note-1">Note</a></h1>
|
||||
<p>This may not have any affect on IPv6 sockets.</p>
|
||||
</div><h4 id="method.multicast_loop_v6" class="method"><code>pub fn <a href="#method.multicast_loop_v6" class="fnname">multicast_loop_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1091-1093" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.set_multicast_loop_v6"><code>set_multicast_loop_v6</code></a>.</p>
|
||||
</div><h4 id="method.set_multicast_loop_v6" class="method"><code>pub fn <a href="#method.set_multicast_loop_v6" class="fnname">set_multicast_loop_v6</a>(&self, on: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1102-1104" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
|
||||
<p>Controls whether this socket sees the multicast packets it sends itself.</p>
|
||||
<h1 id="note-2" class="section-header"><a href="#note-2">Note</a></h1>
|
||||
<p>This may not have any affect on IPv4 sockets.</p>
|
||||
</div><h4 id="method.ttl" class="method"><code>pub fn <a href="#method.ttl" class="fnname">ttl</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1125-1127" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets the value of the <code>IP_TTL</code> option for this socket.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.set_ttl"><code>set_ttl</code></a>.</p>
|
||||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">sock</span>.<span class="ident">ttl</span>()<span class="question-mark">?</span>);</pre></div>
|
||||
</div><h4 id="method.set_ttl" class="method"><code>pub fn <a href="#method.set_ttl" class="fnname">set_ttl</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1147-1149" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the value for the <code>IP_TTL</code> option on this socket.</p>
|
||||
<p>This value sets the time-to-live field that is used in every packet sent
|
||||
from this socket.</p>
|
||||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">sock</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="ident">sock</span>.<span class="ident">set_ttl</span>(<span class="number">60</span>)<span class="question-mark">?</span>;
|
||||
</pre></div>
|
||||
</div><h4 id="method.join_multicast_v4" class="method"><code>pub fn <a href="#method.join_multicast_v4" class="fnname">join_multicast_v4</a>(<br> &self, <br> multiaddr: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>, <br> interface: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1158-1160" title="goto source code">[src]</a></h4><div class="docblock"><p>Executes an operation of the <code>IP_ADD_MEMBERSHIP</code> type.</p>
|
||||
<p>This function specifies a new multicast group for this socket to join.
|
||||
The address must be a valid multicast address, and <code>interface</code> is the
|
||||
address of the local interface with which the system should join the
|
||||
multicast group. If it's equal to <code>INADDR_ANY</code> then an appropriate
|
||||
interface is chosen by the system.</p>
|
||||
</div><h4 id="method.join_multicast_v6" class="method"><code>pub fn <a href="#method.join_multicast_v6" class="fnname">join_multicast_v6</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv6Addr.html" title="struct std::net::ip::Ipv6Addr">Ipv6Addr</a>, <br> interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1167-1169" title="goto source code">[src]</a></h4><div class="docblock"><p>Executes an operation of the <code>IPV6_ADD_MEMBERSHIP</code> type.</p>
|
||||
<p>This function specifies a new multicast group for this socket to join.
|
||||
The address must be a valid multicast address, and <code>interface</code> is the
|
||||
index of the interface to join/leave (or 0 to indicate any interface).</p>
|
||||
</div><h4 id="method.leave_multicast_v4" class="method"><code>pub fn <a href="#method.leave_multicast_v4" class="fnname">leave_multicast_v4</a>(<br> &self, <br> multiaddr: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>, <br> interface: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1176-1178" title="goto source code">[src]</a></h4><div class="docblock"><p>Executes an operation of the <code>IP_DROP_MEMBERSHIP</code> type.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.join_multicast_v4"><code>join_multicast_v4</code></a>.</p>
|
||||
</div><h4 id="method.leave_multicast_v6" class="method"><code>pub fn <a href="#method.leave_multicast_v6" class="fnname">leave_multicast_v6</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv6Addr.html" title="struct std::net::ip::Ipv6Addr">Ipv6Addr</a>, <br> interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1185-1187" title="goto source code">[src]</a></h4><div class="docblock"><p>Executes an operation of the <code>IPV6_DROP_MEMBERSHIP</code> type.</p>
|
||||
<p>For more information about this option, see <a href="../../tokio/net/struct.UdpSocket.html#method.join_multicast_v6"><code>join_multicast_v6</code></a>.</p>
|
||||
</div><h4 id="method.take_error" class="method"><code>pub fn <a href="#method.take_error" class="fnname">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1208-1210" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the value of the <code>SO_ERROR</code> option.</p>
|
||||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UdpSocket</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Create a socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UdpSocket</span>::<span class="ident">bind</span>(<span class="string">"0.0.0.0:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>(<span class="ident">err</span>)) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">take_error</span>() {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Got error: {:?}"</span>, <span class="ident">err</span>);
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/udp.rs.html#1236-1240" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1237-1239" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/udp.rs.html#1225-1229" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1226-1228" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CUdpSocket%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-TryFrom%3CUdpSocket%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/udp.rs.html#1213-1223" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="../../src/tokio/net/udp.rs.html#1220-1222" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.UdpSocket.html#method.from_std"><code>UdpSocket::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UdpSocket.html" title="struct tokio::net::UdpSocket">UdpSocket</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
722
doc/tokio/net/struct.UnixDatagram.html
Normal file
722
doc/tokio/net/struct.UnixDatagram.html
Normal file
@@ -0,0 +1,722 @@
|
||||
<!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="API documentation for the Rust `UnixDatagram` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, UnixDatagram"><title>tokio::net::UnixDatagram - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct UnixDatagram</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.bind">bind</a><a href="#method.connect">connect</a><a href="#method.from_std">from_std</a><a href="#method.local_addr">local_addr</a><a href="#method.pair">pair</a><a href="#method.peer_addr">peer_addr</a><a href="#method.poll_recv">poll_recv</a><a href="#method.poll_recv_from">poll_recv_from</a><a href="#method.poll_send">poll_send</a><a href="#method.poll_send_to">poll_send_to</a><a href="#method.readable">readable</a><a href="#method.ready">ready</a><a href="#method.recv">recv</a><a href="#method.recv_from">recv_from</a><a href="#method.send">send</a><a href="#method.send_to">send_to</a><a href="#method.shutdown">shutdown</a><a href="#method.take_error">take_error</a><a href="#method.try_recv">try_recv</a><a href="#method.try_recv_from">try_recv_from</a><a href="#method.try_send">try_send</a><a href="#method.try_send_to">try_send_to</a><a href="#method.unbound">unbound</a><a href="#method.writable">writable</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CUnixDatagram%3E">TryFrom<UnixDatagram></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "UnixDatagram", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#81-83" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">UnixDatagram</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct UnixDatagram { /* fields omitted */ }</pre></div><div class="docblock"><p>An I/O object representing a Unix datagram socket.</p>
|
||||
<p>A socket can be either named (associated with a filesystem path) or
|
||||
unnamed.</p>
|
||||
<p><strong>Note:</strong> named sockets are persisted even after the object is dropped
|
||||
and the program has exited, and cannot be reconnected. It is advised
|
||||
that you either check for and unlink the existing socket if it exists,
|
||||
or use a temporary file that is guaranteed to not already exist.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Using named sockets, associated with a filesystem path:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind each socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">tx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"tx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">tx_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">tx</span>.<span class="ident">send_to</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span><span class="ident">rx_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> (<span class="ident">size</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">addr</span>.<span class="ident">as_pathname</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&</span><span class="ident">tx_path</span>);
|
||||
</pre></div>
|
||||
<p>Using unnamed sockets, created as a pair</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create the pair of sockets</span>
|
||||
<span class="kw">let</span> (<span class="ident">sock1</span>, <span class="ident">sock2</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Since the sockets are paired, the paired send/recv</span>
|
||||
<span class="comment">// functions can be used</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">sock1</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buff</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> <span class="ident">size</span> <span class="op">=</span> <span class="ident">sock2</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buff</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buff</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#86-1084" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.ready" class="method"><code>pub async fn <a href="#method.ready" class="fnname">ready</a><'_>(&'_ self, interest: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#148-151" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for any of the requested ready states.</p>
|
||||
<p>This function is usually paired with <code>try_recv()</code> or <code>try_send()</code>. It
|
||||
can be used to concurrently recv / send to the same socket on a single
|
||||
task without splitting the socket.</p>
|
||||
<p>The function may complete without the socket being ready. This is a
|
||||
false-positive and attempting an operation will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<p>Concurrently receive from and send to the socket on the same task
|
||||
without splitting.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">server_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">ready</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">ready</span>(<span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_readable</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">data</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">data</span>[..]) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"received {:?}"</span>, <span class="kw-2">&</span><span class="ident">data</span>[..<span class="ident">n</span>]);
|
||||
}
|
||||
<span class="comment">// False-positive, continue</span>
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_writable</span>() {
|
||||
<span class="comment">// Write some data</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"sent {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="comment">// False-positive, continue</span>
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.writable" class="method"><code>pub async fn <a href="#method.writable" class="fnname">writable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#198-201" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become writable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::WRITABLE)</code> and is
|
||||
usually paired with <code>try_send()</code> or <code>try_send_to()</code>.</p>
|
||||
<p>The function may complete without the socket being writable. This is a
|
||||
false-positive and attempting a <code>try_send()</code> will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">server_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to send data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.readable" class="method"><code>pub async fn <a href="#method.readable" class="fnname">readable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#254-257" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become readable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::READABLE)</code> and is usually
|
||||
paired with <code>try_recv()</code>.</p>
|
||||
<p>The function may complete without the socket being readable. This is a
|
||||
false-positive and attempting a <code>try_recv()</code> will return with
|
||||
<code>io::ErrorKind::WouldBlock</code>.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">server_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.bind" class="method"><code>pub fn <a href="#method.bind" class="fnname">bind</a><P>(path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#280-286" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new <code>UnixDatagram</code> bound to the specified path.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind the socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">socket_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"socket"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">socket_path</span>)<span class="question-mark">?</span>;
|
||||
</pre></div>
|
||||
</div><h4 id="method.pair" class="method"><code>pub fn <a href="#method.pair" class="fnname">pair</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a>, <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#317-323" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates an unnamed pair of connected sockets.</p>
|
||||
<p>This function will create a pair of interconnected Unix sockets for
|
||||
communicating back and forth between one another.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create the pair of sockets</span>
|
||||
<span class="kw">let</span> (<span class="ident">sock1</span>, <span class="ident">sock2</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Since the sockets are paired, the paired send/recv</span>
|
||||
<span class="comment">// functions can be used</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hail eris"</span>;
|
||||
<span class="ident">sock1</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buff</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> <span class="ident">size</span> <span class="op">=</span> <span class="ident">sock2</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buff</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buff</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(datagram: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixDatagram.html" title="struct std::sys::unix::ext::net::UnixDatagram">UnixDatagram</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#361-365" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>UnixDatagram</code> from a <code>std::os::unix::net::UnixDatagram</code>.</p>
|
||||
<p>This function is intended to be used to wrap a UnixDatagram from the
|
||||
standard library in the Tokio equivalent. The conversion assumes
|
||||
nothing about the underlying datagram; it is left up to the user to set
|
||||
it in non-blocking mode.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a Tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">os</span>::<span class="ident">unix</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span> <span class="kw">as</span> <span class="ident">StdUDS</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind the socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">socket_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"socket"</span>);
|
||||
<span class="kw">let</span> <span class="ident">std_socket</span> <span class="op">=</span> <span class="ident">StdUDS</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">socket_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">std_socket</span>.<span class="ident">set_nonblocking</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">tokio_socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">from_std</span>(<span class="ident">std_socket</span>)<span class="question-mark">?</span>;
|
||||
</pre></div>
|
||||
</div><h4 id="method.unbound" class="method"><code>pub fn <a href="#method.unbound" class="fnname">unbound</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#403-406" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new <code>UnixDatagram</code> which is not bound to any address.</p>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">unbound</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Create another, bound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Send to the bound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">tx</span>.<span class="ident">send_to</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span><span class="ident">rx_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> (<span class="ident">size</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.connect" class="method"><code>pub fn <a href="#method.connect" class="fnname">connect</a><P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(&self, path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#445-447" title="goto source code">[src]</a></h4><div class="docblock"><p>Connects the socket to the specified address.</p>
|
||||
<p>The <code>send</code> method may be used to send data to the specified address.
|
||||
<code>recv</code> and <code>recv_from</code> will only receive data from that address.</p>
|
||||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">unbound</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Create another, bound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Connect to the bound socket</span>
|
||||
<span class="ident">tx</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Send to the bound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">tx</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> (<span class="ident">size</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.send" class="method"><code>pub async fn <a href="#method.send" class="fnname">send</a><'_, '_>(&'_ self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#475-480" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends data on the socket to the socket's peer.</p>
|
||||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create the pair of sockets</span>
|
||||
<span class="kw">let</span> (<span class="ident">sock1</span>, <span class="ident">sock2</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Since the sockets are paired, the paired send/recv</span>
|
||||
<span class="comment">// functions can be used</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">sock1</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buff</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> <span class="ident">size</span> <span class="op">=</span> <span class="ident">sock2</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buff</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buff</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.try_send" class="method"><code>pub fn <a href="#method.try_send" class="fnname">try_send</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#520-524" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to send a datagram to the peer without waiting.</p>
|
||||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">server_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to send data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.try_send_to" class="method"><code>pub fn <a href="#method.try_send_to" class="fnname">try_send_to</a><P>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, target: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#563-570" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to send a datagram to the peer without waiting.</p>
|
||||
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to send data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_send_to</span>(<span class="string">b"hello world"</span>, <span class="kw-2">&</span><span class="ident">server_path</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.recv" class="method"><code>pub async fn <a href="#method.recv" class="fnname">recv</a><'_, '_>(&'_ self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#598-603" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data from the socket.</p>
|
||||
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create the pair of sockets</span>
|
||||
<span class="kw">let</span> (<span class="ident">sock1</span>, <span class="ident">sock2</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Since the sockets are paired, the paired send/recv</span>
|
||||
<span class="comment">// functions can be used</span>
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">sock1</span>.<span class="ident">send</span>(<span class="ident">bytes</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buff</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> <span class="ident">size</span> <span class="op">=</span> <span class="ident">sock2</span>.<span class="ident">recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buff</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buff</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.try_recv" class="method"><code>pub fn <a href="#method.try_recv" class="fnname">try_recv</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#649-653" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to receive a datagram from the peer without waiting.</p>
|
||||
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">socket</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">server_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.send_to" class="method"><code>pub async fn <a href="#method.send_to" class="fnname">send_to</a><P, '_, '_>(<br> &'_ self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> target: P<br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#688-696" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends data on the socket to the specified address.</p>
|
||||
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind each socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">tx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"tx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">tx_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">tx</span>.<span class="ident">send_to</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span><span class="ident">rx_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> (<span class="ident">size</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">addr</span>.<span class="ident">as_pathname</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&</span><span class="ident">tx_path</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.recv_from" class="method"><code>pub async fn <a href="#method.recv_from" class="fnname">recv_from</a><'_, '_>(<br> &'_ self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#731-739" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data from the socket.</p>
|
||||
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind each socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">tx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"tx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">tx_path</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="string">b"hello world"</span>;
|
||||
<span class="ident">tx</span>.<span class="ident">send_to</span>(<span class="ident">bytes</span>, <span class="kw-2">&</span><span class="ident">rx_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">24</span>];
|
||||
<span class="kw">let</span> (<span class="ident">size</span>, <span class="ident">addr</span>) <span class="op">=</span> <span class="ident">rx</span>.<span class="ident">recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">dgram</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">size</span>];
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">dgram</span>, <span class="ident">bytes</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">addr</span>.<span class="ident">as_pathname</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&</span><span class="ident">tx_path</span>);
|
||||
</pre></div>
|
||||
</div><h4 id="method.poll_recv_from" class="method"><code>pub fn <a href="#method.poll_recv_from" class="fnname">poll_recv_from</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#758-778" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to receive a single datagram on the specified address.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the recv direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value" class="section-header"><a href="#return-value">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to read</li>
|
||||
<li><code>Poll::Ready(Ok(addr))</code> reads data from <code>addr</code> into <code>ReadBuf</code> if the socket is ready</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.poll_send_to" class="method"><code>pub fn <a href="#method.poll_send_to" class="fnname">poll_send_to</a><P>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> target: P<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#797-809" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to send data to the specified address.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the send direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value-1" class="section-header"><a href="#return-value-1">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to write</li>
|
||||
<li><code>Poll::Ready(Ok(n))</code> <code>n</code> is the number of bytes sent.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.poll_send" class="method"><code>pub fn <a href="#method.poll_send" class="fnname">poll_send</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#834-838" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to send data on the socket to the remote address to which it
|
||||
was previously <code>connect</code>ed.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UnixDatagram.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||||
This method will fail if the socket is not connected.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the send direction,
|
||||
only the <code>Waker</code> from the <code>Context</code> passed to the most recent call will
|
||||
be scheduled to receive a wakeup.</p>
|
||||
<h1 id="return-value-2" class="section-header"><a href="#return-value-2">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not available to write</li>
|
||||
<li><code>Poll::Ready(Ok(n))</code> <code>n</code> is the number of bytes sent</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.poll_recv" class="method"><code>pub fn <a href="#method.poll_recv" class="fnname">poll_recv</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#863-879" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to receive a single datagram message on the socket from the remote
|
||||
address to which it is <code>connect</code>ed.</p>
|
||||
<p>The <a href="../../tokio/net/struct.UnixDatagram.html#method.connect"><code>connect</code></a> method will connect this socket to a remote address. This method
|
||||
resolves to an error if the socket is not connected.</p>
|
||||
<p>Note that on multiple calls to a <code>poll_*</code> method in the recv direction, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call will be scheduled to
|
||||
receive a wakeup.</p>
|
||||
<h1 id="return-value-3" class="section-header"><a href="#return-value-3">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the socket is not ready to read</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> reads data <code>ReadBuf</code> if the socket is ready</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_recv_from" class="method"><code>pub fn <a href="#method.try_recv_from" class="fnname">try_recv_from</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#924-931" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to receive data from the socket without waiting.</p>
|
||||
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">client_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"client.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">server_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"server.sock"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">client_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">socket</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// The buffer is **not** included in the async task and will</span>
|
||||
<span class="comment">// only exist on the stack.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// Try to recv data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">try_recv_from</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>((<span class="ident">n</span>, <span class="ident">_addr</span>)) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT {:?}"</span>, <span class="kw-2">&</span><span class="ident">buf</span>[..<span class="ident">n</span>]);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#973-975" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the local address that this socket is bound to.</p>
|
||||
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
|
||||
<p>For a socket bound to a local path</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// We use a temporary directory so that the socket</span>
|
||||
<span class="comment">// files left by the bound sockets will get cleaned up.</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Bind socket to a filesystem path</span>
|
||||
<span class="kw">let</span> <span class="ident">socket_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"socket"</span>);
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">socket_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">socket</span>.<span class="ident">local_addr</span>()<span class="question-mark">?</span>.<span class="ident">as_pathname</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&</span><span class="ident">socket_path</span>);
|
||||
</pre></div>
|
||||
<p>For an unbound socket</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">unbound</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">socket</span>.<span class="ident">local_addr</span>()<span class="question-mark">?</span>.<span class="ident">is_unnamed</span>());
|
||||
</pre></div>
|
||||
</div><h4 id="method.peer_addr" class="method"><code>pub fn <a href="#method.peer_addr" class="fnname">peer_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1022-1024" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the address of this socket's peer.</p>
|
||||
<p>The <code>connect</code> method will connect the socket to a peer.</p>
|
||||
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
|
||||
<p>For a peer with a local path</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">unbound</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Create another, bound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">tmp</span> <span class="op">=</span> <span class="ident">tempdir</span>()<span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> <span class="ident">rx_path</span> <span class="op">=</span> <span class="ident">tmp</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"rx"</span>);
|
||||
<span class="kw">let</span> <span class="ident">rx</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">bind</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Connect to the bound socket</span>
|
||||
<span class="ident">tx</span>.<span class="ident">connect</span>(<span class="kw-2">&</span><span class="ident">rx_path</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">tx</span>.<span class="ident">peer_addr</span>()<span class="question-mark">?</span>.<span class="ident">as_pathname</span>().<span class="ident">unwrap</span>(), <span class="kw-2">&</span><span class="ident">rx_path</span>);
|
||||
</pre></div>
|
||||
<p>For an unbound peer</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create the pair of sockets</span>
|
||||
<span class="kw">let</span> (<span class="ident">sock1</span>, <span class="ident">sock2</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">sock1</span>.<span class="ident">peer_addr</span>()<span class="question-mark">?</span>.<span class="ident">is_unnamed</span>());
|
||||
</pre></div>
|
||||
</div><h4 id="method.take_error" class="method"><code>pub fn <a href="#method.take_error" class="fnname">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1045-1047" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the value of the <code>SO_ERROR</code> option.</p>
|
||||
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">unbound</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Ok</span>(<span class="prelude-val">Some</span>(<span class="ident">err</span>)) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">take_error</span>() {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Got error: {:?}"</span>, <span class="ident">err</span>);
|
||||
}
|
||||
</pre></div>
|
||||
</div><h4 id="method.shutdown" class="method"><code>pub fn <a href="#method.shutdown" class="fnname">shutdown</a>(&self, how: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/enum.Shutdown.html" title="enum std::net::Shutdown">Shutdown</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1081-1083" title="goto source code">[src]</a></h4><div class="docblock"><p>Shuts down the read, write, or both halves of this connection.</p>
|
||||
<p>This function will cause all pending and future I/O calls on the
|
||||
specified portions to immediately return with an appropriate value
|
||||
(see the documentation of <code>Shutdown</code>).</p>
|
||||
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixDatagram</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">Shutdown</span>;
|
||||
|
||||
<span class="comment">// Create an unbound socket</span>
|
||||
<span class="kw">let</span> (<span class="ident">socket</span>, <span class="ident">other</span>) <span class="op">=</span> <span class="ident">UnixDatagram</span>::<span class="ident">pair</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">socket</span>.<span class="ident">shutdown</span>(<span class="ident">Shutdown</span>::<span class="ident">Both</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// NOTE: the following commented out code does NOT work as expected.</span>
|
||||
<span class="comment">// Due to an underlying issue, the recv call will block indefinitely.</span>
|
||||
<span class="comment">// See: https://github.com/tokio-rs/tokio/issues/1679</span>
|
||||
<span class="comment">//let mut buff = vec![0u8; 24];</span>
|
||||
<span class="comment">//let size = socket.recv(&mut buff).await?;</span>
|
||||
<span class="comment">//assert_eq!(size, 0);</span>
|
||||
|
||||
<span class="kw">let</span> <span class="ident">send_result</span> <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">send</span>(<span class="string">b"hello world"</span>).<span class="ident">await</span>;
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">send_result</span>.<span class="ident">is_err</span>());
|
||||
</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1104-1108" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1105-1107" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1098-1102" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1099-1101" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CUnixDatagram%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixDatagram.html" title="struct std::sys::unix::ext::net::UnixDatagram">UnixDatagram</a>> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-TryFrom%3CUnixDatagram%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1086-1096" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixDatagram.html" title="struct std::sys::unix::ext::net::UnixDatagram">UnixDatagram</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="../../src/tokio/net/unix/datagram/socket.rs.html#1093-1095" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the Tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.UnixDatagram.html#method.from_std"><code>UnixDatagram::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixDatagram.html" title="struct tokio::net::UnixDatagram">UnixDatagram</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
67
doc/tokio/net/struct.UnixListener.html
Normal file
67
doc/tokio/net/struct.UnixListener.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<!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="API documentation for the Rust `UnixListener` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, UnixListener"><title>tokio::net::UnixListener - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct UnixListener</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.accept">accept</a><a href="#method.bind">bind</a><a href="#method.from_std">from_std</a><a href="#method.local_addr">local_addr</a><a href="#method.poll_accept">poll_accept</a><a href="#method.take_error">take_error</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CUnixListener%3E">TryFrom<UnixListener></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "UnixListener", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#43-45" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">UnixListener</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct UnixListener { /* fields omitted */ }</pre></div><div class="docblock"><p>A Unix socket which can accept connections from other Unix sockets.</p>
|
||||
<p>You can accept a new connection by using the <a href="../../tokio/net/struct.UnixListener.html#method.accept"><code>accept</code></a> method.</p>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>Note that accepting a connection can lead to various errors and not all
|
||||
of them are necessarily fatal ‒ for example having too many open file
|
||||
descriptors or the other side closing the connection while it waits in
|
||||
an accept queue. These would terminate the stream if not handled in any
|
||||
way.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixListener</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">UnixListener</span>::<span class="ident">bind</span>(<span class="string">"/path/to/the/socket"</span>).<span class="ident">unwrap</span>();
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">match</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span> {
|
||||
<span class="prelude-val">Ok</span>((<span class="ident">stream</span>, <span class="ident">_addr</span>)) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"new client!"</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> { <span class="comment">/* connection failed */</span> }
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#48-122" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.bind" class="method"><code>pub fn <a href="#method.bind" class="fnname">bind</a><P>(path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#58-65" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new <code>UnixListener</code> bound to the specified path.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(listener: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixListener.html" title="struct std::sys::unix::ext::net::UnixListener">UnixListener</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a>></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#81-85" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>UnixListener</code> from a <code>std::os::unix::net::UnixListener </code>.</p>
|
||||
<p>This function is intended to be used to wrap a UnixListener from the
|
||||
standard library in the Tokio equivalent. The conversion assumes
|
||||
nothing about the underlying listener; it is left up to the user to set
|
||||
it in non-blocking mode.</p>
|
||||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#88-90" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the local socket address of this listener.</p>
|
||||
</div><h4 id="method.take_error" class="method"><code>pub fn <a href="#method.take_error" class="fnname">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#93-95" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the value of the <code>SO_ERROR</code> option.</p>
|
||||
</div><h4 id="method.accept" class="method"><code>pub async fn <a href="#method.accept" class="fnname">accept</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>, <a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#98-108" title="goto source code">[src]</a></h4><div class="docblock"><p>Accepts a new incoming connection to this listener.</p>
|
||||
</div><h4 id="method.poll_accept" class="method"><code>pub fn <a href="#method.poll_accept" class="fnname">poll_accept</a>(<br> &self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>, <a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>>></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#116-121" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls to accept a new incoming connection to this listener.</p>
|
||||
<p>If there is no connection to accept, <code>Poll::Pending</code> is returned and the
|
||||
current task will be notified by a waker. Note that on multiple calls
|
||||
to <code>poll_accept</code>, only the <code>Waker</code> from the <code>Context</code> passed to the most
|
||||
recent call is scheduled to receive a wakeup.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#142-146" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#143-145" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#136-140" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#137-139" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CUnixListener%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixListener.html" title="struct std::sys::unix::ext::net::UnixListener">UnixListener</a>> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-TryFrom%3CUnixListener%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#124-134" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixListener.html" title="struct std::sys::unix::ext::net::UnixListener">UnixListener</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><Self></code><a class="srclink" href="../../src/tokio/net/unix/listener.rs.html#131-133" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.UnixListener.html#method.from_std"><code>UnixListener::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixListener.html" title="struct tokio::net::UnixListener">UnixListener</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
344
doc/tokio/net/struct.UnixStream.html
Normal file
344
doc/tokio/net/struct.UnixStream.html
Normal file
@@ -0,0 +1,344 @@
|
||||
<!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="API documentation for the Rust `UnixStream` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, UnixStream"><title>tokio::net::UnixStream - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct UnixStream</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.connect">connect</a><a href="#method.from_std">from_std</a><a href="#method.into_split">into_split</a><a href="#method.local_addr">local_addr</a><a href="#method.pair">pair</a><a href="#method.peer_addr">peer_addr</a><a href="#method.peer_cred">peer_cred</a><a href="#method.poll_read_ready">poll_read_ready</a><a href="#method.poll_write_ready">poll_write_ready</a><a href="#method.readable">readable</a><a href="#method.ready">ready</a><a href="#method.split">split</a><a href="#method.take_error">take_error</a><a href="#method.try_read">try_read</a><a href="#method.try_write">try_write</a><a href="#method.writable">writable</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-AsRef%3CUnixStream%3E">AsRef<UnixStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a><a href="#impl-TryFrom%3CUnixStream%3E">TryFrom<UnixStream></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a></p><script>window.sidebarCurrent = {name: "UnixStream", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#31-33" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">net</a>::<wbr><a class="struct" href="">UnixStream</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct UnixStream { /* fields omitted */ }</pre></div><div class="docblock"><p>A structure representing a connected Unix socket.</p>
|
||||
<p>This socket can be connected directly with <code>UnixStream::connect</code> or accepted
|
||||
from a listener with <code>UnixListener::incoming</code>. Additionally, a pair of
|
||||
anonymous Unix sockets can be created with <code>UnixStream::pair</code>.</p>
|
||||
<p>To shut down the stream in the write direction, you can call the
|
||||
<a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> method. This will cause the other peer to receive a read of
|
||||
length 0, indicating that no more data will be sent. This only closes
|
||||
the stream in one direction.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#36-501" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.connect" class="method"><code>pub async fn <a href="#method.connect" class="fnname">connect</a><P>(path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> <span class="where fmt-newline">where<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>, </span></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#42-51" title="goto source code">[src]</a></h4><div class="docblock"><p>Connects to the socket named by <code>path</code>.</p>
|
||||
<p>This function will create a new Unix socket and connect to the path
|
||||
specified, associating the returned stream with the default event loop's
|
||||
handle.</p>
|
||||
</div><h4 id="method.ready" class="method"><code>pub async fn <a href="#method.ready" class="fnname">ready</a><'_>(&'_ self, interest: <a class="struct" href="../../tokio/io/struct.Interest.html" title="struct tokio::io::Interest">Interest</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/io/struct.Ready.html" title="struct tokio::io::Ready">Ready</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#115-118" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for any of the requested ready states.</p>
|
||||
<p>This function is usually paired with <code>try_read()</code> or <code>try_write()</code>. It
|
||||
can be used to concurrently read / write to the same socket on a single
|
||||
task without splitting the socket.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Concurrently read and write to the stream on the same task without
|
||||
splitting.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">Interest</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">bind_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"bind_path"</span>);
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">UnixStream</span>::<span class="ident">connect</span>(<span class="ident">bind_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">ready</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">ready</span>(<span class="ident">Interest</span>::<span class="ident">READABLE</span> <span class="op">|</span> <span class="ident">Interest</span>::<span class="ident">WRITABLE</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_readable</span>() {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">1024</span>];
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">data</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"read {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<span class="kw">if</span> <span class="ident">ready</span>.<span class="ident">is_writable</span>() {
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"write {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.readable" class="method"><code>pub async fn <a href="#method.readable" class="fnname">readable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#165-168" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become readable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::READABLE)</code> and is usually
|
||||
paired with <code>try_read()</code>.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">bind_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"bind_path"</span>);
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">UnixStream</span>::<span class="ident">connect</span>(<span class="ident">bind_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">msg</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">msg</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="ident">msg</span>.<span class="ident">truncate</span>(<span class="ident">n</span>);
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"GOT = {:?}"</span>, <span class="ident">msg</span>);
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_read_ready" class="method"><code>pub fn <a href="#method.poll_read_ready" class="fnname">poll_read_ready</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#199-201" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for read readiness.</p>
|
||||
<p>If the unix stream is not currently ready for reading, this method will
|
||||
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the unix
|
||||
stream becomes ready for reading, <code>Waker::wake</code> will be called on the
|
||||
waker.</p>
|
||||
<p>Note that on multiple calls to <code>poll_read_ready</code> or <code>poll_read</code>, only
|
||||
the <code>Waker</code> from the <code>Context</code> passed to the most recent call is
|
||||
scheduled to receive a wakeup. (However, <code>poll_write_ready</code> retains a
|
||||
second, independent waker.)</p>
|
||||
<p>This function is intended for cases where creating and pinning a future
|
||||
via <a href="../../tokio/net/struct.UnixStream.html#method.readable"><code>readable</code></a> is not feasible. Where possible, using <a href="../../tokio/net/struct.UnixStream.html#method.readable"><code>readable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<h1 id="return-value" class="section-header"><a href="#return-value">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the unix stream is not ready for reading.</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> if the unix stream is ready for reading.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_read" class="method"><code>pub fn <a href="#method.try_read" class="fnname">try_read</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#264-268" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to read data from the stream into the provided buffer, returning how
|
||||
many bytes were read.</p>
|
||||
<p>Receives any pending data from the socket but does not wait for new data
|
||||
to arrive. On success, returns the number of bytes read. Because
|
||||
<code>try_read()</code> is non-blocking, the buffer does not have to be stored by
|
||||
the async task and can exist entirely on the stack.</p>
|
||||
<p>Usually, <a href="../../tokio/net/struct.UnixStream.html#method.readable"><code>readable()</code></a> or <a href="../../tokio/net/struct.UnixStream.html#method.ready"><code>ready()</code></a> is used with this function.</p>
|
||||
<h1 id="return" class="section-header"><a href="#return">Return</a></h1>
|
||||
<p>If data is successfully read, <code>Ok(n)</code> is returned, where <code>n</code> is the
|
||||
number of bytes read. <code>Ok(0)</code> indicates the stream's read half is closed
|
||||
and will no longer yield data. If the stream is not ready to read data
|
||||
<code>Err(io::ErrorKind::WouldBlock)</code> is returned.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">bind_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"bind_path"</span>);
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">UnixStream</span>::<span class="ident">connect</span>(<span class="ident">bind_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be readable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">readable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Creating the buffer **after** the `await` prevents it from</span>
|
||||
<span class="comment">// being stored in the async task.</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4096</span>];
|
||||
|
||||
<span class="comment">// Try to read data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="number">0</span>) <span class="op">=</span><span class="op">></span> <span class="kw">break</span>,
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"read {} bytes"</span>, <span class="ident">n</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.writable" class="method"><code>pub async fn <a href="#method.writable" class="fnname">writable</a><'_>(&'_ self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#311-314" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for the socket to become writable.</p>
|
||||
<p>This function is equivalent to <code>ready(Interest::WRITABLE)</code> and is usually
|
||||
paired with <code>try_write()</code>.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">bind_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"bind_path"</span>);
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">UnixStream</span>::<span class="ident">connect</span>(<span class="ident">bind_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.poll_write_ready" class="method"><code>pub fn <a href="#method.poll_write_ready" class="fnname">poll_write_ready</a>(&self, cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#345-347" title="goto source code">[src]</a></h4><div class="docblock"><p>Polls for write readiness.</p>
|
||||
<p>If the unix stream is not currently ready for writing, this method will
|
||||
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the unix
|
||||
stream becomes ready for writing, <code>Waker::wake</code> will be called on the
|
||||
waker.</p>
|
||||
<p>Note that on multiple calls to <code>poll_write_ready</code> or <code>poll_write</code>, only
|
||||
the <code>Waker</code> from the <code>Context</code> passed to the most recent call is
|
||||
scheduled to receive a wakeup. (However, <code>poll_read_ready</code> retains a
|
||||
second, independent waker.)</p>
|
||||
<p>This function is intended for cases where creating and pinning a future
|
||||
via <a href="../../tokio/net/struct.UnixStream.html#method.writable"><code>writable</code></a> is not feasible. Where possible, using <a href="../../tokio/net/struct.UnixStream.html#method.writable"><code>writable</code></a> is
|
||||
preferred, as this supports polling from multiple tasks at once.</p>
|
||||
<h1 id="return-value-1" class="section-header"><a href="#return-value-1">Return value</a></h1>
|
||||
<p>The function returns:</p>
|
||||
<ul>
|
||||
<li><code>Poll::Pending</code> if the unix stream is not ready for writing.</li>
|
||||
<li><code>Poll::Ready(Ok(()))</code> if the unix stream is ready for writing.</li>
|
||||
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
|
||||
</ul>
|
||||
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
|
||||
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
||||
</div><h4 id="method.try_write" class="method"><code>pub fn <a href="#method.try_write" class="fnname">try_write</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#399-403" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to write a buffer to the stream, returning how many bytes were
|
||||
written.</p>
|
||||
<p>The function will attempt to write the entire contents of <code>buf</code>, but
|
||||
only part of the buffer may be written.</p>
|
||||
<p>This function is usually paired with <code>writable()</code>.</p>
|
||||
<h1 id="return-1" class="section-header"><a href="#return-1">Return</a></h1>
|
||||
<p>If data is successfully written, <code>Ok(n)</code> is returned, where <code>n</code> is the
|
||||
number of bytes written. If the stream is not ready to write data,
|
||||
<code>Err(io::ErrorKind::WouldBlock)</code> is returned.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">UnixStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">dir</span> <span class="op">=</span> <span class="ident">tempfile</span>::<span class="ident">tempdir</span>().<span class="ident">unwrap</span>();
|
||||
<span class="kw">let</span> <span class="ident">bind_path</span> <span class="op">=</span> <span class="ident">dir</span>.<span class="ident">path</span>().<span class="ident">join</span>(<span class="string">"bind_path"</span>);
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">UnixStream</span>::<span class="ident">connect</span>(<span class="ident">bind_path</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="comment">// Wait for the socket to be writable</span>
|
||||
<span class="ident">stream</span>.<span class="ident">writable</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Try to write data, this may still fail with `WouldBlock`</span>
|
||||
<span class="comment">// if the readiness event is a false positive.</span>
|
||||
<span class="kw">match</span> <span class="ident">stream</span>.<span class="ident">try_write</span>(<span class="string">b"hello world"</span>) {
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">break</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="kw-2">ref</span> <span class="ident">e</span>) <span class="kw">if</span> <span class="ident">e</span>.<span class="ident">kind</span>() <span class="op">=</span><span class="op">=</span> <span class="ident">io</span>::<span class="ident">ErrorKind</span>::<span class="ident">WouldBlock</span> <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>.<span class="ident">into</span>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixStream.html" title="struct std::sys::unix::ext::net::UnixStream">UnixStream</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#419-424" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates new <code>UnixStream</code> from a <code>std::os::unix::net::UnixStream</code>.</p>
|
||||
<p>This function is intended to be used to wrap a UnixStream from the
|
||||
standard library in the Tokio equivalent. The conversion assumes
|
||||
nothing about the underlying stream; it is left up to the user to set
|
||||
it in non-blocking mode.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if thread-local runtime is not set.</p>
|
||||
<p>The runtime is usually set implicitly when this function is called
|
||||
from a future driven by a tokio runtime, otherwise runtime can be set
|
||||
explicitly with <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> function.</p>
|
||||
</div><h4 id="method.pair" class="method"><code>pub fn <a href="#method.pair" class="fnname">pair</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>, <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#431-437" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates an unnamed pair of connected sockets.</p>
|
||||
<p>This function will create a pair of interconnected Unix sockets for
|
||||
communicating back and forth between one another. Each socket will
|
||||
be associated with the default event loop's handle.</p>
|
||||
</div><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#445-447" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the socket address of the local half of this connection.</p>
|
||||
</div><h4 id="method.peer_addr" class="method"><code>pub fn <a href="#method.peer_addr" class="fnname">peer_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#450-452" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the socket address of the remote half of this connection.</p>
|
||||
</div><h4 id="method.peer_cred" class="method"><code>pub fn <a href="#method.peer_cred" class="fnname">peer_cred</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#455-457" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns effective credentials of the process which called <code>connect</code> or <code>pair</code>.</p>
|
||||
</div><h4 id="method.take_error" class="method"><code>pub fn <a href="#method.take_error" class="fnname">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#460-462" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the value of the <code>SO_ERROR</code> option.</p>
|
||||
</div><h4 id="method.split" class="method"><code>pub fn <a href="#method.split" class="fnname">split</a><'a>(&'a mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a>, <a class="struct" href="../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#483-485" title="goto source code">[src]</a></h4><div class="docblock"><p>Split a <code>UnixStream</code> into a read half and a write half, which can be used
|
||||
to read and write the stream concurrently.</p>
|
||||
<p>This method is more efficient than <a href="../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>, but the halves cannot be
|
||||
moved into independently spawned tasks.</p>
|
||||
</div><h4 id="method.into_split" class="method"><code>pub fn <a href="#method.into_split" class="fnname">into_split</a>(self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a>, <a class="struct" href="../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#498-500" title="goto source code">[src]</a></h4><div class="docblock"><p>Splits a <code>UnixStream</code> into a read half and a write half, which can be used
|
||||
to read and write the stream concurrently.</p>
|
||||
<p>Unlike <a href="../../tokio/net/struct.UnixStream.html#method.split"><code>split</code></a>, the owned halves can be moved to separate tasks, however
|
||||
this comes at the cost of a heap allocation.</p>
|
||||
<p><strong>Note:</strong> Dropping the write half will shut down the write half of the
|
||||
stream. This is equivalent to calling <a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> on the <code>UnixStream</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#600-604" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#601-603" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
|
||||
</div></div><h3 id="impl-AsRef%3CUnixStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsRef%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/split.rs.html#90-94" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../src/tokio/net/unix/split.rs.html#91-93" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CUnixStream%3E-1" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsRef%3CUnixStream%3E-1" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/split.rs.html#96-100" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../src/tokio/net/unix/split.rs.html#97-99" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CUnixStream%3E-2" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsRef%3CUnixStream%3E-2" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/split_owned.rs.html#181-185" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../src/tokio/net/unix/split_owned.rs.html#182-184" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsRef%3CUnixStream%3E-3" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsRef%3CUnixStream%3E-3" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/split_owned.rs.html#187-191" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref-3" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../src/tokio/net/unix/split_owned.rs.html#188-190" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#515-523" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#516-522" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#525-554" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#526-532" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#534-540" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#542-544" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#546-548" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#550-553" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#594-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CUnixStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixStream.html" title="struct std::sys::unix::ext::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-TryFrom%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#503-513" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(stream: <a class="struct" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.UnixStream.html" title="struct std::sys::unix::ext::net::UnixStream">UnixStream</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><Self></code><a class="srclink" href="../../src/tokio/net/unix/stream.rs.html#510-512" title="goto source code">[src]</a></h4><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
||||
<p>This is equivalent to
|
||||
<a href="../../tokio/net/struct.UnixStream.html#method.from_std"><code>UnixStream::from_std(stream)</code></a>.</p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
12
doc/tokio/net/tcp/index.html
Normal file
12
doc/tokio/net/tcp/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!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="API documentation for the Rust `tcp` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, tcp"><title>tokio::net::tcp - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module tcp</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a></p><script>window.sidebarCurrent = {name: "tcp", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/mod.rs.html#1-14" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a class="mod" href="">tcp</a></span></h1><div class="docblock"><p>TCP utility types</p>
|
||||
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.OwnedReadHalf.html" title="tokio::net::tcp::OwnedReadHalf struct">OwnedReadHalf</a></td><td class="docblock-short"><p>Owned read half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.OwnedWriteHalf.html" title="tokio::net::tcp::OwnedWriteHalf struct">OwnedWriteHalf</a></td><td class="docblock-short"><p>Owned write half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ReadHalf.html" title="tokio::net::tcp::ReadHalf struct">ReadHalf</a></td><td class="docblock-short"><p>Borrowed read half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.split"><code>split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ReuniteError.html" title="tokio::net::tcp::ReuniteError struct">ReuniteError</a></td><td class="docblock-short"><p>Error indicating that two halves were not from the same socket, and thus could
|
||||
not be reunited.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.WriteHalf.html" title="tokio::net::tcp::WriteHalf struct">WriteHalf</a></td><td class="docblock-short"><p>Borrowed write half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.split"><code>split</code></a>.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/net/tcp/listener/struct.TcpListener.html
Normal file
10
doc/tokio/net/tcp/listener/struct.TcpListener.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/struct.TcpListener.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/struct.TcpListener.html">../../../../tokio/net/struct.TcpListener.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/struct.TcpListener.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
doc/tokio/net/tcp/sidebar-items.js
Normal file
1
doc/tokio/net/tcp/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["OwnedReadHalf","Owned read half of a `TcpStream`, created by `into_split`."],["OwnedWriteHalf","Owned write half of a `TcpStream`, created by `into_split`."],["ReadHalf","Borrowed read half of a `TcpStream`, created by `split`."],["ReuniteError","Error indicating that two halves were not from the same socket, and thus could not be reunited."],["WriteHalf","Borrowed write half of a `TcpStream`, created by `split`."]]});
|
||||
10
doc/tokio/net/tcp/socket/struct.TcpSocket.html
Normal file
10
doc/tokio/net/tcp/socket/struct.TcpSocket.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/struct.TcpSocket.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/struct.TcpSocket.html">../../../../tokio/net/struct.TcpSocket.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/struct.TcpSocket.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/split/struct.ReadHalf.html
Normal file
10
doc/tokio/net/tcp/split/struct.ReadHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/tcp/struct.ReadHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/tcp/struct.ReadHalf.html">../../../../tokio/net/tcp/struct.ReadHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/tcp/struct.ReadHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/split/struct.WriteHalf.html
Normal file
10
doc/tokio/net/tcp/split/struct.WriteHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/tcp/struct.WriteHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/tcp/struct.WriteHalf.html">../../../../tokio/net/tcp/struct.WriteHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/tcp/struct.WriteHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/split_owned/struct.OwnedReadHalf.html
Normal file
10
doc/tokio/net/tcp/split_owned/struct.OwnedReadHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/tcp/struct.OwnedReadHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/tcp/struct.OwnedReadHalf.html">../../../../tokio/net/tcp/struct.OwnedReadHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/tcp/struct.OwnedReadHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/split_owned/struct.OwnedWriteHalf.html
Normal file
10
doc/tokio/net/tcp/split_owned/struct.OwnedWriteHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/tcp/struct.OwnedWriteHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/tcp/struct.OwnedWriteHalf.html">../../../../tokio/net/tcp/struct.OwnedWriteHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/tcp/struct.OwnedWriteHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/split_owned/struct.ReuniteError.html
Normal file
10
doc/tokio/net/tcp/split_owned/struct.ReuniteError.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/tcp/struct.ReuniteError.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/tcp/struct.ReuniteError.html">../../../../tokio/net/tcp/struct.ReuniteError.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/tcp/struct.ReuniteError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/tcp/stream/struct.TcpStream.html
Normal file
10
doc/tokio/net/tcp/stream/struct.TcpStream.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/struct.TcpStream.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/struct.TcpStream.html">../../../../tokio/net/struct.TcpStream.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/struct.TcpStream.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
78
doc/tokio/net/tcp/struct.OwnedReadHalf.html
Normal file
78
doc/tokio/net/tcp/struct.OwnedReadHalf.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<!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="API documentation for the Rust `OwnedReadHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, OwnedReadHalf"><title>tokio::net::tcp::OwnedReadHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct OwnedReadHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.peek">peek</a><a href="#method.poll_peek">poll_peek</a><a href="#method.reunite">reunite</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CTcpStream%3E">AsRef<TcpStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a></p><script>window.sidebarCurrent = {name: "OwnedReadHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#31-33" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a>::<wbr><a class="struct" href="">OwnedReadHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct OwnedReadHalf { /* fields omitted */ }</pre></div><div class="docblock"><p>Owned read half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
<p>Reading from an <code>OwnedReadHalf</code> is usually done using the convenience methods found
|
||||
on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#97-192" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.reunite" class="method"><code>pub fn <a href="#method.reunite" class="fnname">reunite</a>(self, other: <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>, <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#103-105" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to put the two halves of a <code>TcpStream</code> back together and
|
||||
recover the original socket. Succeeds only if the two halves
|
||||
originated from the same call to <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</div><h4 id="method.poll_peek" class="method"><code>pub fn <a href="#method.poll_peek" class="fnname">poll_peek</a>(<br> &mut self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#141-147" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempt to receive data on the socket, without removing that data from
|
||||
the queue, registering the current task for wakeup if data is not yet
|
||||
available.</p>
|
||||
<p>Note that on multiple calls to <code>poll_peek</code> or <code>poll_read</code>, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call is scheduled
|
||||
to receive a wakeup.</p>
|
||||
<p>See the <a href="../../../tokio/net/struct.TcpStream.html#method.poll_peek"><code>TcpStream::poll_peek</code></a> level documenation for more details.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">ReadBuf</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">poll_fn</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8000"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">read_half</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">into_split</span>();
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">ReadBuf</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>);
|
||||
|
||||
<span class="ident">poll_fn</span>(<span class="op">|</span><span class="ident">cx</span><span class="op">|</span> {
|
||||
<span class="ident">read_half</span>.<span class="ident">poll_peek</span>(<span class="ident">cx</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>)
|
||||
}).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.peek" class="method"><code>pub async fn <a href="#method.peek" class="fnname">peek</a><'_, '_>(&'_ mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#188-191" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||||
connected, without removing that data from the queue. On success,
|
||||
returns the number of bytes peeked.</p>
|
||||
<p>See the <a href="../../../tokio/net/struct.TcpStream.html#method.peek"><code>TcpStream::peek</code></a> level documenation for more details.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncReadExt</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">read_half</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">into_split</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b1</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b2</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
|
||||
<span class="comment">// Peek at the data</span>
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">read_half</span>.<span class="ident">peek</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b1</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Read the data</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">n</span>, <span class="ident">read_half</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b2</span>[..<span class="ident">n</span>]).<span class="ident">await</span><span class="question-mark">?</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">b1</span>[..<span class="ident">n</span>], <span class="kw-2">&</span><span class="ident">b2</span>[..<span class="ident">n</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>The <a href="fn@crate::io::AsyncReadExt::read"><code>read</code></a> method is defined on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CTcpStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsRef%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#268-272" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#269-271" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl <a class="trait" href="../../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#194-202" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#195-201" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#30" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#30" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
36
doc/tokio/net/tcp/struct.OwnedWriteHalf.html
Normal file
36
doc/tokio/net/tcp/struct.OwnedWriteHalf.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!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="API documentation for the Rust `OwnedWriteHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, OwnedWriteHalf"><title>tokio::net::tcp::OwnedWriteHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct OwnedWriteHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.forget">forget</a><a href="#method.reunite">reunite</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CTcpStream%3E">AsRef<TcpStream></a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a><a href="#impl-Drop">Drop</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a></p><script>window.sidebarCurrent = {name: "OwnedWriteHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#50-53" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a>::<wbr><a class="struct" href="">OwnedWriteHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct OwnedWriteHalf { /* fields omitted */ }</pre></div><div class="docblock"><p>Owned write half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
<p>Note that in the <a href="../../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> implementation of this type, <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown"><code>poll_shutdown</code></a> will
|
||||
shut down the TCP stream in the write direction. Dropping the write half
|
||||
will also shut down the write half of the TCP stream.</p>
|
||||
<p>Writing to an <code>OwnedWriteHalf</code> is usually done using the convenience methods found
|
||||
on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#204-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.reunite" class="method"><code>pub fn <a href="#method.reunite" class="fnname">reunite</a>(self, other: <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>, <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#210-212" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to put the two halves of a <code>TcpStream</code> back together and
|
||||
recover the original socket. Succeeds only if the two halves
|
||||
originated from the same call to <a href="../../../tokio/net/struct.TcpStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</div><h4 id="method.forget" class="method"><code>pub fn <a href="#method.forget" class="fnname">forget</a>(self)</code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#217-220" title="goto source code">[src]</a></h4><div class="docblock"><p>Destroy the write half, but don't close the write half of the stream
|
||||
until the read half is dropped. If the read half has already been
|
||||
dropped, this closes the stream.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CTcpStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsRef%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#274-278" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#275-277" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl <a class="trait" href="../../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#231-266" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#232-238" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#240-246" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#248-250" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#253-256" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#259-265" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#49" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#49" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Drop" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Drop" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#223-229" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.drop" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#224-228" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
75
doc/tokio/net/tcp/struct.ReadHalf.html
Normal file
75
doc/tokio/net/tcp/struct.ReadHalf.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!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="API documentation for the Rust `ReadHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, ReadHalf"><title>tokio::net::tcp::ReadHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct ReadHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.peek">peek</a><a href="#method.poll_peek">poll_peek</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CTcpStream%3E">AsRef<TcpStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a></p><script>window.sidebarCurrent = {name: "ReadHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#29" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a>::<wbr><a class="struct" href="">ReadHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ReadHalf<'a>(_);</pre></div><div class="docblock"><p>Borrowed read half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.split"><code>split</code></a>.</p>
|
||||
<p>Reading from a <code>ReadHalf</code> is usually done using the convenience methods found on the
|
||||
<a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<'_> <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'_></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#51-137" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_peek" class="method"><code>pub fn <a href="#method.poll_peek" class="fnname">poll_peek</a>(<br> &mut self, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#86-92" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempt to receive data on the socket, without removing that data from
|
||||
the queue, registering the current task for wakeup if data is not yet
|
||||
available.</p>
|
||||
<p>Note that on multiple calls to <code>poll_peek</code> or <code>poll_read</code>, only the
|
||||
<code>Waker</code> from the <code>Context</code> passed to the most recent call is scheduled
|
||||
to receive a wakeup.</p>
|
||||
<p>See the <a href="../../../tokio/net/struct.TcpStream.html#method.poll_peek"><code>TcpStream::poll_peek</code></a> level documenation for more details.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">ReadBuf</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">poll_fn</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8000"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">read_half</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">split</span>();
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">ReadBuf</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>);
|
||||
|
||||
<span class="ident">poll_fn</span>(<span class="op">|</span><span class="ident">cx</span><span class="op">|</span> {
|
||||
<span class="ident">read_half</span>.<span class="ident">poll_peek</span>(<span class="ident">cx</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>)
|
||||
}).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
</div><h4 id="method.peek" class="method"><code>pub async fn <a href="#method.peek" class="fnname">peek</a><'_, '_>(&'_ mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'_ mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#133-136" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||||
connected, without removing that data from the queue. On success,
|
||||
returns the number of bytes peeked.</p>
|
||||
<p>See the <a href="../../../tokio/net/struct.TcpStream.html#method.peek"><code>TcpStream::peek</code></a> level documenation for more details.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncReadExt</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span>;
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Connect to a peer</span>
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">read_half</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">split</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b1</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b2</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||||
|
||||
<span class="comment">// Peek at the data</span>
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="ident">read_half</span>.<span class="ident">peek</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b1</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Read the data</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">n</span>, <span class="ident">read_half</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b2</span>[..<span class="ident">n</span>]).<span class="ident">await</span><span class="question-mark">?</span>);
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">b1</span>[..<span class="ident">n</span>], <span class="kw-2">&</span><span class="ident">b2</span>[..<span class="ident">n</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</pre></div>
|
||||
<p>The <a href="fn@crate::io::AsyncReadExt::read"><code>read</code></a> method is defined on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CTcpStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsRef%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#182-186" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#183-185" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl<'_> <a class="trait" href="../../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#139-147" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#140-146" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#28" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#28" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReadHalf.html" title="struct tokio::net::tcp::ReadHalf">ReadHalf</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
22
doc/tokio/net/tcp/struct.ReuniteError.html
Normal file
22
doc/tokio/net/tcp/struct.ReuniteError.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!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="API documentation for the Rust `ReuniteError` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, ReuniteError"><title>tokio::net::tcp::ReuniteError - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct ReuniteError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a></p><script>window.sidebarCurrent = {name: "ReuniteError", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#84" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a>::<wbr><a class="struct" href="">ReuniteError</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ReuniteError(pub <a class="struct" href="../../../tokio/net/tcp/struct.OwnedReadHalf.html" title="struct tokio::net::tcp::OwnedReadHalf">OwnedReadHalf</a>, pub <a class="struct" href="../../../tokio/net/tcp/struct.OwnedWriteHalf.html" title="struct tokio::net::tcp::OwnedWriteHalf">OwnedWriteHalf</a>);</pre></div><div class="docblock"><p>Error indicating that two halves were not from the same socket, and thus could
|
||||
not be reunited.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#83" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#83" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#86-93" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#87-92" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split_owned.rs.html#95" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)></code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#100-102" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
|
||||
</div><h4 id="method.backtrace" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#128-130" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
|
||||
</div><h4 id="method.description" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#140-142" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
|
||||
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#150-152" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
|
||||
</div></div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.ReuniteError.html" title="struct tokio::net::tcp::ReuniteError">ReuniteError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToString" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-ToString" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2194-2207" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.to_string" class="method hidden"><code>pub default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2200-2206" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
28
doc/tokio/net/tcp/struct.WriteHalf.html
Normal file
28
doc/tokio/net/tcp/struct.WriteHalf.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!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="API documentation for the Rust `WriteHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, WriteHalf"><title>tokio::net::tcp::WriteHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct WriteHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CTcpStream%3E">AsRef<TcpStream></a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a></p><script>window.sidebarCurrent = {name: "WriteHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#45" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">tcp</a>::<wbr><a class="struct" href="">WriteHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct WriteHalf<'a>(_);</pre></div><div class="docblock"><p>Borrowed write half of a <a href="../../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>, created by <a href="../../../tokio/net/struct.TcpStream.html#method.split"><code>split</code></a>.</p>
|
||||
<p>Note that in the <a href="../../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> implemenation of this type, <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown"><code>poll_shutdown</code></a> will
|
||||
shut down the TCP stream in the write direction.</p>
|
||||
<p>Writing to an <code>WriteHalf</code> is usually done using the convenience methods found
|
||||
on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CTcpStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a>> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsRef%3CTcpStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#188-192" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.TcpStream.html" title="struct tokio::net::TcpStream">TcpStream</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#189-191" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl<'_> <a class="trait" href="../../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#149-180" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#150-156" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#158-164" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#166-168" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#171-174" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#177-179" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#44" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/tcp/split.rs.html#44" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/tcp/struct.WriteHalf.html" title="struct tokio::net::tcp::WriteHalf">WriteHalf</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
15
doc/tokio/net/trait.ToSocketAddrs.html
Normal file
15
doc/tokio/net/trait.ToSocketAddrs.html
Normal file
File diff suppressed because one or more lines are too long
10
doc/tokio/net/udp/struct.UdpSocket.html
Normal file
10
doc/tokio/net/udp/struct.UdpSocket.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/net/struct.UdpSocket.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/net/struct.UdpSocket.html">../../../tokio/net/struct.UdpSocket.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/net/struct.UdpSocket.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
5
doc/tokio/net/unix/datagram/index.html
Normal file
5
doc/tokio/net/unix/datagram/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `datagram` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, datagram"><title>tokio::net::unix::datagram - Rust</title><link rel="stylesheet" type="text/css" href="../../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class="location">Module datagram</p><div class="sidebar-elems"><p class="location"><a href="../../../index.html">tokio</a>::<wbr><a href="../../index.html">net</a>::<wbr><a href="../index.html">unix</a></p><script>window.sidebarCurrent = {name: "datagram", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../../settings.html"><img src="../../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../../src/tokio/net/unix/datagram/mod.rs.html#1-3" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../../../index.html">tokio</a>::<wbr><a href="../../index.html">net</a>::<wbr><a href="../index.html">unix</a>::<wbr><a class="mod" href="">datagram</a></span></h1><div class="docblock"><p>Unix datagram types.</p>
|
||||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../../";window.currentCrate = "tokio";</script><script src="../../../../main.js"></script><script defer src="../../../../search-index.js"></script></body></html>
|
||||
1
doc/tokio/net/unix/datagram/sidebar-items.js
Normal file
1
doc/tokio/net/unix/datagram/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({});
|
||||
10
doc/tokio/net/unix/datagram/socket/struct.UnixDatagram.html
Normal file
10
doc/tokio/net/unix/datagram/socket/struct.UnixDatagram.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../../tokio/net/struct.UnixDatagram.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../../tokio/net/struct.UnixDatagram.html">../../../../../tokio/net/struct.UnixDatagram.html</a>...</p>
|
||||
<script>location.replace("../../../../../tokio/net/struct.UnixDatagram.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
16
doc/tokio/net/unix/index.html
Normal file
16
doc/tokio/net/unix/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!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="API documentation for the Rust `unix` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, unix"><title>tokio::net::unix - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Module unix</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a></p><script>window.sidebarCurrent = {name: "unix", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/mod.rs.html#1-20" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a class="mod" href="">unix</a></span></h1><div class="docblock"><p>Unix domain socket utility types</p>
|
||||
</div><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||||
<table><tr class="module-item"><td><a class="mod" href="datagram/index.html" title="tokio::net::unix::datagram mod">datagram</a></td><td class="docblock-short"><p>Unix datagram types.</p>
|
||||
</td></tr></table><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.OwnedReadHalf.html" title="tokio::net::unix::OwnedReadHalf struct">OwnedReadHalf</a></td><td class="docblock-short"><p>Owned read half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.OwnedWriteHalf.html" title="tokio::net::unix::OwnedWriteHalf struct">OwnedWriteHalf</a></td><td class="docblock-short"><p>Owned write half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ReadHalf.html" title="tokio::net::unix::ReadHalf struct">ReadHalf</a></td><td class="docblock-short"><p>Borrowed read half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.split"><code>split</code></a>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ReuniteError.html" title="tokio::net::unix::ReuniteError struct">ReuniteError</a></td><td class="docblock-short"><p>Error indicating that two halves were not from the same socket, and thus could
|
||||
not be reunited.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.SocketAddr.html" title="tokio::net::unix::SocketAddr struct">SocketAddr</a></td><td class="docblock-short"><p>An address associated with a Tokio Unix socket.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.UCred.html" title="tokio::net::unix::UCred struct">UCred</a></td><td class="docblock-short"><p>Credentials of a process</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.WriteHalf.html" title="tokio::net::unix::WriteHalf struct">WriteHalf</a></td><td class="docblock-short"><p>Borrowed write half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.split"><code>split</code></a>.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/net/unix/listener/struct.UnixListener.html
Normal file
10
doc/tokio/net/unix/listener/struct.UnixListener.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/struct.UnixListener.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/struct.UnixListener.html">../../../../tokio/net/struct.UnixListener.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/struct.UnixListener.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
doc/tokio/net/unix/sidebar-items.js
Normal file
1
doc/tokio/net/unix/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"mod":[["datagram","Unix datagram types."]],"struct":[["OwnedReadHalf","Owned read half of a `UnixStream`, created by `into_split`."],["OwnedWriteHalf","Owned write half of a `UnixStream`, created by `into_split`."],["ReadHalf","Borrowed read half of a `UnixStream`, created by `split`."],["ReuniteError","Error indicating that two halves were not from the same socket, and thus could not be reunited."],["SocketAddr","An address associated with a Tokio Unix socket."],["UCred","Credentials of a process"],["WriteHalf","Borrowed write half of a `UnixStream`, created by `split`."]]});
|
||||
10
doc/tokio/net/unix/socketaddr/struct.SocketAddr.html
Normal file
10
doc/tokio/net/unix/socketaddr/struct.SocketAddr.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.SocketAddr.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.SocketAddr.html">../../../../tokio/net/unix/struct.SocketAddr.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.SocketAddr.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/split/struct.ReadHalf.html
Normal file
10
doc/tokio/net/unix/split/struct.ReadHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.ReadHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.ReadHalf.html">../../../../tokio/net/unix/struct.ReadHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.ReadHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/split/struct.WriteHalf.html
Normal file
10
doc/tokio/net/unix/split/struct.WriteHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.WriteHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.WriteHalf.html">../../../../tokio/net/unix/struct.WriteHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.WriteHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/split_owned/struct.OwnedReadHalf.html
Normal file
10
doc/tokio/net/unix/split_owned/struct.OwnedReadHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.OwnedReadHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.OwnedReadHalf.html">../../../../tokio/net/unix/struct.OwnedReadHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.OwnedReadHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/split_owned/struct.OwnedWriteHalf.html
Normal file
10
doc/tokio/net/unix/split_owned/struct.OwnedWriteHalf.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.OwnedWriteHalf.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.OwnedWriteHalf.html">../../../../tokio/net/unix/struct.OwnedWriteHalf.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.OwnedWriteHalf.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/split_owned/struct.ReuniteError.html
Normal file
10
doc/tokio/net/unix/split_owned/struct.ReuniteError.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.ReuniteError.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.ReuniteError.html">../../../../tokio/net/unix/struct.ReuniteError.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.ReuniteError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/net/unix/stream/struct.UnixStream.html
Normal file
10
doc/tokio/net/unix/stream/struct.UnixStream.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/struct.UnixStream.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/struct.UnixStream.html">../../../../tokio/net/struct.UnixStream.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/struct.UnixStream.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
22
doc/tokio/net/unix/struct.OwnedReadHalf.html
Normal file
22
doc/tokio/net/unix/struct.OwnedReadHalf.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!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="API documentation for the Rust `OwnedReadHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, OwnedReadHalf"><title>tokio::net::unix::OwnedReadHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct OwnedReadHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.reunite">reunite</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CUnixStream%3E">AsRef<UnixStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "OwnedReadHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#30-32" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">OwnedReadHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct OwnedReadHalf { /* fields omitted */ }</pre></div><div class="docblock"><p>Owned read half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
<p>Reading from an <code>OwnedReadHalf</code> is usually done using the convenience methods found
|
||||
on the <a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#96-105" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.reunite" class="method"><code>pub fn <a href="#method.reunite" class="fnname">reunite</a>(self, other: <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>, <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#102-104" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to put the two halves of a <code>UnixStream</code> back together and
|
||||
recover the original socket. Succeeds only if the two halves
|
||||
originated from the same call to <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CUnixStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsRef%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#181-185" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#182-184" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl <a class="trait" href="../../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#107-115" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#108-114" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#29" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#29" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
36
doc/tokio/net/unix/struct.OwnedWriteHalf.html
Normal file
36
doc/tokio/net/unix/struct.OwnedWriteHalf.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!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="API documentation for the Rust `OwnedWriteHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, OwnedWriteHalf"><title>tokio::net::unix::OwnedWriteHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct OwnedWriteHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.forget">forget</a><a href="#method.reunite">reunite</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CUnixStream%3E">AsRef<UnixStream></a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a><a href="#impl-Drop">Drop</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "OwnedWriteHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#49-52" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">OwnedWriteHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct OwnedWriteHalf { /* fields omitted */ }</pre></div><div class="docblock"><p>Owned write half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
<p>Note that in the <a href="../../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> implementation of this type,
|
||||
<a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown"><code>poll_shutdown</code></a> will shut down the stream in the write direction.
|
||||
Dropping the write half will also shut down the write half of the stream.</p>
|
||||
<p>Writing to an <code>OwnedWriteHalf</code> is usually done using the convenience methods
|
||||
found on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#117-134" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.reunite" class="method"><code>pub fn <a href="#method.reunite" class="fnname">reunite</a>(self, other: <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>, <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#123-125" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to put the two halves of a <code>UnixStream</code> back together and
|
||||
recover the original socket. Succeeds only if the two halves
|
||||
originated from the same call to <a href="../../../tokio/net/struct.UnixStream.html#method.into_split"><code>into_split</code></a>.</p>
|
||||
</div><h4 id="method.forget" class="method"><code>pub fn <a href="#method.forget" class="fnname">forget</a>(self)</code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#130-133" title="goto source code">[src]</a></h4><div class="docblock"><p>Destroy the write half, but don't close the write half of the stream
|
||||
until the read half is dropped. If the read half has already been
|
||||
dropped, this closes the stream.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CUnixStream%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsRef%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#187-191" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#188-190" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl <a class="trait" href="../../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#144-179" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#145-151" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#153-159" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#161-163" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#166-169" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#172-178" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#48" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#48" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Drop" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Drop" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#136-142" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.drop" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&mut self)</code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#137-141" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
19
doc/tokio/net/unix/struct.ReadHalf.html
Normal file
19
doc/tokio/net/unix/struct.ReadHalf.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!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="API documentation for the Rust `ReadHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, ReadHalf"><title>tokio::net::unix::ReadHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct ReadHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CUnixStream%3E">AsRef<UnixStream></a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "ReadHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#28" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">ReadHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ReadHalf<'a>(_);</pre></div><div class="docblock"><p>Borrowed read half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.split"><code>split</code></a>.</p>
|
||||
<p>Reading from a <code>ReadHalf</code> is usually done using the convenience methods found on the
|
||||
<a href="trait@crate::io::AsyncReadExt"><code>AsyncReadExt</code></a> trait.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CUnixStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsRef%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#90-94" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#91-93" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl<'_> <a class="trait" href="../../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'_></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#50-58" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: &mut <a class="struct" href="../../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#51-57" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#27" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#27" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReadHalf.html" title="struct tokio::net::unix::ReadHalf">ReadHalf</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
22
doc/tokio/net/unix/struct.ReuniteError.html
Normal file
22
doc/tokio/net/unix/struct.ReuniteError.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!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="API documentation for the Rust `ReuniteError` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, ReuniteError"><title>tokio::net::unix::ReuniteError - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct ReuniteError</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Error">Error</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "ReuniteError", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#83" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">ReuniteError</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct ReuniteError(pub <a class="struct" href="../../../tokio/net/unix/struct.OwnedReadHalf.html" title="struct tokio::net::unix::OwnedReadHalf">OwnedReadHalf</a>, pub <a class="struct" href="../../../tokio/net/unix/struct.OwnedWriteHalf.html" title="struct tokio::net::unix::OwnedWriteHalf">OwnedWriteHalf</a>);</pre></div><div class="docblock"><p>Error indicating that two halves were not from the same socket, and thus could
|
||||
not be reunited.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#82" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#82" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#85-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#86-91" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split_owned.rs.html#94" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.source" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source" class="fnname">source</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> + 'static)></code><span class="since" title="Stable since Rust version 1.30.0">1.30.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#100-102" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>The lower-level source of this error, if any. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.source">Read more</a></p>
|
||||
</div><h4 id="method.backtrace" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace" class="fnname">backtrace</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/backtrace/struct.Backtrace.html" title="struct std::backtrace::Backtrace">Backtrace</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#128-130" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>backtrace</code>)</div></div><div class='docblock hidden'><p>Returns a stack backtrace, if available, of where this error occurred. <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.backtrace">Read more</a></p>
|
||||
</div><h4 id="method.description" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description" class="fnname">description</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#140-142" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.42.0: <p>use the Display impl or to_string()</p>
|
||||
</div></div><div class='docblock hidden'> <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.description">Read more</a></div><h4 id="method.cause" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html#method.cause" class="fnname">cause</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&dyn <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a>></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/error.rs.html#150-152" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 1.33.0: <p>replaced by Error::source, which can support downcasting</p>
|
||||
</div></div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.ReuniteError.html" title="struct tokio::net::unix::ReuniteError">ReuniteError</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToString" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-ToString" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2194-2207" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.to_string" class="method hidden"><code>pub default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2200-2206" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
19
doc/tokio/net/unix/struct.SocketAddr.html
Normal file
19
doc/tokio/net/unix/struct.SocketAddr.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!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="API documentation for the Rust `SocketAddr` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, SocketAddr"><title>tokio::net::unix::SocketAddr - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct SocketAddr</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.as_pathname">as_pathname</a><a href="#method.is_unnamed">is_unnamed</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "SocketAddr", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#5" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">SocketAddr</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct SocketAddr(_);</pre></div><div class="docblock"><p>An address associated with a Tokio Unix socket.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#7-25" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.is_unnamed" class="method"><code>pub fn <a href="#method.is_unnamed" class="fnname">is_unnamed</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#13-15" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the address is unnamed.</p>
|
||||
<p>Documentation reflected in <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.SocketAddr.html"><code>SocketAddr</code></a></p>
|
||||
</div><h4 id="method.as_pathname" class="method"><code>pub fn <a href="#method.as_pathname" class="fnname">as_pathname</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>></code><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#22-24" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the contents of this address if it is a <code>pathname</code> address.</p>
|
||||
<p>Documentation reflected in <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/net/struct.SocketAddr.html"><code>SocketAddr</code></a></p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#27-31" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/socketaddr.rs.html#28-30" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.SocketAddr.html" title="struct tokio::net::unix::SocketAddr">SocketAddr</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
31
doc/tokio/net/unix/struct.UCred.html
Normal file
31
doc/tokio/net/unix/struct.UCred.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!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="API documentation for the Rust `UCred` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, UCred"><title>tokio::net::unix::UCred - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct UCred</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.gid">gid</a><a href="#method.pid">pid</a><a href="#method.uid">uid</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Copy">Copy</a><a href="#impl-Debug">Debug</a><a href="#impl-Eq">Eq</a><a href="#impl-Hash">Hash</a><a href="#impl-PartialEq%3CUCred%3E">PartialEq<UCred></a><a href="#impl-StructuralEq">StructuralEq</a><a href="#impl-StructuralPartialEq">StructuralPartialEq</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "UCred", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#5-12" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">UCred</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct UCred { /* fields omitted */ }</pre></div><div class="docblock"><p>Credentials of a process</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#14-32" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.uid" class="method"><code>pub fn <a href="#method.uid" class="fnname">uid</a>(&self) -> <a class="type" href="../../../libc/unix/type.uid_t.html" title="type libc::unix::uid_t">uid_t</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#16-18" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets UID (user ID) of the process.</p>
|
||||
</div><h4 id="method.gid" class="method"><code>pub fn <a href="#method.gid" class="fnname">gid</a>(&self) -> <a class="type" href="../../../libc/unix/type.gid_t.html" title="type libc::unix::gid_t">gid_t</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#21-23" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets GID (group ID) of the process.</p>
|
||||
</div><h4 id="method.pid" class="method"><code>pub fn <a href="#method.pid" class="fnname">pid</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="../../../libc/unix/type.pid_t.html" title="type libc::unix::pid_t">pid_t</a>></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#29-31" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets PID (process ID) of the process.</p>
|
||||
<p>This is only implemented under Linux, Android, iOS, macOS, Solaris and
|
||||
Illumos. On other plaforms this will always return <code>None</code>.</p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Copy" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Copy" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Hash" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Hash" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.hash" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a><__H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>__H)</code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Feeds this value into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></p>
|
||||
</div><h4 id="method.hash_slice" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a><H>(data: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>H) <span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>, </span></code><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#184-191" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></p>
|
||||
</div></div><h3 id="impl-PartialEq%3CUCred%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a>> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-PartialEq%3CUCred%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: &<a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
|
||||
by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
|
||||
</div><h4 id="method.ne" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: &<a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
|
||||
</div></div><h3 id="impl-StructuralEq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-StructuralEq" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-StructuralPartialEq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-StructuralPartialEq" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/ucred.rs.html#4" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.UCred.html" title="struct tokio::net::unix::UCred">UCred</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||||
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||||
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
28
doc/tokio/net/unix/struct.WriteHalf.html
Normal file
28
doc/tokio/net/unix/struct.WriteHalf.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!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="API documentation for the Rust `WriteHalf` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, WriteHalf"><title>tokio::net::unix::WriteHalf - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct WriteHalf</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3CUnixStream%3E">AsRef<UnixStream></a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a></p><script>window.sidebarCurrent = {name: "WriteHalf", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#44" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">net</a>::<wbr><a href="index.html">unix</a>::<wbr><a class="struct" href="">WriteHalf</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct WriteHalf<'a>(_);</pre></div><div class="docblock"><p>Borrowed write half of a <a href="../../../tokio/net/struct.UnixStream.html"><code>UnixStream</code></a>, created by <a href="../../../tokio/net/struct.UnixStream.html#method.split"><code>split</code></a>.</p>
|
||||
<p>Note that in the <a href="../../../tokio/io/trait.AsyncWrite.html"><code>AsyncWrite</code></a> implemenation of this type, <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown"><code>poll_shutdown</code></a> will
|
||||
shut down the UnixStream stream in the write direction.</p>
|
||||
<p>Writing to an <code>WriteHalf</code> is usually done using the convenience methods found
|
||||
on the <a href="trait@crate::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> trait.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3CUnixStream%3E" class="impl"><code class="in-band">impl<'_> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a>> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsRef%3CUnixStream%3E" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#96-100" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../../tokio/net/struct.UnixStream.html" title="struct tokio::net::UnixStream">UnixStream</a></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#97-99" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl<'_> <a class="trait" href="../../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'_></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#60-88" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#61-67" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
|
||||
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#69-75" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#77-79" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
|
||||
implementation. <a href="../../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
|
||||
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#81-83" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
|
||||
their destination. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
|
||||
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, _: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
|
||||
the I/O connection has completely shut down. <a href="../../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#43" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/net/unix/split.rs.html#43" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/net/unix/struct.WriteHalf.html" title="struct tokio::net::unix::WriteHalf">WriteHalf</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "tokio";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>
|
||||
10
doc/tokio/net/unix/ucred/struct.UCred.html
Normal file
10
doc/tokio/net/unix/ucred/struct.UCred.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tokio/net/unix/struct.UCred.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tokio/net/unix/struct.UCred.html">../../../../tokio/net/unix/struct.UCred.html</a>...</p>
|
||||
<script>location.replace("../../../../tokio/net/unix/struct.UCred.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/runtime/builder/struct.Builder.html
Normal file
10
doc/tokio/runtime/builder/struct.Builder.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.Builder.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.Builder.html">../../../tokio/runtime/struct.Builder.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.Builder.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/runtime/handle/struct.EnterGuard.html
Normal file
10
doc/tokio/runtime/handle/struct.EnterGuard.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.EnterGuard.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.EnterGuard.html">../../../tokio/runtime/struct.EnterGuard.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.EnterGuard.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
10
doc/tokio/runtime/handle/struct.Handle.html
Normal file
10
doc/tokio/runtime/handle/struct.Handle.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tokio/runtime/struct.Handle.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tokio/runtime/struct.Handle.html">../../../tokio/runtime/struct.Handle.html</a>...</p>
|
||||
<script>location.replace("../../../tokio/runtime/struct.Handle.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
147
doc/tokio/runtime/index.html
Normal file
147
doc/tokio/runtime/index.html
Normal file
@@ -0,0 +1,147 @@
|
||||
<!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="API documentation for the Rust `runtime` mod in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, runtime"><title>tokio::runtime - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module runtime</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class="location"><a href="../index.html">tokio</a></p><script>window.sidebarCurrent = {name: "runtime", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#1-563" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../index.html">tokio</a>::<wbr><a class="mod" href="">runtime</a></span></h1><div class="docblock"><p>The Tokio runtime.</p>
|
||||
<p>Unlike other Rust programs, asynchronous applications require runtime
|
||||
support. In particular, the following runtime services are necessary:</p>
|
||||
<ul>
|
||||
<li>An <strong>I/O event loop</strong>, called the driver, which drives I/O resources and
|
||||
dispatches I/O events to tasks that depend on them.</li>
|
||||
<li>A <strong>scheduler</strong> to execute <a href="../../tokio/task/index.html">tasks</a> that use these I/O resources.</li>
|
||||
<li>A <strong>timer</strong> for scheduling work to run after a set period of time.</li>
|
||||
</ul>
|
||||
<p>Tokio's <a href="../../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a> bundles all of these services as a single type, allowing
|
||||
them to be started, shut down, and configured together. However, often it is
|
||||
not required to configure a <a href="../../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a> manually, and user may just use the
|
||||
<a href="../attr.main.html"><code>tokio::main</code></a> attribute macro, which creates a <a href="../../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a> under the hood.</p>
|
||||
<h1 id="usage" class="section-header"><a href="#usage">Usage</a></h1>
|
||||
<p>When no fine tuning is required, the <a href="../attr.main.html"><code>tokio::main</code></a> attribute macro can be
|
||||
used.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="ident">AsyncReadExt</span>, <span class="ident">AsyncWriteExt</span>};
|
||||
|
||||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||||
<span class="ident">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">socket</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// In a loop, read data from the socket and write the data back.</span>
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span> {
|
||||
<span class="comment">// socket closed</span>
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="kw">if</span> <span class="ident">n</span> <span class="op">=</span><span class="op">=</span> <span class="number">0</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span>,
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> <span class="ident">n</span>,
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"failed to read from socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">// Write the data back</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span><span class="ident">buf</span>[<span class="number">0</span>..<span class="ident">n</span>]).<span class="ident">await</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"failed to write to socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}</pre></div>
|
||||
<p>From within the context of the runtime, additional tasks are spawned using
|
||||
the <a href="../../tokio/fn.spawn.html"><code>tokio::spawn</code></a> function. Futures spawned using this function will be
|
||||
executed on the same thread pool used by the <a href="../../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a>.</p>
|
||||
<p>A <a href="../../tokio/runtime/struct.Runtime.html"><code>Runtime</code></a> instance can also be used directly.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">net</span>::<span class="ident">TcpListener</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::{<span class="ident">AsyncReadExt</span>, <span class="ident">AsyncWriteExt</span>};
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Box</span><span class="op"><</span><span class="ident">dyn</span> <span class="ident">std</span>::<span class="ident">error</span>::<span class="ident">Error</span><span class="op">></span><span class="op">></span> {
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Spawn the root task</span>
|
||||
<span class="ident">rt</span>.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="kw">let</span> <span class="ident">listener</span> <span class="op">=</span> <span class="ident">TcpListener</span>::<span class="ident">bind</span>(<span class="string">"127.0.0.1:8080"</span>).<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">socket</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">listener</span>.<span class="ident">accept</span>().<span class="ident">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1024</span>];
|
||||
|
||||
<span class="comment">// In a loop, read data from the socket and write the data back.</span>
|
||||
<span class="kw">loop</span> {
|
||||
<span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">socket</span>.<span class="ident">read</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">buf</span>).<span class="ident">await</span> {
|
||||
<span class="comment">// socket closed</span>
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="kw">if</span> <span class="ident">n</span> <span class="op">=</span><span class="op">=</span> <span class="number">0</span> <span class="op">=</span><span class="op">></span> <span class="kw">return</span>,
|
||||
<span class="prelude-val">Ok</span>(<span class="ident">n</span>) <span class="op">=</span><span class="op">></span> <span class="ident">n</span>,
|
||||
<span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"failed to read from socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">// Write the data back</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">e</span>) <span class="op">=</span> <span class="ident">socket</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span><span class="ident">buf</span>[<span class="number">0</span>..<span class="ident">n</span>]).<span class="ident">await</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"failed to write to socket; err = {:?}"</span>, <span class="ident">e</span>);
|
||||
<span class="kw">return</span>;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}</pre></div>
|
||||
<h2 id="runtime-configurations" class="section-header"><a href="#runtime-configurations">Runtime Configurations</a></h2>
|
||||
<p>Tokio provides multiple task scheduling strategies, suitable for different
|
||||
applications. The <a href="../../tokio/runtime/struct.Builder.html">runtime builder</a> or <code>#[tokio::main]</code> attribute may be
|
||||
used to select which scheduler to use.</p>
|
||||
<h4 id="multi-thread-scheduler" class="section-header"><a href="#multi-thread-scheduler">Multi-Thread Scheduler</a></h4>
|
||||
<p>The multi-thread scheduler executes futures on a <em>thread pool</em>, using a
|
||||
work-stealing strategy. By default, it will start a worker thread for each
|
||||
CPU core available on the system. This tends to be the ideal configurations
|
||||
for most applications. The multi-thread scheduler requires the <code>rt-multi-thread</code>
|
||||
feature flag, and is selected by default:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">threaded_rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Runtime</span>::<span class="ident">new</span>()<span class="question-mark">?</span>;</pre></div>
|
||||
<p>Most applications should use the multi-thread scheduler, except in some
|
||||
niche use-cases, such as when running only a single thread is required.</p>
|
||||
<h4 id="current-thread-scheduler" class="section-header"><a href="#current-thread-scheduler">Current-Thread Scheduler</a></h4>
|
||||
<p>The current-thread scheduler provides a <em>single-threaded</em> future executor.
|
||||
All tasks will be created and executed on the current thread. This requires
|
||||
the <code>rt</code> feature flag.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">basic_rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_current_thread</span>()
|
||||
.<span class="ident">build</span>()<span class="question-mark">?</span>;</pre></div>
|
||||
<h4 id="resource-drivers" class="section-header"><a href="#resource-drivers">Resource drivers</a></h4>
|
||||
<p>When configuring a runtime by hand, no resource drivers are enabled by
|
||||
default. In this case, attempting to use networking types or time types will
|
||||
fail. In order to enable these types, the resource drivers must be enabled.
|
||||
This is done with <a href="../../tokio/runtime/struct.Builder.html#method.enable_io"><code>Builder::enable_io</code></a> and <a href="../../tokio/runtime/struct.Builder.html#method.enable_time"><code>Builder::enable_time</code></a>. As a
|
||||
shorthand, <a href="../../tokio/runtime/struct.Builder.html#method.enable_all"><code>Builder::enable_all</code></a> enables both resource drivers.</p>
|
||||
<h2 id="lifetime-of-spawned-threads" class="section-header"><a href="#lifetime-of-spawned-threads">Lifetime of spawned threads</a></h2>
|
||||
<p>The runtime may spawn threads depending on its configuration and usage. The
|
||||
multi-thread scheduler spawns threads to schedule tasks and for <code>spawn_blocking</code>
|
||||
calls.</p>
|
||||
<p>While the <code>Runtime</code> is active, threads may shutdown after periods of being
|
||||
idle. Once <code>Runtime</code> is dropped, all runtime threads are forcibly shutdown.
|
||||
Any tasks that have not yet completed will be dropped.</p>
|
||||
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||||
<table><tr class="module-item"><td><a class="struct" href="struct.Builder.html" title="tokio::runtime::Builder struct">Builder</a></td><td class="docblock-short"><p>Builds Tokio Runtime with custom configuration values.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.EnterGuard.html" title="tokio::runtime::EnterGuard struct">EnterGuard</a></td><td class="docblock-short"><p>Runtime context guard.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Handle.html" title="tokio::runtime::Handle struct">Handle</a></td><td class="docblock-short"><p>Handle to the runtime.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.Runtime.html" title="tokio::runtime::Runtime struct">Runtime</a></td><td class="docblock-short"><p>The Tokio runtime.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
1
doc/tokio/runtime/sidebar-items.js
Normal file
1
doc/tokio/runtime/sidebar-items.js
Normal file
@@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["Builder","Builds Tokio Runtime with custom configuration values."],["EnterGuard","Runtime context guard."],["Handle","Handle to the runtime."],["Runtime","The Tokio runtime."]]});
|
||||
185
doc/tokio/runtime/struct.Builder.html
Normal file
185
doc/tokio/runtime/struct.Builder.html
Normal file
@@ -0,0 +1,185 @@
|
||||
<!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="API documentation for the Rust `Builder` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Builder"><title>tokio::runtime::Builder - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Builder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.build">build</a><a href="#method.enable_all">enable_all</a><a href="#method.enable_io">enable_io</a><a href="#method.enable_time">enable_time</a><a href="#method.max_blocking_threads">max_blocking_threads</a><a href="#method.new_current_thread">new_current_thread</a><a href="#method.new_multi_thread">new_multi_thread</a><a href="#method.on_thread_start">on_thread_start</a><a href="#method.on_thread_stop">on_thread_stop</a><a href="#method.thread_keep_alive">thread_keep_alive</a><a href="#method.thread_name">thread_name</a><a href="#method.thread_name_fn">thread_name_fn</a><a href="#method.thread_stack_size">thread_stack_size</a><a href="#method.worker_threads">worker_threads</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></p><script>window.sidebarCurrent = {name: "Builder", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#40-72" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a>::<wbr><a class="struct" href="">Builder</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Builder { /* fields omitted */ }</pre></div><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="../../tokio/runtime/struct.Builder.html#method.build"><code>build</code></a>.</p>
|
||||
<p>New instances of <code>Builder</code> are obtained via <a href="../../tokio/runtime/struct.Builder.html#method.new_multi_thread"><code>Builder::new_multi_thread</code></a>
|
||||
or <a href="../../tokio/runtime/struct.Builder.html#method.new_current_thread"><code>Builder::new_current_thread</code></a>.</p>
|
||||
<p>See function level documentation for details on the various configuration
|
||||
settings.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Builder</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="comment">// build runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">runtime</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">worker_threads</span>(<span class="number">4</span>)
|
||||
.<span class="ident">thread_name</span>(<span class="string">"my-custom-name"</span>)
|
||||
.<span class="ident">thread_stack_size</span>(<span class="number">3</span> <span class="op">*</span> <span class="number">1024</span> <span class="op">*</span> <span class="number">1024</span>)
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// use runtime ...</span>
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#82-443" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new_current_thread" class="method"><code>pub fn <a href="#method.new_current_thread" class="fnname">new_current_thread</a>() -> <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#86-88" title="goto source code">[src]</a></h4><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>
|
||||
</div><h4 id="method.new_multi_thread" class="method"><code>pub fn <a href="#method.new_multi_thread" class="fnname">new_multi_thread</a>() -> <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#95-97" title="goto source code">[src]</a></h4><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><h4 id="method.enable_all" class="method"><code>pub fn <a href="#method.enable_all" class="fnname">enable_all</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#148-155" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">enable_all</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();</pre></div>
|
||||
</div><h4 id="method.worker_threads" class="method"><code>pub fn <a href="#method.worker_threads" class="fnname">worker_threads</a>(&mut self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#206-210" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the number of worker threads the <code>Runtime</code> will use.</p>
|
||||
<p>This should be a number between 0 and 32,768 though it is advised to
|
||||
keep this value on the smaller side.</p>
|
||||
<h1 id="default" class="section-header"><a href="#default">Default</a></h1>
|
||||
<p>The default value is the number of cores available to the system.</p>
|
||||
<h1 id="panic" class="section-header"><a href="#panic">Panic</a></h1>
|
||||
<p>When using the <code>current_thread</code> runtime this method will panic, since
|
||||
those variants do not allow setting worker thread counts.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1><h2 id="multi-threaded-runtime-with-4-threads" class="section-header"><a href="#multi-threaded-runtime-with-4-threads">Multi threaded runtime with 4 threads</a></h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="comment">// This will spawn a work-stealing runtime with 4 worker threads.</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">worker_threads</span>(<span class="number">4</span>)
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="ident">rt</span>.<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {});</pre></div>
|
||||
<h2 id="current-thread-runtime-will-only-run-on-the-current-thread-via-runtimeblock_on" class="section-header"><a href="#current-thread-runtime-will-only-run-on-the-current-thread-via-runtimeblock_on">Current thread runtime (will only run on the current thread via <code>Runtime::block_on</code>)</a></h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="comment">// Create a runtime that _must_ be driven from a call</span>
|
||||
<span class="comment">// to `Runtime::block_on`.</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_current_thread</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// This will run the runtime and future on the current thread</span>
|
||||
<span class="ident">rt</span>.<span class="ident">block_on</span>(<span class="ident">async</span> <span class="kw">move</span> {});</pre></div>
|
||||
<h1 id="panic-1" class="section-header"><a href="#panic-1">Panic</a></h1>
|
||||
<p>This will panic if <code>val</code> is not larger than <code>0</code>.</p>
|
||||
</div><h4 id="method.max_blocking_threads" class="method"><code>pub fn <a href="#method.max_blocking_threads" class="fnname">max_blocking_threads</a>(&mut self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#225-229" title="goto source code">[src]</a></h4><div class="docblock"><p>Specifies limit for threads spawned by the Runtime used for blocking operations.</p>
|
||||
<p>Similarly to the <code>worker_threads</code>, this number should be between 1 and 32,768.</p>
|
||||
<p>The default value is 512.</p>
|
||||
<p>Otherwise as <code>worker_threads</code> are always active, it limits additional threads (e.g. for
|
||||
blocking annotations).</p>
|
||||
<h1 id="panic-2" class="section-header"><a href="#panic-2">Panic</a></h1>
|
||||
<p>This will panic if <code>val</code> is not larger than <code>0</code>.</p>
|
||||
</div><h4 id="method.thread_name" class="method"><code>pub fn <a href="#method.thread_name" class="fnname">thread_name</a>(&mut self, val: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#246-250" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">thread_name</span>(<span class="string">"my-pool"</span>)
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div><h4 id="method.thread_name_fn" class="method"><code>pub fn <a href="#method.thread_name_fn" class="fnname">thread_name_fn</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#272-278" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">thread_name_fn</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="kw">static</span> <span class="ident">ATOMIC_ID</span>: <span class="ident">AtomicUsize</span> <span class="op">=</span> <span class="ident">AtomicUsize</span>::<span class="ident">new</span>(<span class="number">0</span>);
|
||||
<span class="kw">let</span> <span class="ident">id</span> <span class="op">=</span> <span class="ident">ATOMIC_ID</span>.<span class="ident">fetch_add</span>(<span class="number">1</span>, <span class="ident">Ordering</span>::<span class="ident">SeqCst</span>);
|
||||
<span class="macro">format</span><span class="macro">!</span>(<span class="string">"my-pool-{}"</span>, <span class="ident">id</span>)
|
||||
})
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div><h4 id="method.thread_stack_size" class="method"><code>pub fn <a href="#method.thread_stack_size" class="fnname">thread_stack_size</a>(&mut self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#299-302" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">thread_stack_size</span>(<span class="number">32</span> <span class="op">*</span> <span class="number">1024</span>)
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div><h4 id="method.on_thread_start" class="method"><code>pub fn <a href="#method.on_thread_start" class="fnname">on_thread_start</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#323-329" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">runtime</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">on_thread_start</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"thread started"</span>);
|
||||
})
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div><h4 id="method.on_thread_stop" class="method"><code>pub fn <a href="#method.on_thread_stop" class="fnname">on_thread_stop</a><F>(&mut self, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#349-355" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">runtime</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">on_thread_stop</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"thread stopping"</span>);
|
||||
})
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div><h4 id="method.build" class="method"><code>pub fn <a href="#method.build" class="fnname">build</a>(&mut self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a>></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#372-378" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates the configured <code>Runtime</code>.</p>
|
||||
<p>The returned <code>Runtime</code> instance is ready to spawn tasks.</p>
|
||||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Builder</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>().<span class="ident">build</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="ident">rt</span>.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello from the Tokio runtime"</span>);
|
||||
});</pre></div>
|
||||
</div><h4 id="method.thread_keep_alive" class="method"><code>pub fn <a href="#method.thread_keep_alive" class="fnname">thread_keep_alive</a>(&mut self, duration: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#409-412" title="goto source code">[src]</a></h4><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 overriden using .thread_keep_alive().</p>
|
||||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">thread_keep_alive</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">100</span>))
|
||||
.<span class="ident">build</span>();</pre></div>
|
||||
</div></div><h3 id="impl-1" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#446-466" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.enable_io" class="method"><code>pub fn <a href="#method.enable_io" class="fnname">enable_io</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#462-465" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">enable_io</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();</pre></div>
|
||||
</div></div><h3 id="impl-2" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-2" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#470-489" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.enable_time" class="method"><code>pub fn <a href="#method.enable_time" class="fnname">enable_time</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#485-488" title="goto source code">[src]</a></h4><div class="docblock"><p>Enables the time driver.</p>
|
||||
<p>Doing this enables using <code>tokio::time</code> on the runtime.</p>
|
||||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">runtime</span>::<span class="ident">Builder</span>::<span class="ident">new_multi_thread</span>()
|
||||
.<span class="ident">enable_time</span>()
|
||||
.<span class="ident">build</span>()
|
||||
.<span class="ident">unwrap</span>();</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#533-547" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/runtime/builder.rs.html#534-546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Builder.html" title="struct tokio::runtime::Builder">Builder</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
17
doc/tokio/runtime/struct.EnterGuard.html
Normal file
17
doc/tokio/runtime/struct.EnterGuard.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!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="API documentation for the Rust `EnterGuard` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, EnterGuard"><title>tokio::runtime::EnterGuard - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct EnterGuard</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></p><script>window.sidebarCurrent = {name: "EnterGuard", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#41-44" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a>::<wbr><a class="struct" href="">EnterGuard</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct EnterGuard<'a> { /* fields omitted */ }</pre></div><div class="docblock"><p>Runtime context guard.</p>
|
||||
<p>Returned by <a href="../../tokio/runtime/struct.Runtime.html#method.enter"><code>Runtime::enter</code></a> and <a href="../../tokio/runtime/struct.Handle.html#method.enter" title="Handle::enter"><code>Handle::enter</code></a>, the context guard exits
|
||||
the runtime context on drop.</p>
|
||||
</div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#40" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#40" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
86
doc/tokio/runtime/struct.Handle.html
Normal file
86
doc/tokio/runtime/struct.Handle.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!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="API documentation for the Rust `Handle` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Handle"><title>tokio::runtime::Handle - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Handle</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.current">current</a><a href="#method.enter">enter</a><a href="#method.spawn">spawn</a><a href="#method.spawn_blocking">spawn_blocking</a><a href="#method.try_current">try_current</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></p><script>window.sidebarCurrent = {name: "Handle", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#15-32" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a>::<wbr><a class="struct" href="">Handle</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Handle { /* fields omitted */ }</pre></div><div class="docblock"><p>Handle to the runtime.</p>
|
||||
<p>The handle is internally reference-counted and can be freely cloned. A handle can be
|
||||
obtained using the <a href="../../tokio/runtime/struct.Runtime.html#method.handle"><code>Runtime::handle</code></a> method.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#46-203" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.enter" class="method"><code>pub fn <a href="#method.enter" class="fnname">enter</a>(&self) -> <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'_></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#54-59" title="goto source code">[src]</a></h4><div class="docblock"><p>Enter the runtime context. This allows you to construct types that must
|
||||
have an executor available on creation such as <a href="../../tokio/time/struct.Sleep.html"><code>Sleep</code></a> or <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>.
|
||||
It will also allow you to call methods such as <a href="../../tokio/fn.spawn.html"><code>tokio::spawn</code></a>.</p>
|
||||
</div><h4 id="method.current" class="method"><code>pub fn <a href="#method.current" class="fnname">current</a>() -> Self</code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#99-101" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a <code>Handle</code> view over the currently running <code>Runtime</code></p>
|
||||
<h1 id="panic" class="section-header"><a href="#panic">Panic</a></h1>
|
||||
<p>This will panic if called outside the context of a Tokio runtime. That means that you must
|
||||
call this on one of the threads <strong>being run by the runtime</strong>. Calling this from within a
|
||||
thread created by <code>std::thread::spawn</code> (for example) will cause a panic.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>This can be used to obtain the handle of the surrounding runtime from an async
|
||||
block or function running on that runtime.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Handle</span>;
|
||||
|
||||
<span class="comment">// Inside an async block or function.</span>
|
||||
<span class="kw">let</span> <span class="ident">handle</span> <span class="op">=</span> <span class="ident">Handle</span>::<span class="ident">current</span>();
|
||||
<span class="ident">handle</span>.<span class="ident">spawn</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"now running in the existing Runtime"</span>);
|
||||
});
|
||||
|
||||
<span class="ident">thread</span>::<span class="ident">spawn</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
||||
<span class="comment">// Notice that the handle is created outside of this thread and then moved in</span>
|
||||
<span class="ident">handle</span>.<span class="ident">spawn</span>(<span class="ident">async</span> { <span class="comment">/* ... */</span> })
|
||||
<span class="comment">// This next line would cause a panic</span>
|
||||
<span class="comment">// let handle2 = Handle::current();</span>
|
||||
});</pre></div>
|
||||
</div><h4 id="method.try_current" class="method"><code>pub fn <a href="#method.try_current" class="fnname">try_current</a>() -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, TryCurrentError></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#108-110" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a Handle view over the currently running Runtime</p>
|
||||
<p>Returns an error if no Runtime has been started</p>
|
||||
<p>Contrary to <code>current</code>, this never panics</p>
|
||||
</div><h4 id="method.spawn" class="method"><code>pub fn <a href="#method.spawn" class="fnname">spawn</a><F>(&self, future: F) -> <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><F::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></h3><code class="content"><span class="where fmt-newline">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../../tokio/task/struct.JoinError.html" title="struct tokio::task::JoinError">JoinError</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> F::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#140-148" title="goto source code">[src]</a></h4><div class="docblock"><p>Spawn a future onto the Tokio runtime.</p>
|
||||
<p>This spawns the given future onto the runtime's executor, usually a
|
||||
thread pool. The thread pool is then responsible for polling the future
|
||||
until it completes.</p>
|
||||
<p>See <a href="index.html">module level</a> documentation for more details.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
<span class="comment">// Get a handle from this runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">handle</span> <span class="op">=</span> <span class="ident">rt</span>.<span class="ident">handle</span>();
|
||||
|
||||
<span class="comment">// Spawn a future onto the runtime using the handle</span>
|
||||
<span class="ident">handle</span>.<span class="ident">spawn</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"now running on a worker thread"</span>);
|
||||
});</pre></div>
|
||||
</div><h4 id="method.spawn_blocking" class="method"><code>pub fn <a href="#method.spawn_blocking" class="fnname">spawn_blocking</a><F, R>(&self, func: F) -> <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><R><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></h3><code class="content"><span class="where fmt-newline">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../../tokio/task/struct.JoinError.html" title="struct tokio::task::JoinError">JoinError</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> R + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#170-202" title="goto source code">[src]</a></h4><div class="docblock"><p>Run the provided function on an executor dedicated to blocking
|
||||
operations.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
<span class="comment">// Get a handle from this runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">handle</span> <span class="op">=</span> <span class="ident">rt</span>.<span class="ident">handle</span>();
|
||||
|
||||
<span class="comment">// Spawn a blocking function onto the runtime using the handle</span>
|
||||
<span class="ident">handle</span>.<span class="ident">spawn_blocking</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"now running on a worker thread"</span>);
|
||||
});</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#14" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#14" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#14" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/runtime/handle.rs.html#14" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||||
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||||
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91" title="goto source code">[src]</a></h4><div class="stability hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
202
doc/tokio/runtime/struct.Runtime.html
Normal file
202
doc/tokio/runtime/struct.Runtime.html
Normal file
@@ -0,0 +1,202 @@
|
||||
<!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="API documentation for the Rust `Runtime` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Runtime"><title>tokio::runtime::Runtime - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Runtime</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.block_on">block_on</a><a href="#method.enter">enter</a><a href="#method.handle">handle</a><a href="#method.new">new</a><a href="#method.shutdown_background">shutdown_background</a><a href="#method.shutdown_timeout">shutdown_timeout</a><a href="#method.spawn">spawn</a><a href="#method.spawn_blocking">spawn_blocking</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a></p><script>window.sidebarCurrent = {name: "Runtime", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><span class="help-button">?</span>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#264-273" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">runtime</a>::<wbr><a class="struct" href="">Runtime</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Runtime { /* fields omitted */ }</pre></div><div class="docblock"><p>The Tokio runtime.</p>
|
||||
<p>The runtime provides an I/O driver, task scheduler, <a href="../../tokio/time/index.html">timer</a>, and
|
||||
blocking pool, necessary for running asynchronous tasks.</p>
|
||||
<p>Instances of <code>Runtime</code> can be created using <a href="../../tokio/runtime/struct.Runtime.html#method.new"><code>new</code></a>, or <a href="../../tokio/runtime/struct.Builder.html"><code>Builder</code></a>.
|
||||
However, most users will use the <code>#[tokio::main]</code> annotation on their
|
||||
entry point instead.</p>
|
||||
<p>See <a href="index.html">module level</a> documentation for more details.</p>
|
||||
<h1 id="shutdown" class="section-header"><a href="#shutdown">Shutdown</a></h1>
|
||||
<p>Shutting down the runtime is done by dropping the value. The current
|
||||
thread will block until the shut down operation has completed.</p>
|
||||
<ul>
|
||||
<li>Drain any scheduled work queues.</li>
|
||||
<li>Drop any futures that have not yet completed.</li>
|
||||
<li>Drop the reactor.</li>
|
||||
</ul>
|
||||
<p>Once the reactor has dropped, any outstanding I/O resources bound to
|
||||
that reactor will no longer function. Calling any method on them will
|
||||
result in an error.</p>
|
||||
<h1 id="sharing" class="section-header"><a href="#sharing">Sharing</a></h1>
|
||||
<p>The Tokio runtime implements <code>Sync</code> and <code>Send</code> to allow you to wrap it
|
||||
in a <code>Arc</code>. Most fn take <code>&self</code> to allow you to call them concurrently
|
||||
accross multiple threads.</p>
|
||||
<p>Calls to <code>shutdown</code> and <code>shutdown_timeout</code> require exclusive ownership of
|
||||
the runtime type and this can be achieved via <code>Arc::try_unwrap</code> when only
|
||||
one strong count reference is left over.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#289-562" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>() -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a>></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#321-323" title="goto source code">[src]</a></h4><div class="docblock"><p>Create a new runtime instance with default configuration values.</p>
|
||||
<p>This results in the multi threaded scheduler, I/O driver, and time driver being
|
||||
initialized.</p>
|
||||
<p>Most applications will not need to call this function directly. Instead,
|
||||
they will use the <a href="../attr.main.html"><code>#[tokio::main]</code> attribute</a>. When a more complex
|
||||
configuration is necessary, the <a href="../../tokio/runtime/struct.Builder.html">runtime builder</a> may be used.</p>
|
||||
<p>See <a href="index.html">module level</a> documentation for more details.</p>
|
||||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||||
<p>Creating a new <code>Runtime</code> with default configuration values.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>()
|
||||
.<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// Use the runtime...</span></pre></div>
|
||||
</div><h4 id="method.handle" class="method"><code>pub fn <a href="#method.handle" class="fnname">handle</a>(&self) -> &<a class="struct" href="../../tokio/runtime/struct.Handle.html" title="struct tokio::runtime::Handle">Handle</a></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#342-344" title="goto source code">[src]</a></h4><div class="docblock"><p>Return a handle to the runtime's spawner.</p>
|
||||
<p>The returned handle can be used to spawn tasks that run on this runtime, and can
|
||||
be cloned to allow moving the <code>Handle</code> to other threads.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>()
|
||||
.<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">handle</span> <span class="op">=</span> <span class="ident">rt</span>.<span class="ident">handle</span>();
|
||||
|
||||
<span class="comment">// Use the handle...</span></pre></div>
|
||||
</div><h4 id="method.spawn" class="method"><code>pub fn <a href="#method.spawn" class="fnname">spawn</a><F>(&self, future: F) -> <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><F::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></h3><code class="content"><span class="where fmt-newline">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../../tokio/task/struct.JoinError.html" title="struct tokio::task::JoinError">JoinError</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> F::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#372-378" title="goto source code">[src]</a></h4><div class="docblock"><p>Spawn a future onto the Tokio runtime.</p>
|
||||
<p>This spawns the given future onto the runtime's executor, usually a
|
||||
thread pool. The thread pool is then responsible for polling the future
|
||||
until it completes.</p>
|
||||
<p>See <a href="index.html">module level</a> documentation for more details.</p>
|
||||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// Spawn a future onto the runtime</span>
|
||||
<span class="ident">rt</span>.<span class="ident">spawn</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"now running on a worker thread"</span>);
|
||||
});</pre></div>
|
||||
</div><h4 id="method.spawn_blocking" class="method"><code>pub fn <a href="#method.spawn_blocking" class="fnname">spawn_blocking</a><F, R>(&self, func: F) -> <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><R><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></h3><code class="content"><span class="where fmt-newline">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../tokio/task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle">JoinHandle</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../../tokio/task/struct.JoinError.html" title="struct tokio::task::JoinError">JoinError</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> R + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static, </span></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#397-403" title="goto source code">[src]</a></h4><div class="docblock"><p>Run the provided function on an executor dedicated to blocking operations.</p>
|
||||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// Spawn a blocking function onto the runtime</span>
|
||||
<span class="ident">rt</span>.<span class="ident">spawn_blocking</span>(<span class="op">|</span><span class="op">|</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"now running on a worker thread"</span>);
|
||||
});</pre></div>
|
||||
</div><h4 id="method.block_on" class="method"><code>pub fn <a href="#method.block_on" class="fnname">block_on</a><F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>(&self, future: F) -> F::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#446-454" title="goto source code">[src]</a></h4><div class="docblock"><p>Run a future to completion on the Tokio runtime. This is the
|
||||
runtime's entry point.</p>
|
||||
<p>This runs the given future on the runtime, blocking until it is
|
||||
complete, and yielding its resolved result. Any tasks or timers
|
||||
which the future spawns internally will be executed on the runtime.</p>
|
||||
<h1 id="multi-thread-scheduler" class="section-header"><a href="#multi-thread-scheduler">Multi thread scheduler</a></h1>
|
||||
<p>When the multi thread scheduler is used this will allow futures
|
||||
to run within the io driver and timer context of the overall runtime.</p>
|
||||
<h1 id="current-thread-scheduler" class="section-header"><a href="#current-thread-scheduler">Current thread scheduler</a></h1>
|
||||
<p>When the current thread scheduler is enabled <code>block_on</code>
|
||||
can be called concurrently from multiple threads. The first call
|
||||
will take ownership of the io and timer drivers. This means
|
||||
other threads which do not own the drivers will hook into that one.
|
||||
When the first <code>block_on</code> completes, other threads will be able to
|
||||
"steal" the driver to allow continued execution of their futures.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>This function panics if the provided future panics, or if called within an
|
||||
asynchronous execution context.</p>
|
||||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="comment">// Create the runtime</span>
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="comment">// Execute the future, blocking the current thread until completion</span>
|
||||
<span class="ident">rt</span>.<span class="ident">block_on</span>(<span class="ident">async</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"hello"</span>);
|
||||
});</pre></div>
|
||||
</div><h4 id="method.enter" class="method"><code>pub fn <a href="#method.enter" class="fnname">enter</a>(&self) -> <a class="struct" href="../../tokio/runtime/struct.EnterGuard.html" title="struct tokio::runtime::EnterGuard">EnterGuard</a><'_></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#488-490" title="goto source code">[src]</a></h4><div class="docblock"><p>Enter the runtime context.</p>
|
||||
<p>This allows you to construct types that must have an executor
|
||||
available on creation such as <a href="../../tokio/time/struct.Sleep.html"><code>Sleep</code></a> or <a href="../../tokio/net/struct.TcpStream.html"><code>TcpStream</code></a>. It will
|
||||
also allow you to call methods such as <a href="../../tokio/fn.spawn.html"><code>tokio::spawn</code></a>.</p>
|
||||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">function_that_spawns</span>(<span class="ident">msg</span>: <span class="ident">String</span>) {
|
||||
<span class="comment">// Had we not used `rt.enter` below, this would panic.</span>
|
||||
<span class="ident">tokio</span>::<span class="ident">spawn</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">msg</span>);
|
||||
});
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">rt</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="string">"Hello World!"</span>.<span class="ident">to_string</span>();
|
||||
|
||||
<span class="comment">// By entering the context, we tie `tokio::spawn` to this executor.</span>
|
||||
<span class="kw">let</span> <span class="ident">_guard</span> <span class="op">=</span> <span class="ident">rt</span>.<span class="ident">enter</span>();
|
||||
<span class="ident">function_that_spawns</span>(<span class="ident">s</span>);
|
||||
}</pre></div>
|
||||
</div><h4 id="method.shutdown_timeout" class="method"><code>pub fn <a href="#method.shutdown_timeout" class="fnname">shutdown_timeout</a>(self, duration: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)</code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#527-531" title="goto source code">[src]</a></h4><div class="docblock"><p>Shutdown the runtime, waiting for at most <code>duration</code> for all spawned
|
||||
task to shutdown.</p>
|
||||
<p>Usually, dropping a <code>Runtime</code> handle is sufficient as tasks are able to
|
||||
shutdown in a timely fashion. However, dropping a <code>Runtime</code> will wait
|
||||
indefinitely for all tasks to terminate, and there are cases where a long
|
||||
blocking task has been spawned, which can block dropping <code>Runtime</code>.</p>
|
||||
<p>In this case, calling <code>shutdown_timeout</code> with an explicit wait timeout
|
||||
can work. The <code>shutdown_timeout</code> will signal all tasks to shutdown and
|
||||
will wait for at most <code>duration</code> for all spawned tasks to terminate. If
|
||||
<code>timeout</code> elapses before all tasks are dropped, the function returns and
|
||||
outstanding tasks are potentially leaked.</p>
|
||||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">task</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">thread</span>;
|
||||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">time</span>::<span class="ident">Duration</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">runtime</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="ident">runtime</span>.<span class="ident">block_on</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="ident">task</span>::<span class="ident">spawn_blocking</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
||||
<span class="ident">thread</span>::<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_secs</span>(<span class="number">10_000</span>));
|
||||
});
|
||||
});
|
||||
|
||||
<span class="ident">runtime</span>.<span class="ident">shutdown_timeout</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">100</span>));
|
||||
}</pre></div>
|
||||
</div><h4 id="method.shutdown_background" class="method"><code>pub fn <a href="#method.shutdown_background" class="fnname">shutdown_background</a>(self)</code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#559-561" title="goto source code">[src]</a></h4><div class="docblock"><p>Shutdown the runtime, without waiting for any spawned tasks to shutdown.</p>
|
||||
<p>This can be useful if you want to drop a runtime from within another runtime.
|
||||
Normally, dropping a runtime will block indefinitely for spawned blocking tasks
|
||||
to complete, which would normally not be permitted within an asynchronous context.
|
||||
By calling <code>shutdown_background()</code>, you can drop the runtime from such a context.</p>
|
||||
<p>Note however, that because we do not wait for any blocking tasks to complete, this
|
||||
may result in a resource leak (in that any blocking tasks are still running until they
|
||||
return.</p>
|
||||
<p>This function is equivalent to calling <code>shutdown_timeout(Duration::of_nanos(0))</code>.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">runtime</span>::<span class="ident">Runtime</span>;
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">runtime</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
|
||||
<span class="ident">runtime</span>.<span class="ident">block_on</span>(<span class="ident">async</span> <span class="kw">move</span> {
|
||||
<span class="kw">let</span> <span class="ident">inner_runtime</span> <span class="op">=</span> <span class="ident">Runtime</span>::<span class="ident">new</span>().<span class="ident">unwrap</span>();
|
||||
<span class="comment">// ...</span>
|
||||
<span class="ident">inner_runtime</span>.<span class="ident">shutdown_background</span>();
|
||||
});
|
||||
}</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#263" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/runtime/mod.rs.html#263" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime">Runtime</a></code><a href="#impl-UnwindSafe" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#552-556" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-555" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589-598" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#595-597" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#575-584" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#581-583" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user