1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 19:12:56 +01:00
actix-net/actix_rt/net/struct.UnixStream.html
2024-10-01 00:01:00 +00:00

575 lines
87 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A structure representing a connected Unix socket."><title>UnixStream in actix_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-b778ab399e080a4b.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_rt" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0-nightly (7608018cb 2024-09-29)" data-channel="nightly" data-search-js="search-e056c65ede92db13.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-54bc299d2a5e4e43.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-0111fcff984fae8f.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_rt/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_rt/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../actix_rt/index.html">actix_<wbr>rt</a><span class="version">2.10.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Unix<wbr>Stream</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.async_io" title="async_io">async_io</a></li><li><a href="#method.connect" title="connect">connect</a></li><li><a href="#method.from_std" title="from_std">from_std</a></li><li><a href="#method.into_split" title="into_split">into_split</a></li><li><a href="#method.into_std" title="into_std">into_std</a></li><li><a href="#method.local_addr" title="local_addr">local_addr</a></li><li><a href="#method.pair" title="pair">pair</a></li><li><a href="#method.peer_addr" title="peer_addr">peer_addr</a></li><li><a href="#method.peer_cred" title="peer_cred">peer_cred</a></li><li><a href="#method.poll_read_ready" title="poll_read_ready">poll_read_ready</a></li><li><a href="#method.poll_write_ready" title="poll_write_ready">poll_write_ready</a></li><li><a href="#method.readable" title="readable">readable</a></li><li><a href="#method.ready" title="ready">ready</a></li><li><a href="#method.split" title="split">split</a></li><li><a href="#method.take_error" title="take_error">take_error</a></li><li><a href="#method.try_io" title="try_io">try_io</a></li><li><a href="#method.try_read" title="try_read">try_read</a></li><li><a href="#method.try_read_vectored" title="try_read_vectored">try_read_vectored</a></li><li><a href="#method.try_write" title="try_write">try_write</a></li><li><a href="#method.try_write_vectored" title="try_write_vectored">try_write_vectored</a></li><li><a href="#method.writable" title="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-UnixStream" title="AsFd">AsFd</a></li><li><a href="#impl-AsRawFd-for-UnixStream" title="AsRawFd">AsRawFd</a></li><li><a href="#impl-AsyncRead-for-UnixStream" title="AsyncRead">AsyncRead</a></li><li><a href="#impl-AsyncWrite-for-UnixStream" title="AsyncWrite">AsyncWrite</a></li><li><a href="#impl-Debug-for-UnixStream" title="Debug">Debug</a></li><li><a href="#impl-TryFrom%3CUnixStream%3E-for-UnixStream" title="TryFrom&#60;UnixStream&#62;">TryFrom&#60;UnixStream&#62;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-UnixStream" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-UnixStream" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-UnixStream" title="Send">Send</a></li><li><a href="#impl-Sync-for-UnixStream" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-UnixStream" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-UnixStream" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In actix_<wbr>rt::<wbr>net</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">actix_rt</a>::<wbr><a href="index.html">net</a></span><h1>Struct <span class="struct">UnixStream</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub struct UnixStream { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A structure representing a connected Unix socket.</p>
<p>This socket can be connected directly with <a href="struct.UnixStream.html#method.connect" title="associated function actix_rt::net::UnixStream::connect"><code>UnixStream::connect</code></a> or accepted
from a listener with <a href="struct.UnixListener.html#method.accept" title="method actix_rt::net::UnixListener::accept"><code>UnixListener::accept</code></a>. Additionally, a pair of
anonymous Unix sockets can be created with <code>UnixStream::pair</code>.</p>
<p>To shut down the stream in the write direction, you can call the
<a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> method. This will cause the other peer to receive a read of
length 0, indicating that no more data will be sent. This only closes
the stream in one direction.</p>
</div></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-UnixStream" class="impl"><a href="#impl-UnixStream" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&lt;P&gt;(path: P) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&gt;<div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;,</div></h4></section></summary><div class="docblock"><p>Connects to the socket named by <code>path</code>.</p>
<p>This function will create a new Unix socket and connect to the path
specified, associating the returned stream with the default event loops
handle.</p>
</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>(&amp;self, interest: Interest) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Ready.html" title="struct actix_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>&gt;</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_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"><a class="doc-anchor" href="#examples">§</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::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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">&amp;mut </span>data) {
<span class="prelude-val">Ok</span>(n) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</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-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::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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">&amp;mut </span>msg) {
<span class="prelude-val">Ok</span>(n) =&gt; {
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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(&amp;self, cx: &amp;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>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</h4></section></summary><div class="docblock"><p>Polls for read readiness.</p>
<p>If the unix stream is not currently ready for reading, this method will
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the unix
stream becomes ready for reading, <code>Waker::wake</code> will be called on the
waker.</p>
<p>Note that on multiple calls to <code>poll_read_ready</code> or <code>poll_read</code>, only
the <code>Waker</code> from the <code>Context</code> passed to the most recent call is
scheduled to receive a wakeup. (However, <code>poll_write_ready</code> retains a
second, independent waker.)</p>
<p>This function is intended for cases where creating and pinning a future
via <a href="struct.UnixStream.html#method.readable" title="method actix_rt::net::UnixStream::readable"><code>readable</code></a> is not feasible. Where possible, using <a href="struct.UnixStream.html#method.readable" title="method actix_rt::net::UnixStream::readable"><code>readable</code></a> is
preferred, as this supports polling from multiple tasks at once.</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 the unix stream is not ready for reading.</li>
<li><code>Poll::Ready(Ok(()))</code> if the unix stream is ready for reading.</li>
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
</ul>
<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>
</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>(&amp;self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</h4></section></summary><div class="docblock"><p>Try to read data from the stream into the provided buffer, returning how
many bytes were read.</p>
<p>Receives any pending data from the socket but does not wait for new data
to arrive. On success, returns the number of bytes read. Because
<code>try_read()</code> is non-blocking, the buffer does not have to be stored by
the async task and can exist entirely on the stack.</p>
<p>Usually, <a href="struct.UnixStream.html#method.readable" title="method actix_rt::net::UnixStream::readable"><code>readable()</code></a> or <a href="struct.UnixStream.html#method.ready" title="method actix_rt::net::UnixStream::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 streams 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-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>tokio::net::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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">&amp;mut </span>buf) {
<span class="prelude-val">Ok</span>(<span class="number">0</span>) =&gt; <span class="kw">break</span>,
<span class="prelude-val">Ok</span>(n) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(
&amp;self,
bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</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.UnixStream.html#method.try_read" title="method actix_rt::net::UnixStream::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.UnixStream.html#method.readable" title="method actix_rt::net::UnixStream::readable"><code>readable()</code></a> or <a href="struct.UnixStream.html#method.ready" title="method actix_rt::net::UnixStream::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 streams 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-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>tokio::net::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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">&amp;mut </span>buf_a),
IoSliceMut::new(<span class="kw-2">&amp;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">&amp;mut </span>bufs) {
<span class="prelude-val">Ok</span>(<span class="number">0</span>) =&gt; <span class="kw">break</span>,
<span class="prelude-val">Ok</span>(n) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</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-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::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(&amp;self, cx: &amp;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>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</h4></section></summary><div class="docblock"><p>Polls for write readiness.</p>
<p>If the unix stream is not currently ready for writing, this method will
store a clone of the <code>Waker</code> from the provided <code>Context</code>. When the unix
stream becomes ready for writing, <code>Waker::wake</code> will be called on the
waker.</p>
<p>Note that on multiple calls to <code>poll_write_ready</code> or <code>poll_write</code>, only
the <code>Waker</code> from the <code>Context</code> passed to the most recent call is
scheduled to receive a wakeup. (However, <code>poll_read_ready</code> retains a
second, independent waker.)</p>
<p>This function is intended for cases where creating and pinning a future
via <a href="struct.UnixStream.html#method.writable" title="method actix_rt::net::UnixStream::writable"><code>writable</code></a> is not feasible. Where possible, using <a href="struct.UnixStream.html#method.writable" title="method actix_rt::net::UnixStream::writable"><code>writable</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 unix stream is not ready for writing.</li>
<li><code>Poll::Ready(Ok(()))</code> if the unix stream is ready for writing.</li>
<li><code>Poll::Ready(Err(e))</code> if an error is encountered.</li>
</ul>
<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_write" class="method"><h4 class="code-header">pub fn <a href="#method.try_write" class="fn">try_write</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</h4></section></summary><div class="docblock"><p>Tries 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-2"><a class="doc-anchor" href="#return-2">§</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-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::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>(&amp;self, buf: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</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.UnixStream.html#method.try_write" title="method actix_rt::net::UnixStream::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-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-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::net::UnixStream;
<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() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="comment">// Connect to a peer
</span><span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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">&amp;</span>bufs) {
<span class="prelude-val">Ok</span>(n) =&gt; {
<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 =&gt; {
<span class="kw">continue</span>;
}
<span class="prelude-val">Err</span>(e) =&gt; {
<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>&lt;R&gt;(
&amp;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>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;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>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;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>&gt;</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>UnixStream</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.UnixStream.html#method.readable" title="method actix_rt::net::UnixStream::readable"><code>readable()</code></a>, <a href="struct.UnixStream.html#method.writable" title="method actix_rt::net::UnixStream::writable"><code>writable()</code></a> or <a href="struct.UnixStream.html#method.ready" title="method actix_rt::net::UnixStream::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>&lt;R&gt;(
&amp;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>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;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>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;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>&gt;</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>UnixStream</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.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/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&gt;</h4></section></summary><div class="docblock"><p>Creates new <a href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream"><code>UnixStream</code></a> from a <a href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream"><code>std::os::unix::net::UnixStream</code></a>.</p>
<p>This function is intended to be used to wrap a <code>UnixStream</code> 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/os/unix/net/stream/struct.UnixStream.html#method.set_nonblocking" title="method std::os::unix::net::stream::UnixStream::set_nonblocking"><code>set_nonblocking</code></a>.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::net::UnixStream;
<span class="kw">use </span>std::os::unix::net::UnixStream <span class="kw">as </span>StdUnixStream;
<span class="kw">let </span>std_stream = StdUnixStream::connect(<span class="string">"/path/to/the/socket"</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 = UnixStream::from_std(std_stream)<span class="question-mark">?</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) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</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>&gt;</h4></section></summary><div class="docblock"><p>Turns a <a href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream"><code>tokio::net::UnixStream</code></a> into a <a href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream"><code>std::os::unix::net::UnixStream</code></a>.</p>
<p>The returned <a href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream"><code>std::os::unix::net::UnixStream</code></a> will have nonblocking
mode set as <code>true</code>. Use <a href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html#method.set_nonblocking" title="method std::os::unix::net::stream::UnixStream::set_nonblocking"><code>set_nonblocking</code></a> to change the blocking
mode if needed.</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>std::error::Error;
<span class="kw">use </span>std::io::Read;
<span class="kw">use </span>tokio::net::UnixListener;
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error&gt;&gt; {
<span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<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 = UnixListener::bind(<span class="kw-2">&amp;</span>bind_path)<span class="question-mark">?</span>;
<span class="kw">let </span>(tokio_unix_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_unix_stream = tokio_unix_stream.into_std()<span class="question-mark">?</span>;
std_unix_stream.set_nonblocking(<span class="bool-val">false</span>)<span class="question-mark">?</span>;
std_unix_stream.read_exact(<span class="kw-2">&amp;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.pair" class="method"><h4 class="code-header">pub fn <a href="#method.pair" class="fn">pair</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(<a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>, <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&gt;</h4></section></summary><div class="docblock"><p>Creates an unnamed pair of connected sockets.</p>
<p>This function will create a pair of interconnected Unix sockets for
communicating back and forth between one another. Each socket will
be associated with the default event loops handle.</p>
</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>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;SocketAddr, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the socket address of the local half of this connection.</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::UnixStream;
<span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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.peer_addr" class="method"><h4 class="code-header">pub fn <a href="#method.peer_addr" class="fn">peer_addr</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;SocketAddr, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the socket address of the remote half of this connection.</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::UnixStream;
<span class="kw">let </span>dir = tempfile::tempdir().unwrap();
<span class="kw">let </span>bind_path = dir.path().join(<span class="string">"bind_path"</span>);
<span class="kw">let </span>stream = UnixStream::connect(bind_path).<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.peer_cred" class="method"><h4 class="code-header">pub fn <a href="#method.peer_cred" class="fn">peer_cred</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;UCred, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Returns effective credentials of the process which called <code>connect</code> or <code>pair</code>.</p>
</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>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</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.split" class="method"><h4 class="code-header">pub fn <a href="#method.split" class="fn">split</a>&lt;'a&gt;(&amp;'a mut self) -&gt; (ReadHalf&lt;'a&gt;, WriteHalf&lt;'a&gt;)</h4></section></summary><div class="docblock"><p>Splits a <code>UnixStream</code> into a read half and a write half, which can be used
to read and write the stream concurrently.</p>
<p>This method is more efficient than <a href="struct.UnixStream.html#method.into_split" title="method actix_rt::net::UnixStream::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) -&gt; (OwnedReadHalf, OwnedWriteHalf)</h4></section></summary><div class="docblock"><p>Splits a <code>UnixStream</code> into a read half and a write half, which can be used
to read and write the stream concurrently.</p>
<p>Unlike <a href="struct.UnixStream.html#method.split" title="method actix_rt::net::UnixStream::split"><code>split</code></a>, the owned halves can be moved to separate tasks, however
this comes at the cost of a heap allocation.</p>
<p><strong>Note:</strong> Dropping the write half will shut down the write half of the
stream. This is equivalent to calling <a href="fn@crate::io::AsyncWriteExt::shutdown"><code>shutdown()</code></a> on the <code>UnixStream</code>.</p>
</div></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-UnixStream" class="impl"><a href="#impl-AsFd-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>(&amp;self) -&gt; <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>&lt;'_&gt;</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-UnixStream" class="impl"><a href="#impl-AsRawFd-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>(&amp;self) -&gt; <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-UnixStream" class="impl"><a href="#impl-AsyncRead-for-UnixStream" class="anchor">§</a><h3 class="code-header">impl AsyncRead for <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&lt;&amp;mut <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>&gt;,
cx: &amp;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>&lt;'_&gt;,
buf: &amp;mut ReadBuf&lt;'_&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</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-UnixStream" class="impl"><a href="#impl-AsyncWrite-for-UnixStream" class="anchor">§</a><h3 class="code-header">impl AsyncWrite for <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&lt;&amp;mut <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>&gt;,
cx: &amp;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>&lt;'_&gt;,
buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</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>&lt;&amp;mut <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>&gt;,
cx: &amp;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>&lt;'_&gt;,
bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</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>(&amp;self) -&gt; <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>&lt;&amp;mut <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>&gt;,
_: &amp;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>&lt;'_&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</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>&lt;&amp;mut <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a>&gt;,
_: &amp;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>&lt;'_&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;&gt;</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-UnixStream" class="impl"><a href="#impl-Debug-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<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>&gt;</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-TryFrom%3CUnixStream%3E-for-UnixStream" class="impl"><a href="#impl-TryFrom%3CUnixStream%3E-for-UnixStream" 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>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>&gt; for <a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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>&gt;</h4></section></summary><div class="docblock"><p>Consumes stream, returning the tokio I/O object.</p>
<p>This is equivalent to
<a href="struct.UnixStream.html#method.from_std" title="associated function actix_rt::net::UnixStream::from_std"><code>UnixStream::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-UnixStream" class="impl"><a href="#impl-Freeze-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a></h3></section><section id="impl-RefUnwindSafe-for-UnixStream" class="impl"><a href="#impl-RefUnwindSafe-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a></h3></section><section id="impl-Send-for-UnixStream" class="impl"><a href="#impl-Send-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a></h3></section><section id="impl-Sync-for-UnixStream" class="impl"><a href="#impl-Sync-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a></h3></section><section id="impl-Unpin-for-UnixStream" class="impl"><a href="#impl-Unpin-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</a></h3></section><section id="impl-UnwindSafe-for-UnixStream" class="impl"><a href="#impl-UnwindSafe-for-UnixStream" 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.UnixStream.html" title="struct actix_rt::net::UnixStream">UnixStream</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#138">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/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#139">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>(&amp;self) -&gt; <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-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#209">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/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#211">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>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/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#217">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/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#218">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>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/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&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/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) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/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&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/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) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/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&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-2" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#809">source</a><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) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/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&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#794">source</a><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> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/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) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>