mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
891 lines
155 KiB
HTML
891 lines
155 KiB
HTML
|
<!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="A TCP stream between a local and a remote socket."><title>TcpStream in actix_web::rt::net - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">TcpStream</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.async_io">async_io</a></li><li><a href="#method.connect">connect</a></li><li><a href="#method.from_std">from_std</a></li><li><a href="#method.into_split">into_split</a></li><li><a href="#method.into_std">into_std</a></li><li><a href="#method.linger">linger</a></li><li><a href="#method.local_addr">local_addr</a></li><li><a href="#method.nodelay">nodelay</a></li><li><a href="#method.peek">peek</a></li><li><a href="#method.peer_addr">peer_addr</a></li><li><a href="#method.poll_peek">poll_peek</a></li><li><a href="#method.poll_read_ready">poll_read_ready</a></li><li><a href="#method.poll_write_ready">poll_write_ready</a></li><li><a href="#method.readable">readable</a></li><li><a href="#method.ready">ready</a></li><li><a href="#method.set_linger">set_linger</a></li><li><a href="#method.set_nodelay">set_nodelay</a></li><li><a href="#method.set_ttl">set_ttl</a></li><li><a href="#method.split">split</a></li><li><a href="#method.take_error">take_error</a></li><li><a href="#method.try_io">try_io</a></li><li><a href="#method.try_read">try_read</a></li><li><a href="#method.try_read_buf">try_read_buf</a></li><li><a href="#method.try_read_vectored">try_read_vectored</a></li><li><a href="#method.try_write">try_write</a></li><li><a href="#method.try_write_vectored">try_write_vectored</a></li><li><a href="#method.ttl">ttl</a></li><li><a href="#method.writable">writable</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsFd-for-TcpStream">AsFd</a></li><li><a href="#impl-AsRawFd-for-TcpStream">AsRawFd</a></li><li><a href="#impl-AsyncRead-for-TcpS
|
|||
|
<p>A TCP stream can either be created by connecting to an endpoint, via the
|
|||
|
<a href="struct.TcpStream.html#method.connect" title="associated function actix_web::rt::net::TcpStream::connect"><code>connect</code></a> method, or by <a href="struct.TcpListener.html#method.accept" title="method actix_web::rt::net::TcpListener::accept">accepting</a> a connection from a <a href="struct.TcpListener.html" title="struct actix_web::rt::net::TcpListener">listener</a>. A
|
|||
|
TCP stream can also be created via the <a href="struct.TcpSocket.html" title="struct actix_web::rt::net::TcpSocket"><code>TcpSocket</code></a> type.</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>
|
|||
|
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>tokio::io::AsyncWriteExt;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span><span class="kw-2">mut </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Write some data.
|
|||
|
</span>stream.write_all(<span class="string">b"hello world!"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></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></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-TcpStream" class="impl"><a href="#impl-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.connect" class="method"><h4 class="code-header">pub async fn <a href="#method.connect" class="fn">connect</a><A>(addr: 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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</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>><div class="where">where
|
|||
|
A: ToSocketAddrs,</div></h4></section><span class="item-info"><div class="stab portability">Available on <strong>non-WASI</strong> only.</div></span></summary><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="trait@crate::net::ToSocketAddrs"><code>ToSocketAddrs</code></a> trait can be supplied as the address. 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>
|
|||
|
<p>To configure the socket before connecting, you can use the <a href="struct.TcpSocket.html" title="struct actix_web::rt::net::TcpSocket"><code>TcpSocket</code></a>
|
|||
|
type.</p>
|
|||
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>tokio::io::AsyncWriteExt;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span><span class="kw-2">mut </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Write some data.
|
|||
|
</span>stream.write_all(<span class="string">b"hello world!"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></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></details><details class="toggle method-toggle" open><summary><section id="method.from_std" class="method"><h4 class="code-header">pub fn <a href="#method.from_std" class="fn">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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</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>></h4></section></summary><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.</p>
|
|||
|
<h5 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h5>
|
|||
|
<p>The caller is responsible for ensuring that the stream is in
|
|||
|
non-blocking mode. Otherwise all I/O operations on the stream
|
|||
|
will block the thread, which will cause unexpected behavior.
|
|||
|
Non-blocking mode can be set using <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html#method.set_nonblocking" title="method std::net::tcp::TcpStream::set_nonblocking"><code>set_nonblocking</code></a>.</p>
|
|||
|
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="kw">let </span>std_stream = std::net::TcpStream::connect(<span class="string">"127.0.0.1:34254"</span>)<span class="question-mark">?</span>;
|
|||
|
std_stream.set_nonblocking(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>stream = TcpStream::from_std(std_stream)<span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
|||
|
<p>This function panics if it is not called from within a runtime with
|
|||
|
IO enabled.</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="crate::runtime::Runtime::enter"><code>Runtime::enter</code></a> function.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_std" class="method"><h4 class="code-header">pub fn <a href="#method.into_std" class="fn">into_std</a>(self) -> <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="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</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>></h4></section></summary><div class="docblock"><p>Turns a <a href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream"><code>tokio::net::TcpStream</code></a> into a <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream"><code>std::net::TcpStream</code></a>.</p>
|
|||
|
<p>The returned <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream"><code>std::net::TcpStream</code></a> will have nonblocking mode set as <code>true</code>.
|
|||
|
Use <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html#method.set_nonblocking" title="method std::net::tcp::TcpStream::set_nonblocking"><code>set_nonblocking</code></a> to change the blocking mode if needed.</p>
|
|||
|
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io::Read;
|
|||
|
<span class="kw">use </span>tokio::net::TcpListener;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>data = [<span class="number">0u8</span>; <span class="number">12</span>];
|
|||
|
<span class="kw">let </span>listener = TcpListener::bind(<span class="string">"127.0.0.1:34254"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>(tokio_tcp_stream, <span class="kw">_</span>) = listener.accept().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>std_tcp_stream = tokio_tcp_stream.into_std()<span class="question-mark">?</span>;
|
|||
|
std_tcp_stream.set_nonblocking(<span class="bool-val">false</span>)<span class="question-mark">?</span>;
|
|||
|
std_tcp_stream.read_exact(<span class="kw-2">&mut </span>data)<span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.local_addr" class="method"><h4 class="code-header">pub fn <a href="#method.local_addr" class="fn">local_addr</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</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>></h4></section></summary><div class="docblock"><p>Returns the local address that this stream is bound to.</p>
|
|||
|
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, stream.local_addr()<span class="question-mark">?</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take_error" class="method"><h4 class="code-header">pub fn <a href="#method.take_error" class="fn">take_error</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::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>>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Returns the value of the <code>SO_ERROR</code> option.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.peer_addr" class="method"><h4 class="code-header">pub fn <a href="#method.peer_addr" class="fn">peer_addr</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</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>></h4></section></summary><div class="docblock"><p>Returns the remote address that this stream is connected to.</p>
|
|||
|
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, stream.peer_addr()<span class="question-mark">?</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.poll_peek" class="method"><h4 class="code-header">pub fn <a href="#method.poll_peek" class="fn">poll_peek</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: &mut ReadBuf<'_>
|
|||
|
) -> <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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>>></h4></section></summary><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>
|
|||
|
<h5 id="return-value"><a class="doc-anchor" href="#return-value">§</a>Return value</h5>
|
|||
|
<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>
|
|||
|
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
|
|||
|
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
|||
|
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::io::{<span class="self">self</span>, ReadBuf};
|
|||
|
<span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">use </span>futures::future::poll_fn;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> io::Result<()> {
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8000"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0</span>; <span class="number">10</span>];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = ReadBuf::new(<span class="kw-2">&mut </span>buf);
|
|||
|
|
|||
|
poll_fn(|cx| {
|
|||
|
stream.poll_peek(cx, <span class="kw-2">&mut </span>buf)
|
|||
|
}).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.ready" class="method"><h4 class="code-header">pub async fn <a href="#method.ready" class="fn">ready</a>(&self, interest: Interest) -> <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="struct.Ready.html" title="struct actix_web::rt::net::Ready">Ready</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>></h4></section></summary><div class="docblock"><p>Waits 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>
|
|||
|
<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>. The function can also return with an empty
|
|||
|
<a href="struct.Ready.html" title="struct actix_web::rt::net::Ready"><code>Ready</code></a> set, so you should always check the returned value and possibly
|
|||
|
wait again if the requested states are not set.</p>
|
|||
|
<h5 id="cancel-safety"><a class="doc-anchor" href="#cancel-safety">§</a>Cancel safety</h5>
|
|||
|
<p>This method is cancel safe. Once a readiness event occurs, the method
|
|||
|
will continue to return immediately until the readiness event is
|
|||
|
consumed by an attempt to read or write that fails with <code>WouldBlock</code> or
|
|||
|
<code>Poll::Pending</code>.</p>
|
|||
|
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
|||
|
<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"><code><span class="kw">use </span>tokio::io::Interest;
|
|||
|
<span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="kw">let </span>ready = stream.ready(Interest::READABLE | Interest::WRITABLE).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">if </span>ready.is_readable() {
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>data = <span class="macro">vec!</span>[<span class="number">0</span>; <span class="number">1024</span>];
|
|||
|
<span class="comment">// Try to read data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_read(<span class="kw-2">&mut </span>data) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="macro">println!</span>(<span class="string">"read {} bytes"</span>, n);
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
<span class="kw">if </span>ready.is_writable() {
|
|||
|
<span class="comment">// Try to write data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_write(<span class="string">b"hello world"</span>) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="macro">println!</span>(<span class="string">"write {} bytes"</span>, n);
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue
|
|||
|
</span>}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.readable" class="method"><h4 class="code-header">pub async fn <a href="#method.readable" class="fn">readable</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>></h4></section></summary><div class="docblock"><p>Waits 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>
|
|||
|
<h5 id="cancel-safety-1"><a class="doc-anchor" href="#cancel-safety-1">§</a>Cancel safety</h5>
|
|||
|
<p>This method is cancel safe. Once a readiness event occurs, the method
|
|||
|
will continue to return immediately until the readiness event is
|
|||
|
consumed by an attempt to read that fails with <code>WouldBlock</code> or
|
|||
|
<code>Poll::Pending</code>.</p>
|
|||
|
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>msg = <span class="macro">vec!</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>stream.readable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Try to read data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_read(<span class="kw-2">&mut </span>msg) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
msg.truncate(n);
|
|||
|
<span class="kw">break</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"GOT = {:?}"</span>, msg);
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.poll_read_ready" class="method"><h4 class="code-header">pub fn <a href="#method.poll_read_ready" class="fn">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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>>></h4></section></summary><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="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable</code></a> is not feasible. Where possible, using <a href="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable</code></a> is
|
|||
|
preferred, as this supports polling from multiple tasks at once.</p>
|
|||
|
<h5 id="return-value-1"><a class="doc-anchor" href="#return-value-1">§</a>Return value</h5>
|
|||
|
<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>
|
|||
|
<h5 id="errors-1"><a class="doc-anchor" href="#errors-1">§</a>Errors</h5>
|
|||
|
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_read" class="method"><h4 class="code-header">pub fn <a href="#method.try_read" class="fn">try_read</a>(&self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>></h4></section></summary><div class="docblock"><p>Tries 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="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable()</code></a> or <a href="struct.TcpStream.html#method.ready" title="method actix_web::rt::net::TcpStream::ready"><code>ready()</code></a> is used with this function.</p>
|
|||
|
<h5 id="return"><a class="doc-anchor" href="#return">§</a>Return</h5>
|
|||
|
<p>If data is successfully read, <code>Ok(n)</code> is returned, where <code>n</code> is the
|
|||
|
number of bytes read. If <code>n</code> is <code>0</code>, then it can indicate one of two scenarios:</p>
|
|||
|
<ol>
|
|||
|
<li>The stream’s read half is closed and will no longer yield data.</li>
|
|||
|
<li>The specified buffer was 0 bytes in length.</li>
|
|||
|
</ol>
|
|||
|
<p>If the stream is not ready to read data,
|
|||
|
<code>Err(io::ErrorKind::WouldBlock)</code> is returned.</p>
|
|||
|
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be readable
|
|||
|
</span>stream.readable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Creating the buffer **after** the `await` prevents it from
|
|||
|
// being stored in the async task.
|
|||
|
</span><span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0</span>; <span class="number">4096</span>];
|
|||
|
|
|||
|
<span class="comment">// Try to read data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_read(<span class="kw-2">&mut </span>buf) {
|
|||
|
<span class="prelude-val">Ok</span>(<span class="number">0</span>) => <span class="kw">break</span>,
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="macro">println!</span>(<span class="string">"read {} bytes"</span>, n);
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_read_vectored" class="method"><h4 class="code-header">pub fn <a href="#method.try_read_vectored" class="fn">try_read_vectored</a>(
|
|||
|
&self,
|
|||
|
bufs: &mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>></h4></section></summary><div class="docblock"><p>Tries to read data from the stream into the provided buffers, returning
|
|||
|
how many bytes were read.</p>
|
|||
|
<p>Data is copied to fill each buffer in order, with the final buffer
|
|||
|
written to possibly being only partially filled. This method behaves
|
|||
|
equivalently to a single call to <a href="struct.TcpStream.html#method.try_read" title="method actix_web::rt::net::TcpStream::try_read"><code>try_read()</code></a> with concatenated
|
|||
|
buffers.</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_vectored()</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="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable()</code></a> or <a href="struct.TcpStream.html#method.ready" title="method actix_web::rt::net::TcpStream::ready"><code>ready()</code></a> is used with this function.</p>
|
|||
|
<h5 id="return-1"><a class="doc-anchor" href="#return-1">§</a>Return</h5>
|
|||
|
<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>
|
|||
|
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io::{<span class="self">self</span>, IoSliceMut};
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be readable
|
|||
|
</span>stream.readable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Creating the buffer **after** the `await` prevents it from
|
|||
|
// being stored in the async task.
|
|||
|
</span><span class="kw">let </span><span class="kw-2">mut </span>buf_a = [<span class="number">0</span>; <span class="number">512</span>];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf_b = [<span class="number">0</span>; <span class="number">1024</span>];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>bufs = [
|
|||
|
IoSliceMut::new(<span class="kw-2">&mut </span>buf_a),
|
|||
|
IoSliceMut::new(<span class="kw-2">&mut </span>buf_b),
|
|||
|
];
|
|||
|
|
|||
|
<span class="comment">// Try to read data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_read_vectored(<span class="kw-2">&mut </span>bufs) {
|
|||
|
<span class="prelude-val">Ok</span>(<span class="number">0</span>) => <span class="kw">break</span>,
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="macro">println!</span>(<span class="string">"read {} bytes"</span>, n);
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_read_buf" class="method"><h4 class="code-header">pub fn <a href="#method.try_read_buf" class="fn">try_read_buf</a><B>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut B</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>><div class="where">where
|
|||
|
B: <a class="trait" href="../../web/trait.BufMut.html" title="trait actix_web::web::BufMut">BufMut</a>,</div></h4></section><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>io-util</code></strong> only.</div></span></summary><div class="docblock"><p>Tries to read data from the stream into the provided buffer, advancing the
|
|||
|
buffer’s internal cursor, 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_buf()</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="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable()</code></a> or <a href="struct.TcpStream.html#method.ready" title="method actix_web::rt::net::TcpStream::ready"><code>ready()</code></a> is used with this function.</p>
|
|||
|
<h5 id="return-2"><a class="doc-anchor" href="#return-2">§</a>Return</h5>
|
|||
|
<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>
|
|||
|
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be readable
|
|||
|
</span>stream.readable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = Vec::with_capacity(<span class="number">4096</span>);
|
|||
|
|
|||
|
<span class="comment">// Try to read data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_read_buf(<span class="kw-2">&mut </span>buf) {
|
|||
|
<span class="prelude-val">Ok</span>(<span class="number">0</span>) => <span class="kw">break</span>,
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="macro">println!</span>(<span class="string">"read {} bytes"</span>, n);
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.writable" class="method"><h4 class="code-header">pub async fn <a href="#method.writable" class="fn">writable</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>></h4></section></summary><div class="docblock"><p>Waits 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>
|
|||
|
<h5 id="cancel-safety-2"><a class="doc-anchor" href="#cancel-safety-2">§</a>Cancel safety</h5>
|
|||
|
<p>This method is cancel safe. Once a readiness event occurs, the method
|
|||
|
will continue to return immediately until the readiness event is
|
|||
|
consumed by an attempt to write that fails with <code>WouldBlock</code> or
|
|||
|
<code>Poll::Pending</code>.</p>
|
|||
|
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be writable
|
|||
|
</span>stream.writable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Try to write data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_write(<span class="string">b"hello world"</span>) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="kw">break</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.poll_write_ready" class="method"><h4 class="code-header">pub fn <a href="#method.poll_write_ready" class="fn">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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>>></h4></section></summary><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="struct.TcpStream.html#method.writable" title="method actix_web::rt::net::TcpStream::writable"><code>writable</code></a> is not feasible. Where possible, using <a href="struct.TcpStream.html#method.writable" title="method actix_web::rt::net::TcpStream::writable"><code>writable</code></a> is
|
|||
|
preferred, as this supports polling from multiple tasks at once.</p>
|
|||
|
<h5 id="return-value-2"><a class="doc-anchor" href="#return-value-2">§</a>Return value</h5>
|
|||
|
<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>
|
|||
|
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</h5>
|
|||
|
<p>This function may encounter any standard I/O error except <code>WouldBlock</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_write" class="method"><h4 class="code-header">pub fn <a href="#method.try_write" class="fn">try_write</a>(&self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>></h4></section></summary><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>
|
|||
|
<h5 id="return-3"><a class="doc-anchor" href="#return-3">§</a>Return</h5>
|
|||
|
<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>
|
|||
|
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be writable
|
|||
|
</span>stream.writable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Try to write data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_write(<span class="string">b"hello world"</span>) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="kw">break</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_write_vectored" class="method"><h4 class="code-header">pub fn <a href="#method.try_write_vectored" class="fn">try_write_vectored</a>(&self, bufs: &[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>></h4></section></summary><div class="docblock"><p>Tries to write several buffers to the stream, returning how many bytes
|
|||
|
were written.</p>
|
|||
|
<p>Data is written from each buffer in order, with the final buffer read
|
|||
|
from possible being only partially consumed. This method behaves
|
|||
|
equivalently to a single call to <a href="struct.TcpStream.html#method.try_write" title="method actix_web::rt::net::TcpStream::try_write"><code>try_write()</code></a> with concatenated
|
|||
|
buffers.</p>
|
|||
|
<p>This function is usually paired with <code>writable()</code>.</p>
|
|||
|
<h5 id="return-4"><a class="doc-anchor" href="#return-4">§</a>Return</h5>
|
|||
|
<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>
|
|||
|
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
<span class="kw">use </span>std::io;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">let </span>bufs = [io::IoSlice::new(<span class="string">b"hello "</span>), io::IoSlice::new(<span class="string">b"world"</span>)];
|
|||
|
|
|||
|
<span class="kw">loop </span>{
|
|||
|
<span class="comment">// Wait for the socket to be writable
|
|||
|
</span>stream.writable().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Try to write data, this may still fail with `WouldBlock`
|
|||
|
// if the readiness event is a false positive.
|
|||
|
</span><span class="kw">match </span>stream.try_write_vectored(<span class="kw-2">&</span>bufs) {
|
|||
|
<span class="prelude-val">Ok</span>(n) => {
|
|||
|
<span class="kw">break</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(<span class="kw-2">ref </span>e) <span class="kw">if </span>e.kind() == io::ErrorKind::WouldBlock => {
|
|||
|
<span class="kw">continue</span>;
|
|||
|
}
|
|||
|
<span class="prelude-val">Err</span>(e) => {
|
|||
|
<span class="kw">return </span><span class="prelude-val">Err</span>(e.into());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_io" class="method"><h4 class="code-header">pub fn <a href="#method.try_io" class="fn">try_io</a><R>(
|
|||
|
&self,
|
|||
|
interest: Interest,
|
|||
|
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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><R, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>
|
|||
|
) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><R, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Tries to read or write from the socket using a user-provided IO operation.</p>
|
|||
|
<p>If the socket is ready, the provided closure is called. The closure
|
|||
|
should attempt to perform IO operation on the socket by manually
|
|||
|
calling the appropriate syscall. If the operation fails because the
|
|||
|
socket is not actually ready, then the closure should return a
|
|||
|
<code>WouldBlock</code> error and the readiness flag is cleared. The return value
|
|||
|
of the closure is then returned by <code>try_io</code>.</p>
|
|||
|
<p>If the socket is not ready, then the closure is not called
|
|||
|
and a <code>WouldBlock</code> error is returned.</p>
|
|||
|
<p>The closure should only return a <code>WouldBlock</code> error if it has performed
|
|||
|
an IO operation on the socket that failed due to the socket not being
|
|||
|
ready. Returning a <code>WouldBlock</code> error in any other situation will
|
|||
|
incorrectly clear the readiness flag, which can cause the socket to
|
|||
|
behave incorrectly.</p>
|
|||
|
<p>The closure should not perform the IO operation using any of the methods
|
|||
|
defined on the Tokio <code>TcpStream</code> type, as this will mess with the
|
|||
|
readiness flag and can cause the socket to behave incorrectly.</p>
|
|||
|
<p>This method is not intended to be used with combined interests.
|
|||
|
The closure should perform only one type of IO operation, so it should not
|
|||
|
require more than one ready state. This method may panic or sleep forever
|
|||
|
if it is called with a combined interest.</p>
|
|||
|
<p>Usually, <a href="struct.TcpStream.html#method.readable" title="method actix_web::rt::net::TcpStream::readable"><code>readable()</code></a>, <a href="struct.TcpStream.html#method.writable" title="method actix_web::rt::net::TcpStream::writable"><code>writable()</code></a> or <a href="struct.TcpStream.html#method.ready" title="method actix_web::rt::net::TcpStream::ready"><code>ready()</code></a> is used with this function.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.async_io" class="method"><h4 class="code-header">pub async fn <a href="#method.async_io" class="fn">async_io</a><R>(
|
|||
|
&self,
|
|||
|
interest: Interest,
|
|||
|
f: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>() -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><R, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>
|
|||
|
) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><R, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Reads or writes from the socket using a user-provided IO operation.</p>
|
|||
|
<p>The readiness of the socket is awaited and when the socket is ready,
|
|||
|
the provided closure is called. The closure should attempt to perform
|
|||
|
IO operation on the socket by manually calling the appropriate syscall.
|
|||
|
If the operation fails because the socket is not actually ready,
|
|||
|
then the closure should return a <code>WouldBlock</code> error. In such case the
|
|||
|
readiness flag is cleared and the socket readiness is awaited again.
|
|||
|
This loop is repeated until the closure returns an <code>Ok</code> or an error
|
|||
|
other than <code>WouldBlock</code>.</p>
|
|||
|
<p>The closure should only return a <code>WouldBlock</code> error if it has performed
|
|||
|
an IO operation on the socket that failed due to the socket not being
|
|||
|
ready. Returning a <code>WouldBlock</code> error in any other situation will
|
|||
|
incorrectly clear the readiness flag, which can cause the socket to
|
|||
|
behave incorrectly.</p>
|
|||
|
<p>The closure should not perform the IO operation using any of the methods
|
|||
|
defined on the Tokio <code>TcpStream</code> type, as this will mess with the
|
|||
|
readiness flag and can cause the socket to behave incorrectly.</p>
|
|||
|
<p>This method is not intended to be used with combined interests.
|
|||
|
The closure should perform only one type of IO operation, so it should not
|
|||
|
require more than one ready state. This method may panic or sleep forever
|
|||
|
if it is called with a combined interest.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek" class="method"><h4 class="code-header">pub async fn <a href="#method.peek" class="fn">peek</a>(&self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>></h4></section></summary><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 <code>recv</code> system call.</p>
|
|||
|
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
<span class="kw">use </span>tokio::io::AsyncReadExt;
|
|||
|
<span class="kw">use </span>std::error::Error;
|
|||
|
|
|||
|
<span class="attr">#[tokio::main]
|
|||
|
</span><span class="kw">async fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
|||
|
<span class="comment">// Connect to a peer
|
|||
|
</span><span class="kw">let </span><span class="kw-2">mut </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>b1 = [<span class="number">0</span>; <span class="number">10</span>];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>b2 = [<span class="number">0</span>; <span class="number">10</span>];
|
|||
|
|
|||
|
<span class="comment">// Peek at the data
|
|||
|
</span><span class="kw">let </span>n = stream.peek(<span class="kw-2">&mut </span>b1).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Read the data
|
|||
|
</span><span class="macro">assert_eq!</span>(n, stream.read(<span class="kw-2">&mut </span>b2[..n]).<span class="kw">await</span><span class="question-mark">?</span>);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>b1[..n], <span class="kw-2">&</span>b2[..n]);
|
|||
|
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
}</code></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></details><details class="toggle method-toggle" open><summary><section id="method.nodelay" class="method"><h4 class="code-header">pub fn <a href="#method.nodelay" class="fn">nodelay</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</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>></h4></section></summary><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="struct.TcpStream.html#method.set_nodelay" title="method actix_web::rt::net::TcpStream::set_nodelay"><code>set_nodelay</code></a>.</p>
|
|||
|
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, stream.nodelay()<span class="question-mark">?</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_nodelay" class="method"><h4 class="code-header">pub fn <a href="#method.set_nodelay" class="fn">set_nodelay</a>(&self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>></h4></section></summary><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>
|
|||
|
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
stream.set_nodelay(<span class="bool-val">true</span>)<span class="question-mark">?</span>;</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.linger" class="method"><h4 class="code-header">pub fn <a href="#method.linger" class="fn">linger</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::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>>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section><span class="item-info"><div class="stab portability">Available on <strong>non-WASI</strong> only.</div></span></summary><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="struct.TcpStream.html#method.set_linger" title="method actix_web::rt::net::TcpStream::set_linger"><code>set_linger</code></a>.</p>
|
|||
|
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, stream.linger()<span class="question-mark">?</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_linger" class="method"><h4 class="code-header">pub fn <a href="#method.set_linger" class="fn">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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>></h4></section><span class="item-info"><div class="stab portability">Available on <strong>non-WASI</strong> only.</div></span></summary><div class="docblock"><p>Sets the linger duration of this socket by setting the <code>SO_LINGER</code> option.</p>
|
|||
|
<p>This option controls the action taken when a stream has unsent messages and the stream is
|
|||
|
closed. If <code>SO_LINGER</code> is set, the system shall block the process until it can transmit the
|
|||
|
data or until the time expires.</p>
|
|||
|
<p>If <code>SO_LINGER</code> 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>
|
|||
|
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
stream.set_linger(<span class="prelude-val">None</span>)<span class="question-mark">?</span>;</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.ttl" class="method"><h4 class="code-header">pub fn <a href="#method.ttl" class="fn">ttl</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</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>></h4></section></summary><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="struct.TcpStream.html#method.set_ttl" title="method actix_web::rt::net::TcpStream::set_ttl"><code>set_ttl</code></a>.</p>
|
|||
|
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, stream.ttl()<span class="question-mark">?</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_ttl" class="method"><h4 class="code-header">pub fn <a href="#method.set_ttl" class="fn">set_ttl</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>></h4></section></summary><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>
|
|||
|
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::TcpStream;
|
|||
|
|
|||
|
<span class="kw">let </span>stream = TcpStream::connect(<span class="string">"127.0.0.1:8080"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
stream.set_ttl(<span class="number">123</span>)<span class="question-mark">?</span>;</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.split" class="method"><h4 class="code-header">pub fn <a href="#method.split" class="fn">split</a><'a>(&'a mut self) -> (ReadHalf<'a>, WriteHalf<'a>)</h4></section></summary><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="struct.TcpStream.html#method.into_split" title="method actix_web::rt::net::TcpStream::into_split"><code>into_split</code></a>, but the halves cannot be
|
|||
|
moved into independently spawned tasks.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_split" class="method"><h4 class="code-header">pub fn <a href="#method.into_split" class="fn">into_split</a>(self) -> (OwnedReadHalf, OwnedWriteHalf)</h4></section></summary><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="struct.TcpStream.html#method.split" title="method actix_web::rt::net::TcpStream::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></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsFd-for-TcpStream" class="impl"><a href="#impl-AsFd-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/os/fd/owned/trait.AsFd.html" title="trait std::os::fd::owned::AsFd">AsFd</a> for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_fd" class="method trait-impl"><a href="#method.as_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd" class="fn">as_fd</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/os/fd/owned/struct.BorrowedFd.html" title="struct std::os::fd::owned::BorrowedFd">BorrowedFd</a><'_></h4></section></summary><div class='docblock'>Borrows the file descriptor. <a href="https://doc.rust-lang.org/nightly/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsRawFd-for-TcpStream" class="impl"><a href="#impl-AsRawFd-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a> for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_raw_fd" class="method trait-impl"><a href="#method.as_raw_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd" class="fn">as_raw_fd</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></h4></section></summary><div class='docblock'>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsyncRead-for-TcpStream" class="impl"><a href="#impl-AsyncRead-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl AsyncRead for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.poll_read" class="method trait-impl"><a href="#method.poll_read" class="anchor">§</a><h4 class="code-header">fn <a class="fn">poll_read</a>(
|
|||
|
self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><&mut <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>>,
|
|||
|
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: &mut ReadBuf<'_>
|
|||
|
) -> <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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>>></h4></section></summary><div class='docblock'>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsyncWrite-for-TcpStream" class="impl"><a href="#impl-AsyncWrite-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl AsyncWrite for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.poll_write" class="method trait-impl"><a href="#method.poll_write" class="anchor">§</a><h4 class="code-header">fn <a class="fn">poll_write</a>(
|
|||
|
self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><&mut <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>>,
|
|||
|
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.u8.html">u8</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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>>></h4></section></summary><div class='docblock'>Attempt to write bytes from <code>buf</code> into the object. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.poll_write_vectored" class="method trait-impl"><a href="#method.poll_write_vectored" class="anchor">§</a><h4 class="code-header">fn <a class="fn">poll_write_vectored</a>(
|
|||
|
self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><&mut <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>>,
|
|||
|
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><'_>,
|
|||
|
bufs: &[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</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>>></h4></section></summary><div class='docblock'>Like <a href="AsyncWrite::poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_write_vectored" class="method trait-impl"><a href="#method.is_write_vectored" class="anchor">§</a><h4 class="code-header">fn <a class="fn">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Determines if this writer has an efficient <a href="AsyncWrite::poll_write_vectored"><code>poll_write_vectored</code></a>
|
|||
|
implementation. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.poll_flush" class="method trait-impl"><a href="#method.poll_flush" class="anchor">§</a><h4 class="code-header">fn <a class="fn">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><&mut <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>>,
|
|||
|
_: &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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>>></h4></section></summary><div class='docblock'>Attempts to flush the object, ensuring that any buffered data reach
|
|||
|
their destination. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.poll_shutdown" class="method trait-impl"><a href="#method.poll_shutdown" class="anchor">§</a><h4 class="code-header">fn <a class="fn">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><&mut <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>>,
|
|||
|
_: &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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</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>>></h4></section></summary><div class='docblock'>Initiates or attempts to shut down this writer, returning success when
|
|||
|
the I/O connection has completely shut down. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-TcpStream" class="impl"><a href="#impl-Debug-for-TcpStream" class="anchor">§</a><h3 class="code-header">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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>></h4></section></summary><div class='docblock'>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></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromStream-for-TcpStream" class="impl"><a href="#impl-FromStream-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl FromStream for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><section id="method.from_mio" class="method trait-impl"><a href="#method.from_mio" class="anchor">§</a><h4 class="code-header">fn <a class="fn">from_mio</a>(sock: MioStream) -> <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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</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>></h4></section></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-TryFrom%3CTcpStream%3E-for-TcpStream" class="impl"><a href="#impl-TryFrom%3CTcpStream%3E-for-TcpStream" class="anchor">§</a><h3 class="code-header">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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">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><<a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a>, <<a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a> as <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>>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
|
|||
|
<p>This is equivalent to
|
|||
|
<a href="struct.TcpStream.html#method.from_std" title="associated function actix_web::rt::net::TcpStream::from_std"><code>TcpStream::from_std(stream)</code></a>.</p>
|
|||
|
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">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></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-TcpStream" class="impl"><a href="#impl-Freeze-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section><section id="impl-RefUnwindSafe-for-TcpStream" class="impl"><a href="#impl-RefUnwindSafe-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section><section id="impl-Send-for-TcpStream" class="impl"><a href="#impl-Send-for-TcpStream" class="anchor">§</a><h3 class="code-header">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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section><section id="impl-Sync-for-TcpStream" class="impl"><a href="#impl-Sync-for-TcpStream" class="anchor">§</a><h3 class="code-header">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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section><section id="impl-Unpin-for-TcpStream" class="impl"><a href="#impl-Unpin-for-TcpStream" class="anchor">§</a><h3 class="code-header">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="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section><section id="impl-UnwindSafe-for-TcpStream" class="impl"><a href="#impl-UnwindSafe-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.TcpStream.html" title="struct actix_web::rt::net::TcpStream">TcpStream</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">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></h4></section></summary><div class='docblock'>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></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-AsyncReadExt-for-R" class="impl"><a href="#impl-AsyncReadExt-for-R" class="anchor">§</a><h3 class="code-header">impl<R> AsyncReadExt for R<div class="where">where
|
|||
|
R: AsyncRead + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.chain" class="method trait-impl"><a href="#method.chain" class="anchor">§</a><h4 class="code-header">fn <a class="fn">chain</a><R>(self, next: R) -> Chain<Self, R><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
R: AsyncRead,</div></h4></section></summary><div class='docblock'>Creates a new <code>AsyncRead</code> instance that chains this stream with
|
|||
|
<code>next</code>. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read" class="method trait-impl"><a href="#method.read" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read</a><'a>(&'a mut self, buf: &'a mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -> Read<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Pulls some bytes from this source into the specified buffer,
|
|||
|
returning how many bytes were read. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf" class="method trait-impl"><a href="#method.read_buf" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_buf</a><'a, B>(&'a mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut B</a>) -> ReadBuf<'a, Self, B><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,
|
|||
|
B: <a class="trait" href="../../web/trait.BufMut.html" title="trait actix_web::web::BufMut">BufMut</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Pulls some bytes from this source into the specified buffer,
|
|||
|
advancing the buffer’s internal cursor. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_exact" class="method trait-impl"><a href="#method.read_exact" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_exact</a><'a>(&'a mut self, buf: &'a mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -> ReadExact<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads the exact number of bytes required to fill <code>buf</code>. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u8" class="method trait-impl"><a href="#method.read_u8" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u8</a>(&mut self) -> ReadU8<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 8 bit integer from the underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i8" class="method trait-impl"><a href="#method.read_i8" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i8</a>(&mut self) -> ReadI8<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads a signed 8 bit integer from the underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u16" class="method trait-impl"><a href="#method.read_u16" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u16</a>(&mut self) -> ReadU16<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 16-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i16" class="method trait-impl"><a href="#method.read_i16" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i16</a>(&mut self) -> ReadI16<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads a signed 16-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u32" class="method trait-impl"><a href="#method.read_u32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u32</a>(&mut self) -> ReadU32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 32-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i32" class="method trait-impl"><a href="#method.read_i32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i32</a>(&mut self) -> ReadI32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads a signed 32-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u64" class="method trait-impl"><a href="#method.read_u64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u64</a>(&mut self) -> ReadU64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 64-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i64" class="method trait-impl"><a href="#method.read_i64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i64</a>(&mut self) -> ReadI64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an signed 64-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u128" class="method trait-impl"><a href="#method.read_u128" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u128</a>(&mut self) -> ReadU128<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 128-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i128" class="method trait-impl"><a href="#method.read_i128" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i128</a>(&mut self) -> ReadI128<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an signed 128-bit integer in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_f32" class="method trait-impl"><a href="#method.read_f32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_f32</a>(&mut self) -> ReadF32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an 32-bit floating point type in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_f64" class="method trait-impl"><a href="#method.read_f64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_f64</a>(&mut self) -> ReadF64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an 64-bit floating point type in big-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u16_le" class="method trait-impl"><a href="#method.read_u16_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u16_le</a>(&mut self) -> ReadU16Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 16-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i16_le" class="method trait-impl"><a href="#method.read_i16_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i16_le</a>(&mut self) -> ReadI16Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads a signed 16-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u32_le" class="method trait-impl"><a href="#method.read_u32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u32_le</a>(&mut self) -> ReadU32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 32-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i32_le" class="method trait-impl"><a href="#method.read_i32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i32_le</a>(&mut self) -> ReadI32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads a signed 32-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u64_le" class="method trait-impl"><a href="#method.read_u64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u64_le</a>(&mut self) -> ReadU64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 64-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i64_le" class="method trait-impl"><a href="#method.read_i64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i64_le</a>(&mut self) -> ReadI64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an signed 64-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_u128_le" class="method trait-impl"><a href="#method.read_u128_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_u128_le</a>(&mut self) -> ReadU128Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an unsigned 128-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_i128_le" class="method trait-impl"><a href="#method.read_i128_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_i128_le</a>(&mut self) -> ReadI128Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an signed 128-bit integer in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_f32_le" class="method trait-impl"><a href="#method.read_f32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_f32_le</a>(&mut self) -> ReadF32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an 32-bit floating point type in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_f64_le" class="method trait-impl"><a href="#method.read_f64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_f64_le</a>(&mut self) -> ReadF64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads an 64-bit floating point type in little-endian order from the
|
|||
|
underlying reader. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_end" class="method trait-impl"><a href="#method.read_to_end" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_to_end</a><'a>(&'a mut self, buf: &'a mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>>) -> ReadToEnd<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, placing them into <code>buf</code>. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_string" class="method trait-impl"><a href="#method.read_to_string" class="anchor">§</a><h4 class="code-header">fn <a class="fn">read_to_string</a><'a>(
|
|||
|
&'a mut self,
|
|||
|
dst: &'a mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>
|
|||
|
) -> ReadToString<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, appending them to <code>buf</code>. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method trait-impl"><a href="#method.take" class="anchor">§</a><h4 class="code-header">fn <a class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> Take<Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adaptor which reads at most <code>limit</code> bytes from it. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-AsyncWriteExt-for-W" class="impl"><a href="#impl-AsyncWriteExt-for-W" class="anchor">§</a><h3 class="code-header">impl<W> AsyncWriteExt for W<div class="where">where
|
|||
|
W: AsyncWrite + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.write" class="method trait-impl"><a href="#method.write" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write</a><'a>(&'a mut self, src: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -> Write<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a buffer into this writer, returning how many bytes were
|
|||
|
written. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_vectored" class="method trait-impl"><a href="#method.write_vectored" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_vectored</a><'a, 'b>(
|
|||
|
&'a mut self,
|
|||
|
bufs: &'a [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'b>]
|
|||
|
) -> WriteVectored<'a, 'b, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Like <a href="AsyncWriteExt::write"><code>write</code></a>, except that it writes from a slice of buffers. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_buf" class="method trait-impl"><a href="#method.write_buf" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_buf</a><'a, B>(&'a mut self, src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut B</a>) -> WriteBuf<'a, Self, B><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,
|
|||
|
B: <a class="trait" href="../../web/trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,</div></h4></section></summary><div class='docblock'>Writes a buffer into this writer, advancing the buffer’s internal
|
|||
|
cursor. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all_buf" class="method trait-impl"><a href="#method.write_all_buf" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_all_buf</a><'a, B>(
|
|||
|
&'a mut self,
|
|||
|
src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut B</a>
|
|||
|
) -> WriteAllBuf<'a, Self, B><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,
|
|||
|
B: <a class="trait" href="../../web/trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,</div></h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all" class="method trait-impl"><a href="#method.write_all" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_all</a><'a>(&'a mut self, src: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -> WriteAll<'a, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u8" class="method trait-impl"><a href="#method.write_u8" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> WriteU8<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 8-bit integer to the underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i8" class="method trait-impl"><a href="#method.write_i8" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> WriteI8<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a signed 8-bit integer to the underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u16" class="method trait-impl"><a href="#method.write_u16" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u16</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> WriteU16<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 16-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i16" class="method trait-impl"><a href="#method.write_i16" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i16</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> WriteI16<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a signed 16-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u32" class="method trait-impl"><a href="#method.write_u32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u32</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> WriteU32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 32-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i32" class="method trait-impl"><a href="#method.write_i32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i32</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> WriteI32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a signed 32-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u64" class="method trait-impl"><a href="#method.write_u64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u64</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> WriteU64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 64-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i64" class="method trait-impl"><a href="#method.write_i64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i64</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> WriteI64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an signed 64-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u128" class="method trait-impl"><a href="#method.write_u128" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u128</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> WriteU128<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 128-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i128" class="method trait-impl"><a href="#method.write_i128" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i128</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> WriteI128<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an signed 128-bit integer in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_f32" class="method trait-impl"><a href="#method.write_f32" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_f32</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> WriteF32<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an 32-bit floating point type in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_f64" class="method trait-impl"><a href="#method.write_f64" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_f64</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> WriteF64<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an 64-bit floating point type in big-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u16_le" class="method trait-impl"><a href="#method.write_u16_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> WriteU16Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 16-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i16_le" class="method trait-impl"><a href="#method.write_i16_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> WriteI16Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a signed 16-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u32_le" class="method trait-impl"><a href="#method.write_u32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> WriteU32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 32-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i32_le" class="method trait-impl"><a href="#method.write_i32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> WriteI32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes a signed 32-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u64_le" class="method trait-impl"><a href="#method.write_u64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> WriteU64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 64-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i64_le" class="method trait-impl"><a href="#method.write_i64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> WriteI64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an signed 64-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_u128_le" class="method trait-impl"><a href="#method.write_u128_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_u128_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> WriteU128Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an unsigned 128-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_i128_le" class="method trait-impl"><a href="#method.write_i128_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_i128_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> WriteI128Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an signed 128-bit integer in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_f32_le" class="method trait-impl"><a href="#method.write_f32_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_f32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> WriteF32Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an 32-bit floating point type in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_f64_le" class="method trait-impl"><a href="#method.write_f64_le" class="anchor">§</a><h4 class="code-header">fn <a class="fn">write_f64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> WriteF64Le<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut Self</a>><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Writes an 64-bit floating point type in little-endian order to the
|
|||
|
underlying writer. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.flush" class="method trait-impl"><a href="#method.flush" class="anchor">§</a><h4 class="code-header">fn <a class="fn">flush</a>(&mut self) -> Flush<'_, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Flushes this output stream, ensuring that all intermediately buffered
|
|||
|
contents reach their destination. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.shutdown" class="method trait-impl"><a href="#method.shutdown" class="anchor">§</a><h4 class="code-header">fn <a class="fn">shutdown</a>(&mut self) -> Shutdown<'_, Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class='docblock'>Shuts down the output stream, ensuring that the value can be dropped
|
|||
|
cleanly. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>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></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">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</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Instrument-for-T" class="impl"><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl<T> Instrument for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl"><a href="#method.instrument" class="anchor">§</a><h4 class="code-header">fn <a class="fn">instrument</a>(self, span: Span) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the provided [<code>Span</code>], returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl"><a href="#method.in_current_span" class="anchor">§</a><h4 class="code-header">fn <a class="fn">in_current_span</a>(self) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the <a href="super::Span::current()">current</a> <a href="crate::Span"><code>Span</code></a>, returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
|||
|
<p>That is, this conversion is whatever the implementation of
|
|||
|
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Same-for-T" class="impl"><a class="src rightside" href="https://docs.rs/typenum/1.17.0/src/typenum/type_operators.rs.html#34">source</a><a href="#impl-Same-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html" title="trait typenum::type_operators::Same">Same</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>Should always be <code>Self</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-2" class="associatedtype trait-impl"><a href="#associatedtype.Error-2" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">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="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">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<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">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="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">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="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-VZip%3CV%3E-for-T" class="impl"><a href="#impl-VZip%3CV%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<V, T> VZip<V> for T<div class="where">where
|
|||
|
V: MultiLane<T>,</div></h3></section></summary><div class="impl-items"><section id="method.vzip" class="method trait-impl"><a href="#method.vzip" class="anchor">§</a><h4 class="code-header">fn <a class="fn">vzip</a>(self) -> V</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-T" class="impl"><a href="#impl-WithSubscriber-for-T" class="anchor">§</a><h3 class="code-header">impl<T> WithSubscriber for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method trait-impl"><a href="#method.with_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_subscriber</a><S>(self, subscriber: S) -> WithDispatch<Self><div class="where">where
|
|||
|
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><Dispatch>,</div></h4></section></summary><div class='docblock'>Attaches the provided <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl"><a href="#method.with_current_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_current_subscriber</a>(self) -> WithDispatch<Self></h4></section></summary><div class='docblock'>Attaches the current <a href="crate::dispatcher#setting-the-default-subscriber">default</a> <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details></div></details></div></section></div></main></body></html>
|