mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-18 00:38:14 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
1
mio/all.html
Normal file
1
mio/all.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Interest.html">Interest</a></li><li><a href="struct.Poll.html">Poll</a></li><li><a href="struct.Registry.html">Registry</a></li><li><a href="struct.Token.html">Token</a></li><li><a href="struct.Waker.html">Waker</a></li><li><a href="event/struct.Event.html">event::Event</a></li><li><a href="event/struct.Events.html">event::Events</a></li><li><a href="event/struct.Iter.html">event::Iter</a></li><li><a href="net/struct.TcpListener.html">net::TcpListener</a></li><li><a href="net/struct.TcpStream.html">net::TcpStream</a></li><li><a href="net/struct.UdpSocket.html">net::UdpSocket</a></li><li><a href="net/struct.UnixDatagram.html">net::UnixDatagram</a></li><li><a href="net/struct.UnixListener.html">net::UnixListener</a></li><li><a href="net/struct.UnixStream.html">net::UnixStream</a></li><li><a href="unix/struct.SourceFd.html">unix::SourceFd</a></li><li><a href="unix/pipe/struct.Receiver.html">unix::pipe::Receiver</a></li><li><a href="unix/pipe/struct.Sender.html">unix::pipe::Sender</a></li></ul><h3 id="traits">Traits</h3><ul class="all-items"><li><a href="event/trait.Source.html">event::Source</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="unix/pipe/fn.new.html">unix::pipe::new</a></li></ul></section></div></main></body></html>
|
||||
11
mio/event/event/struct.Event.html
Normal file
11
mio/event/event/struct.Event.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../mio/event/struct.Event.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../mio/event/struct.Event.html">../../../mio/event/struct.Event.html</a>...</p>
|
||||
<script>location.replace("../../../mio/event/struct.Event.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/event/events/struct.Events.html
Normal file
11
mio/event/events/struct.Events.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../mio/event/struct.Events.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../mio/event/struct.Events.html">../../../mio/event/struct.Events.html</a>...</p>
|
||||
<script>location.replace("../../../mio/event/struct.Events.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/event/events/struct.Iter.html
Normal file
11
mio/event/events/struct.Iter.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../mio/event/struct.Iter.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../mio/event/struct.Iter.html">../../../mio/event/struct.Iter.html</a>...</p>
|
||||
<script>location.replace("../../../mio/event/struct.Iter.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
2
mio/event/index.html
Normal file
2
mio/event/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Readiness event types and utilities."><title>mio::event - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module event</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate mio</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">mio</a></span><h1>Module <span>event</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/mio/event/mod.rs.html#1-10">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Readiness event types and utilities.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Event.html" title="struct mio::event::Event">Event</a></div><div class="desc docblock-short">A readiness event.</div></li><li><div class="item-name"><a class="struct" href="struct.Events.html" title="struct mio::event::Events">Events</a></div><div class="desc docblock-short">A collection of readiness events.</div></li><li><div class="item-name"><a class="struct" href="struct.Iter.html" title="struct mio::event::Iter">Iter</a></div><div class="desc docblock-short"><a href="struct.Events.html"><code>Events</code></a> iterator.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Source.html" title="trait mio::event::Source">Source</a></div><div class="desc docblock-short">An event source that may be registered with <a href="../struct.Registry.html"><code>Registry</code></a>.</div></li></ul></section></div></main></body></html>
|
||||
1
mio/event/sidebar-items.js
Normal file
1
mio/event/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["Event","Events","Iter"],"trait":["Source"]};
|
||||
11
mio/event/source/trait.Source.html
Normal file
11
mio/event/source/trait.Source.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../mio/event/trait.Source.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../mio/event/trait.Source.html">../../../mio/event/trait.Source.html</a>...</p>
|
||||
<script>location.replace("../../../mio/event/trait.Source.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
102
mio/event/struct.Event.html
Normal file
102
mio/event/struct.Event.html
Normal file
File diff suppressed because one or more lines are too long
82
mio/event/struct.Events.html
Normal file
82
mio/event/struct.Events.html
Normal file
File diff suppressed because one or more lines are too long
208
mio/event/struct.Iter.html
Normal file
208
mio/event/struct.Iter.html
Normal file
File diff suppressed because one or more lines are too long
100
mio/event/trait.Source.html
Normal file
100
mio/event/trait.Source.html
Normal file
File diff suppressed because one or more lines are too long
13
mio/features/index.html
Normal file
13
mio/features/index.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!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="Mio’s optional features."><title>mio::features - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module features</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#mios-optional-features" title="Mio’s optional features.">Mio’s optional features.</a><ul><li><a href="#os-poll-enabled" title="`os-poll` (enabled)"><code>os-poll</code> (enabled)</a></li><li><a href="#os-ext-enabled" title="`os-ext` (enabled)"><code>os-ext</code> (enabled)</a></li><li><a href="#network-types-enabled" title="Network types (enabled)">Network types (enabled)</a></li></ul></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate mio</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">mio</a></span><h1>Module <span>features</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/mio/lib.rs.html#104">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="mios-optional-features"><a class="doc-anchor" href="#mios-optional-features">§</a>Mio’s optional features.</h2>
|
||||
<p>This document describes the available features in Mio.</p>
|
||||
<h3 id="os-poll-enabled"><a class="doc-anchor" href="#os-poll-enabled">§</a><code>os-poll</code> (enabled)</h3>
|
||||
<p>Mio by default provides only a shell implementation that <code>panic!</code>s the
|
||||
moment it is actually run. To run it requires OS support, this is
|
||||
enabled by activating the <code>os-poll</code> feature.</p>
|
||||
<p>This makes <code>Poll</code>, <code>Registry</code> and <code>Waker</code> functional.</p>
|
||||
<h3 id="os-ext-enabled"><a class="doc-anchor" href="#os-ext-enabled">§</a><code>os-ext</code> (enabled)</h3>
|
||||
<p><code>os-ext</code> enables additional OS specific facilities. These facilities can
|
||||
be found in the <code>unix</code> and <code>windows</code> module.</p>
|
||||
<h3 id="network-types-enabled"><a class="doc-anchor" href="#network-types-enabled">§</a>Network types (enabled)</h3>
|
||||
<p>The <code>net</code> feature enables networking primitives in the <code>net</code> module.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
1
mio/features/sidebar-items.js
Normal file
1
mio/features/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {};
|
||||
85
mio/guide/index.html
Normal file
85
mio/guide/index.html
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<!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="Getting started guide."><title>mio::guide - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module guide</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#getting-started-guide" title="Getting started guide.">Getting started guide.</a><ul><li><a href="#1-creating-a-poll-instance" title="1. Creating a `Poll` instance">1. Creating a <code>Poll</code> instance</a></li><li><a href="#2-registering-event-source" title="2. Registering event source">2. Registering event source</a></li><li><a href="#3-creating-the-event-loop" title="3. Creating the event loop">3. Creating the event loop</a></li></ul></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate mio</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">mio</a></span><h1>Module <span>guide</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/mio/lib.rs.html#130">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="getting-started-guide"><a class="doc-anchor" href="#getting-started-guide">§</a>Getting started guide.</h2>
|
||||
<p>In this guide we’ll do the following:</p>
|
||||
<ol>
|
||||
<li>Create a <a href="../struct.Poll.html"><code>Poll</code></a> instance (and learn what it is).</li>
|
||||
<li>Register an <a href="../event/trait.Source.html">event source</a>.</li>
|
||||
<li>Create an event loop.</li>
|
||||
</ol>
|
||||
<p>At the end you’ll have a very small (but quick) TCP server that accepts
|
||||
connections and then drops (disconnects) them.</p>
|
||||
<h3 id="1-creating-a-poll-instance"><a class="doc-anchor" href="#1-creating-a-poll-instance">§</a>1. Creating a <code>Poll</code> instance</h3>
|
||||
<p>Using Mio starts by creating a <a href="../struct.Poll.html"><code>Poll</code></a> instance, which monitors events
|
||||
from the OS and puts them into <a href="../event/struct.Events.html"><code>Events</code></a>. This allows us to execute I/O
|
||||
operations based on what operations are ready.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// `Poll` allows for polling of readiness events.
|
||||
</span><span class="kw">let </span>poll = Poll::new()<span class="question-mark">?</span>;
|
||||
<span class="comment">// `Events` is collection of readiness `Event`s and can be filled by
|
||||
// calling `Poll::poll`.
|
||||
</span><span class="kw">let </span>events = Events::with_capacity(<span class="number">128</span>);</code></pre></div>
|
||||
<p>For example if we’re using a <a href="../net/struct.TcpListener.html"><code>TcpListener</code></a>, we’ll only want to
|
||||
attempt to accept an incoming connection <em>iff</em> any connections are
|
||||
queued and ready to be accepted. We don’t want to waste our time if no
|
||||
connections are ready.</p>
|
||||
<h3 id="2-registering-event-source"><a class="doc-anchor" href="#2-registering-event-source">§</a>2. Registering event source</h3>
|
||||
<p>After we’ve created a <a href="../struct.Poll.html"><code>Poll</code></a> instance that monitors events from the OS
|
||||
for us, we need to provide it with a source of events. This is done by
|
||||
registering an <a href="../event/trait.Source.html">event source</a>. As the name “event source” suggests it is
|
||||
a source of events which can be polled using a <code>Poll</code> instance. On Unix
|
||||
systems this is usually a file descriptor, or a socket/handle on
|
||||
Windows.</p>
|
||||
<p>In the example below we’ll use a <a href="../net/struct.TcpListener.html"><code>TcpListener</code></a> for which we’ll receive
|
||||
an event (from <a href="../struct.Poll.html"><code>Poll</code></a>) once a connection is ready to be accepted.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Create a `TcpListener`, binding it to `address`.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>listener = TcpListener::bind(address)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Next we register it with `Poll` to receive events for it. The `SERVER`
|
||||
// `Token` is used to determine that we received an event for the listener
|
||||
// later on.
|
||||
</span><span class="kw">const </span>SERVER: Token = Token(<span class="number">0</span>);
|
||||
poll.registry().register(<span class="kw-2">&mut </span>listener, SERVER, Interest::READABLE)<span class="question-mark">?</span>;</code></pre></div>
|
||||
<p>Multiple event sources can be <a href="../struct.Registry.html#method.register">registered</a> (concurrently), so we can
|
||||
monitor multiple sources at a time.</p>
|
||||
<h3 id="3-creating-the-event-loop"><a class="doc-anchor" href="#3-creating-the-event-loop">§</a>3. Creating the event loop</h3>
|
||||
<p>After we’ve created a <a href="../struct.Poll.html"><code>Poll</code></a> instance and registered one or more
|
||||
<a href="../event/trait.Source.html">event sources</a> with it, we can <a href="../struct.Poll.html#method.poll">poll</a> it for events. Polling for events
|
||||
is simple, we need a container to store the events: <a href="../event/struct.Events.html"><code>Events</code></a> and need
|
||||
to do something based on the polled events (this part is up to you, we
|
||||
can’t do it all!). If we do this in a loop we’ve got ourselves an event
|
||||
loop.</p>
|
||||
<p>The example below shows the event loop in action, completing our small
|
||||
TCP server.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Start our event loop.
|
||||
</span><span class="kw">loop </span>{
|
||||
<span class="comment">// Poll the OS for events, waiting at most 100 milliseconds.
|
||||
</span>poll.poll(<span class="kw-2">&mut </span>events, <span class="prelude-val">Some</span>(Duration::from_millis(<span class="number">100</span>)))<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Process each event.
|
||||
</span><span class="kw">for </span>event <span class="kw">in </span>events.iter() {
|
||||
<span class="comment">// We can use the token we previously provided to `register` to
|
||||
// determine for which type the event is.
|
||||
</span><span class="kw">match </span>event.token() {
|
||||
SERVER => <span class="kw">loop </span>{
|
||||
<span class="comment">// One or more connections are ready, so we'll attempt to
|
||||
// accept them (in a loop).
|
||||
</span><span class="kw">match </span>listener.accept() {
|
||||
<span class="prelude-val">Ok</span>((connection, address)) => {
|
||||
<span class="macro">println!</span>(<span class="string">"Got a connection from: {}"</span>, address);
|
||||
},
|
||||
<span class="comment">// A "would block error" is returned if the operation
|
||||
// is not ready, so we'll stop trying to accept
|
||||
// connections.
|
||||
</span><span class="prelude-val">Err</span>(<span class="kw-2">ref </span>err) <span class="kw">if </span>would_block(err) => <span class="kw">break</span>,
|
||||
<span class="prelude-val">Err</span>(err) => <span class="kw">return </span><span class="prelude-val">Err</span>(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>would_block(err: <span class="kw-2">&</span>io::Error) -> bool {
|
||||
err.kind() == io::ErrorKind::WouldBlock
|
||||
}</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
1
mio/guide/sidebar-items.js
Normal file
1
mio/guide/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {};
|
||||
15
mio/index.html
Normal file
15
mio/index.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!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="Mio is a fast, low-level I/O library for Rust focusing on non-blocking APIs and event notification for building high performance I/O apps with as little overhead as possible over the OS abstractions."><title>mio - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#usage" title="Usage">Usage</a><ul><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#guide" title="Guide">Guide</a></li><li><a href="#available-features" title="Available features">Available features</a></li></ul></li></ul><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>mio</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/mio/lib.rs.html#1-274">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Mio is a fast, low-level I/O library for Rust focusing on non-blocking APIs
|
||||
and event notification for building high performance I/O apps with as little
|
||||
overhead as possible over the OS abstractions.</p>
|
||||
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
|
||||
<p>Using Mio starts by creating a <a href="../mio/struct.Poll.html"><code>Poll</code></a>, which reads events from the OS and
|
||||
puts them into <a href="../mio/event/struct.Events.html"><code>Events</code></a>. You can handle I/O events from the OS with it.</p>
|
||||
<p>For more detail, see <a href="../mio/struct.Poll.html"><code>Poll</code></a>.</p>
|
||||
<h3 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h3>
|
||||
<p>Examples can found in the <code>examples</code> directory of the source code, or <a href="https://github.com/tokio-rs/mio/tree/master/examples">on
|
||||
GitHub</a>.</p>
|
||||
<h3 id="guide"><a class="doc-anchor" href="#guide">§</a>Guide</h3>
|
||||
<p>A getting started guide is available in the <a href="guide/index.html" title="mod mio::guide"><code>guide</code></a> module.</p>
|
||||
<h3 id="available-features"><a class="doc-anchor" href="#available-features">§</a>Available features</h3>
|
||||
<p>The available features are described in the <a href="features/index.html" title="mod mio::features"><code>features</code></a> module.</p>
|
||||
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Events"><code>pub use event::<a class="struct" href="event/struct.Events.html" title="struct mio::event::Events">Events</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="event/index.html" title="mod mio::event">event</a></div><div class="desc docblock-short">Readiness event types and utilities.</div></li><li><div class="item-name"><a class="mod" href="features/index.html" title="mod mio::features">features</a></div><div class="desc docblock-short">Mio’s optional features.</div></li><li><div class="item-name"><a class="mod" href="guide/index.html" title="mod mio::guide">guide</a></div><div class="desc docblock-short">Getting started guide.</div></li><li><div class="item-name"><a class="mod" href="net/index.html" title="mod mio::net">net</a></div><div class="desc docblock-short">Networking primitives.</div></li><li><div class="item-name"><a class="mod" href="unix/index.html" title="mod mio::unix">unix</a></div><div class="desc docblock-short">Unix only extensions.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Interest.html" title="struct mio::Interest">Interest</a></div><div class="desc docblock-short">Interest used in registering.</div></li><li><div class="item-name"><a class="struct" href="struct.Poll.html" title="struct mio::Poll">Poll</a></div><div class="desc docblock-short">Polls for readiness events on all registered values.</div></li><li><div class="item-name"><a class="struct" href="struct.Registry.html" title="struct mio::Registry">Registry</a></div><div class="desc docblock-short">Registers I/O resources.</div></li><li><div class="item-name"><a class="struct" href="struct.Token.html" title="struct mio::Token">Token</a></div><div class="desc docblock-short">Associates readiness events with <a href="./event/trait.Source.html"><code>event::Source</code></a>s.</div></li><li><div class="item-name"><a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></div><div class="desc docblock-short">Waker allows cross-thread waking of <a href="struct.Poll.html"><code>Poll</code></a>.</div></li></ul></section></div></main></body></html>
|
||||
11
mio/interest/struct.Interest.html
Normal file
11
mio/interest/struct.Interest.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../mio/struct.Interest.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../mio/struct.Interest.html">../../mio/struct.Interest.html</a>...</p>
|
||||
<script>location.replace("../../mio/struct.Interest.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
23
mio/net/index.html
Normal file
23
mio/net/index.html
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<!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="Networking primitives."><title>mio::net - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module net</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#notes" title="Notes">Notes</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate mio</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">mio</a></span><h1>Module <span>net</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/mio/net/mod.rs.html#1-39">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Networking primitives.</p>
|
||||
<p>The types provided in this module are non-blocking by default and are
|
||||
designed to be portable across all supported Mio platforms. As long as the
|
||||
<a href="../struct.Poll.html#portability">portability guidelines</a> are followed, the behavior should be identical no
|
||||
matter the target platform.</p>
|
||||
<h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2>
|
||||
<p>When using a datagram based socket, i.e. <a href="struct.UdpSocket.html" title="struct mio::net::UdpSocket"><code>UdpSocket</code></a> or <a href="struct.UnixDatagram.html" title="struct mio::net::UnixDatagram"><code>UnixDatagram</code></a>,
|
||||
its only possible to receive a packet once. This means that if you provide a
|
||||
buffer that is too small you won’t be able to receive the data anymore. How
|
||||
OSs deal with this situation is different for each OS:</p>
|
||||
<ul>
|
||||
<li>Unixes, such as Linux, FreeBSD and macOS, will simply fill the buffer and
|
||||
return the amount of bytes written. This means that if the returned value
|
||||
is equal to the size of the buffer it may have only written a part of the
|
||||
packet (or the packet has the same size as the buffer).</li>
|
||||
<li>Windows returns an <code>WSAEMSGSIZE</code> error.</li>
|
||||
</ul>
|
||||
<p>Mio does not change the value (either ok or error) returned by the OS, it’s
|
||||
up to the user handle this. How to deal with these difference is still up
|
||||
for debate, specifically in
|
||||
<a href="https://github.com/rust-lang/rust/issues/55794">https://github.com/rust-lang/rust/issues/55794</a>. The best advice we can
|
||||
give is to always call receive with a large enough buffer.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.TcpListener.html" title="struct mio::net::TcpListener">TcpListener</a></div><div class="desc docblock-short">A structure representing a socket server</div></li><li><div class="item-name"><a class="struct" href="struct.TcpStream.html" title="struct mio::net::TcpStream">TcpStream</a></div><div class="desc docblock-short">A non-blocking TCP stream between a local socket and a remote socket.</div></li><li><div class="item-name"><a class="struct" href="struct.UdpSocket.html" title="struct mio::net::UdpSocket">UdpSocket</a></div><div class="desc docblock-short">A User Datagram Protocol socket.</div></li><li><div class="item-name"><a class="struct" href="struct.UnixDatagram.html" title="struct mio::net::UnixDatagram">Unix<wbr>Datagram</a></div><div class="desc docblock-short">A Unix datagram socket.</div></li><li><div class="item-name"><a class="struct" href="struct.UnixListener.html" title="struct mio::net::UnixListener">Unix<wbr>Listener</a></div><div class="desc docblock-short">A non-blocking Unix domain socket server.</div></li><li><div class="item-name"><a class="struct" href="struct.UnixStream.html" title="struct mio::net::UnixStream">Unix<wbr>Stream</a></div><div class="desc docblock-short">A non-blocking Unix stream socket.</div></li></ul></section></div></main></body></html>
|
||||
1
mio/net/sidebar-items.js
Normal file
1
mio/net/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["TcpListener","TcpStream","UdpSocket","UnixDatagram","UnixListener","UnixStream"]};
|
||||
76
mio/net/struct.TcpListener.html
Normal file
76
mio/net/struct.TcpListener.html
Normal file
File diff suppressed because one or more lines are too long
190
mio/net/struct.TcpStream.html
Normal file
190
mio/net/struct.TcpStream.html
Normal file
File diff suppressed because one or more lines are too long
334
mio/net/struct.UdpSocket.html
Normal file
334
mio/net/struct.UdpSocket.html
Normal file
File diff suppressed because one or more lines are too long
106
mio/net/struct.UnixDatagram.html
Normal file
106
mio/net/struct.UnixDatagram.html
Normal file
File diff suppressed because one or more lines are too long
38
mio/net/struct.UnixListener.html
Normal file
38
mio/net/struct.UnixListener.html
Normal file
File diff suppressed because one or more lines are too long
121
mio/net/struct.UnixStream.html
Normal file
121
mio/net/struct.UnixStream.html
Normal file
File diff suppressed because one or more lines are too long
11
mio/net/tcp/listener/struct.TcpListener.html
Normal file
11
mio/net/tcp/listener/struct.TcpListener.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/net/struct.TcpListener.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/net/struct.TcpListener.html">../../../../mio/net/struct.TcpListener.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/net/struct.TcpListener.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/net/tcp/stream/struct.TcpStream.html
Normal file
11
mio/net/tcp/stream/struct.TcpStream.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/net/struct.TcpStream.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/net/struct.TcpStream.html">../../../../mio/net/struct.TcpStream.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/net/struct.TcpStream.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/net/udp/struct.UdpSocket.html
Normal file
11
mio/net/udp/struct.UdpSocket.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../mio/net/struct.UdpSocket.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../mio/net/struct.UdpSocket.html">../../../mio/net/struct.UdpSocket.html</a>...</p>
|
||||
<script>location.replace("../../../mio/net/struct.UdpSocket.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/net/uds/datagram/struct.UnixDatagram.html
Normal file
11
mio/net/uds/datagram/struct.UnixDatagram.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/net/struct.UnixDatagram.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/net/struct.UnixDatagram.html">../../../../mio/net/struct.UnixDatagram.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/net/struct.UnixDatagram.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/net/uds/listener/struct.UnixListener.html
Normal file
11
mio/net/uds/listener/struct.UnixListener.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/net/struct.UnixListener.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/net/struct.UnixListener.html">../../../../mio/net/struct.UnixListener.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/net/struct.UnixListener.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/net/uds/stream/struct.UnixStream.html
Normal file
11
mio/net/uds/stream/struct.UnixStream.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/net/struct.UnixStream.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/net/struct.UnixStream.html">../../../../mio/net/struct.UnixStream.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/net/struct.UnixStream.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/poll/struct.Poll.html
Normal file
11
mio/poll/struct.Poll.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../mio/struct.Poll.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../mio/struct.Poll.html">../../mio/struct.Poll.html</a>...</p>
|
||||
<script>location.replace("../../mio/struct.Poll.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/poll/struct.Registry.html
Normal file
11
mio/poll/struct.Registry.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../mio/struct.Registry.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../mio/struct.Registry.html">../../mio/struct.Registry.html</a>...</p>
|
||||
<script>location.replace("../../mio/struct.Registry.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
mio/sidebar-items.js
Normal file
1
mio/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"mod":["event","features","guide","net","unix"],"struct":["Interest","Poll","Registry","Token","Waker"]};
|
||||
57
mio/struct.Interest.html
Normal file
57
mio/struct.Interest.html
Normal file
File diff suppressed because one or more lines are too long
286
mio/struct.Poll.html
Normal file
286
mio/struct.Poll.html
Normal file
File diff suppressed because one or more lines are too long
174
mio/struct.Registry.html
Normal file
174
mio/struct.Registry.html
Normal file
File diff suppressed because one or more lines are too long
135
mio/struct.Token.html
Normal file
135
mio/struct.Token.html
Normal file
File diff suppressed because one or more lines are too long
63
mio/struct.Waker.html
Normal file
63
mio/struct.Waker.html
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Waker allows cross-thread waking of `Poll`."><title>Waker in mio - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Waker</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#notes" title="Notes">Notes</a></li><li><a href="#implementation-notes" title="Implementation notes">Implementation notes</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li><li><a href="#method.wake" title="wake">wake</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Waker" title="Debug">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Waker" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Waker" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Waker" title="Send">Send</a></li><li><a href="#impl-Sync-for-Waker" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Waker" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Waker" 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<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate mio</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">mio</a></span><h1>Struct <span class="struct">Waker</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/mio/waker.rs.html#78-80">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Waker { <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>Waker allows cross-thread waking of <a href="struct.Poll.html"><code>Poll</code></a>.</p>
|
||||
<p>When created it will cause events with <a href="./event/struct.Event.html#method.is_readable"><code>readable</code></a> readiness and the
|
||||
provided <code>token</code> if <a href="struct.Waker.html#method.wake"><code>wake</code></a> is called, possibly from another thread.</p>
|
||||
<h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2>
|
||||
<p><code>Waker</code> events are only guaranteed to be delivered while the <code>Waker</code> value
|
||||
is alive.</p>
|
||||
<p>Only a single <code>Waker</code> can be active per <a href="struct.Poll.html"><code>Poll</code></a>, if multiple threads need
|
||||
access to the <code>Waker</code> it can be shared via for example an <code>Arc</code>. What
|
||||
happens if multiple <code>Waker</code>s are registered with the same <code>Poll</code> is
|
||||
unspecified.</p>
|
||||
<h2 id="implementation-notes"><a class="doc-anchor" href="#implementation-notes">§</a>Implementation notes</h2>
|
||||
<p>On platforms that support kqueue this will use the <code>EVFILT_USER</code> event
|
||||
filter, see <a href="struct.Poll.html#implementation-notes">implementation notes of <code>Poll</code></a> to see what platforms support
|
||||
kqueue. On Linux it uses <a href="https://man7.org/linux/man-pages/man2/eventfd.2.html">eventfd</a>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Wake a <a href="struct.Poll.html"><code>Poll</code></a> instance from another thread.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::thread;
|
||||
<span class="kw">use </span>std::time::Duration;
|
||||
<span class="kw">use </span>std::sync::Arc;
|
||||
|
||||
<span class="kw">use </span>mio::{Events, Token, Poll, Waker};
|
||||
|
||||
<span class="kw">const </span>WAKE_TOKEN: Token = Token(<span class="number">10</span>);
|
||||
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>poll = Poll::new()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>events = Events::with_capacity(<span class="number">2</span>);
|
||||
|
||||
<span class="kw">let </span>waker = Arc::new(Waker::new(poll.registry(), WAKE_TOKEN)<span class="question-mark">?</span>);
|
||||
|
||||
<span class="comment">// We need to keep the Waker alive, so we'll create a clone for the
|
||||
// thread we create below.
|
||||
</span><span class="kw">let </span>waker1 = waker.clone();
|
||||
<span class="kw">let </span>handle = thread::spawn(<span class="kw">move </span>|| {
|
||||
<span class="comment">// Working hard, or hardly working?
|
||||
</span>thread::sleep(Duration::from_millis(<span class="number">500</span>));
|
||||
|
||||
<span class="comment">// Now we'll wake the queue on the other thread.
|
||||
</span>waker1.wake().expect(<span class="string">"unable to wake"</span>);
|
||||
});
|
||||
|
||||
<span class="comment">// On our current thread we'll poll for events, without a timeout.
|
||||
</span>poll.poll(<span class="kw-2">&mut </span>events, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// After about 500 milliseconds we should be awoken by the other thread and
|
||||
// get a single event.
|
||||
</span><span class="macro">assert!</span>(!events.is_empty());
|
||||
<span class="kw">let </span>waker_event = events.iter().next().unwrap();
|
||||
<span class="macro">assert!</span>(waker_event.is_readable());
|
||||
<span class="macro">assert_eq!</span>(waker_event.token(), WAKE_TOKEN);</code></pre></div>
|
||||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Waker" class="impl"><a class="src rightside" href="../src/mio/waker.rs.html#82-96">Source</a><a href="#impl-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/mio/waker.rs.html#84-88">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(registry: &<a class="struct" href="struct.Registry.html" title="struct mio::Registry">Registry</a>, token: <a class="struct" href="struct.Token.html" title="struct mio::Token">Token</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a>></h4></section></summary><div class="docblock"><p>Create a new <code>Waker</code>.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.wake" class="method"><a class="src rightside" href="../src/mio/waker.rs.html#93-95">Source</a><h4 class="code-header">pub fn <a href="#method.wake" class="fn">wake</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Wake up the <a href="struct.Poll.html"><code>Poll</code></a> associated with this <code>Waker</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-Debug-for-Waker" class="impl"><a class="src rightside" href="../src/mio/waker.rs.html#77">Source</a><a href="#impl-Debug-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/mio/waker.rs.html#77">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Waker" class="impl"><a href="#impl-Freeze-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section><section id="impl-RefUnwindSafe-for-Waker" class="impl"><a href="#impl-RefUnwindSafe-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section><section id="impl-Send-for-Waker" class="impl"><a href="#impl-Send-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section><section id="impl-Sync-for-Waker" class="impl"><a href="#impl-Sync-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section><section id="impl-Unpin-for-Waker" class="impl"><a href="#impl-Unpin-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section><section id="impl-UnwindSafe-for-Waker" class="impl"><a href="#impl-UnwindSafe-for-Waker" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Waker.html" title="struct mio::Waker">Waker</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">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/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">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/1.84.1/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/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">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/1.84.1/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/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/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></div></section></div></main></body></html>
|
||||
11
mio/sys/unix/pipe/fn.new.html
Normal file
11
mio/sys/unix/pipe/fn.new.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/unix/pipe/fn.new.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/unix/pipe/fn.new.html">../../../../mio/unix/pipe/fn.new.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/unix/pipe/fn.new.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/sys/unix/pipe/struct.Receiver.html
Normal file
11
mio/sys/unix/pipe/struct.Receiver.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/unix/pipe/struct.Receiver.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/unix/pipe/struct.Receiver.html">../../../../mio/unix/pipe/struct.Receiver.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/unix/pipe/struct.Receiver.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/sys/unix/pipe/struct.Sender.html
Normal file
11
mio/sys/unix/pipe/struct.Sender.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/unix/pipe/struct.Sender.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/unix/pipe/struct.Sender.html">../../../../mio/unix/pipe/struct.Sender.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/unix/pipe/struct.Sender.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/sys/unix/sourcefd/struct.SourceFd.html
Normal file
11
mio/sys/unix/sourcefd/struct.SourceFd.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../mio/unix/struct.SourceFd.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../mio/unix/struct.SourceFd.html">../../../../mio/unix/struct.SourceFd.html</a>...</p>
|
||||
<script>location.replace("../../../../mio/unix/struct.SourceFd.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
mio/token/struct.Token.html
Normal file
11
mio/token/struct.Token.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../mio/struct.Token.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../mio/struct.Token.html">../../mio/struct.Token.html</a>...</p>
|
||||
<script>location.replace("../../mio/struct.Token.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
2
mio/unix/index.html
Normal file
2
mio/unix/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Unix only extensions."><title>mio::unix - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module unix</a></h2><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate mio</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">mio</a></span><h1>Module <span>unix</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/mio/lib.rs.html#74">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Unix only extensions.</p>
|
||||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="pipe/index.html" title="mod mio::unix::pipe">pipe</a></div><div class="desc docblock-short">Unix pipe.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.SourceFd.html" title="struct mio::unix::SourceFd">Source<wbr>Fd</a></div><div class="desc docblock-short">Adapter for <a href="https://doc.rust-lang.org/1.84.1/std/os/fd/raw/type.RawFd.html" title="type std::os::fd::raw::RawFd"><code>RawFd</code></a> providing an <a href="../event/trait.Source.html"><code>event::Source</code></a> implementation.</div></li></ul></section></div></main></body></html>
|
||||
97
mio/unix/pipe/fn.new.html
Normal file
97
mio/unix/pipe/fn.new.html
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Create a new non-blocking Unix pipe."><title>new in mio::unix::pipe - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">new</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#events" title="Events">Events</a></li><li><a href="#deregistering" title="Deregistering">Deregistering</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In mio::<wbr>unix::<wbr>pipe</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">mio</a>::<wbr><a href="../index.html">unix</a>::<wbr><a href="index.html">pipe</a></span><h1>Function <span class="fn">new</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/mio/sys/unix/pipe.rs.html#208-214">Source</a> </span></div><pre class="rust item-decl"><code>pub fn new() -> <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Sender.html" title="struct mio::unix::pipe::Sender">Sender</a>, <a class="struct" href="struct.Receiver.html" title="struct mio::unix::pipe::Receiver">Receiver</a>)></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a new non-blocking Unix pipe.</p>
|
||||
<p>This is a wrapper around Unix’s <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/pipe.html"><code>pipe(2)</code></a> system call and can be used as
|
||||
inter-process or thread communication channel.</p>
|
||||
<p>This channel may be created before forking the process and then one end used
|
||||
in each process, e.g. the parent process has the sending end to send command
|
||||
to the child process.</p>
|
||||
<h2 id="events"><a class="doc-anchor" href="#events">§</a>Events</h2>
|
||||
<p>The <a href="struct.Sender.html" title="struct mio::unix::pipe::Sender"><code>Sender</code></a> can be registered with <a href="../../struct.Interest.html#associatedconstant.WRITABLE" title="associated constant mio::Interest::WRITABLE"><code>WRITABLE</code></a> interest to receive
|
||||
<a href="../../event/struct.Event.html#method.is_writable" title="method mio::event::Event::is_writable">writable events</a>, the <a href="struct.Receiver.html" title="struct mio::unix::pipe::Receiver"><code>Receiver</code></a> with <a href="../../struct.Interest.html#associatedconstant.READABLE" title="associated constant mio::Interest::READABLE"><code>READABLE</code></a> interest. Once data is
|
||||
written to the <code>Sender</code> the <code>Receiver</code> will receive an <a href="../../event/struct.Event.html#method.is_readable" title="method mio::event::Event::is_readable">readable event</a>.</p>
|
||||
<p>In addition to those events, events will also be generated if the other side
|
||||
is dropped. To check if the <code>Sender</code> is dropped you’ll need to check
|
||||
<a href="../../event/struct.Event.html#method.is_read_closed" title="method mio::event::Event::is_read_closed"><code>is_read_closed</code></a> on events for the <code>Receiver</code>, if it returns true the
|
||||
<code>Sender</code> is dropped. On the <code>Sender</code> end check <a href="../../event/struct.Event.html#method.is_write_closed" title="method mio::event::Event::is_write_closed"><code>is_write_closed</code></a>, if it
|
||||
returns true the <code>Receiver</code> was dropped. Also see the second example below.</p>
|
||||
<h2 id="deregistering"><a class="doc-anchor" href="#deregistering">§</a>Deregistering</h2>
|
||||
<p>Both <code>Sender</code> and <code>Receiver</code> will deregister themselves when dropped,
|
||||
<strong>iff</strong> the file descriptors are not duplicated (via <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html"><code>dup(2)</code></a>).</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Simple example that writes data into the sending end and read it from the
|
||||
receiving end.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io::{<span class="self">self</span>, Read, Write};
|
||||
|
||||
<span class="kw">use </span>mio::{Poll, Events, Interest, Token};
|
||||
<span class="kw">use </span>mio::unix::pipe;
|
||||
|
||||
<span class="comment">// Unique tokens for the two ends of the channel.
|
||||
</span><span class="kw">const </span>PIPE_RECV: Token = Token(<span class="number">0</span>);
|
||||
<span class="kw">const </span>PIPE_SEND: Token = Token(<span class="number">1</span>);
|
||||
|
||||
<span class="comment">// Create our `Poll` instance and the `Events` container.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>poll = Poll::new()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>events = Events::with_capacity(<span class="number">8</span>);
|
||||
|
||||
<span class="comment">// Create a new pipe.
|
||||
</span><span class="kw">let </span>(<span class="kw-2">mut </span>sender, <span class="kw-2">mut </span>receiver) = pipe::new()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Register both ends of the channel.
|
||||
</span>poll.registry().register(<span class="kw-2">&mut </span>receiver, PIPE_RECV, Interest::READABLE)<span class="question-mark">?</span>;
|
||||
poll.registry().register(<span class="kw-2">&mut </span>sender, PIPE_SEND, Interest::WRITABLE)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">const </span>MSG: <span class="kw-2">&</span>[u8; <span class="number">11</span>] = <span class="string">b"Hello world"</span>;
|
||||
|
||||
<span class="kw">loop </span>{
|
||||
poll.poll(<span class="kw-2">&mut </span>events, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">for </span>event <span class="kw">in </span>events.iter() {
|
||||
<span class="kw">match </span>event.token() {
|
||||
PIPE_SEND => sender.write(MSG)
|
||||
.and_then(|n| <span class="kw">if </span>n != MSG.len() {
|
||||
<span class="comment">// We'll consider a short write an error in this
|
||||
// example. NOTE: we can't use `write_all` with
|
||||
// non-blocking I/O.
|
||||
</span><span class="prelude-val">Err</span>(io::ErrorKind::WriteZero.into())
|
||||
} <span class="kw">else </span>{
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
})<span class="question-mark">?</span>,
|
||||
PIPE_RECV => {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0</span>; <span class="number">11</span>];
|
||||
<span class="kw">let </span>n = receiver.read(<span class="kw-2">&mut </span>buf)<span class="question-mark">?</span>;
|
||||
<span class="macro">println!</span>(<span class="string">"received: {:?}"</span>, <span class="kw-2">&</span>buf[<span class="number">0</span>..n]);
|
||||
<span class="macro">assert_eq!</span>(n, MSG.len());
|
||||
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>buf, <span class="kw-2">&*</span>MSG);
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>(());
|
||||
},
|
||||
<span class="kw">_ </span>=> <span class="macro">unreachable!</span>(),
|
||||
}
|
||||
}
|
||||
}</code></pre></div>
|
||||
<p>Example that receives an event once the <code>Sender</code> is dropped.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Same setup as in the example above.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>poll = Poll::new()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>events = Events::with_capacity(<span class="number">8</span>);
|
||||
|
||||
<span class="kw">let </span>(<span class="kw-2">mut </span>sender, <span class="kw-2">mut </span>receiver) = pipe::new()<span class="question-mark">?</span>;
|
||||
|
||||
poll.registry().register(<span class="kw-2">&mut </span>receiver, PIPE_RECV, Interest::READABLE)<span class="question-mark">?</span>;
|
||||
poll.registry().register(<span class="kw-2">&mut </span>sender, PIPE_SEND, Interest::WRITABLE)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Drop the sender.
|
||||
</span>drop(sender);
|
||||
|
||||
poll.poll(<span class="kw-2">&mut </span>events, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">for </span>event <span class="kw">in </span>events.iter() {
|
||||
<span class="kw">match </span>event.token() {
|
||||
PIPE_RECV <span class="kw">if </span>event.is_read_closed() => {
|
||||
<span class="comment">// Detected that the sender was dropped.
|
||||
</span><span class="macro">println!</span>(<span class="string">"Sender dropped!"</span>);
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>(());
|
||||
},
|
||||
<span class="kw">_ </span>=> <span class="macro">unreachable!</span>(),
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
3
mio/unix/pipe/index.html
Normal file
3
mio/unix/pipe/index.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!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="Unix pipe."><title>mio::unix::pipe - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="mio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../mio/index.html">mio</a><span class="version">1.0.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module pipe</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In mio::<wbr>unix</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">mio</a>::<wbr><a href="../index.html">unix</a></span><h1>Module <span>pipe</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/mio/lib.rs.html#77">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Unix pipe.</p>
|
||||
<p>See the <a href="fn.new.html" title="fn mio::unix::pipe::new"><code>new</code></a> function for documentation.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Receiver.html" title="struct mio::unix::pipe::Receiver">Receiver</a></div><div class="desc docblock-short">Receiving end of an Unix pipe.</div></li><li><div class="item-name"><a class="struct" href="struct.Sender.html" title="struct mio::unix::pipe::Sender">Sender</a></div><div class="desc docblock-short">Sending end of an Unix pipe.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.new.html" title="fn mio::unix::pipe::new">new</a></div><div class="desc docblock-short">Create a new non-blocking Unix pipe.</div></li></ul></section></div></main></body></html>
|
||||
1
mio/unix/pipe/sidebar-items.js
Normal file
1
mio/unix/pipe/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["new"],"struct":["Receiver","Sender"]};
|
||||
92
mio/unix/pipe/struct.Receiver.html
Normal file
92
mio/unix/pipe/struct.Receiver.html
Normal file
File diff suppressed because one or more lines are too long
84
mio/unix/pipe/struct.Sender.html
Normal file
84
mio/unix/pipe/struct.Sender.html
Normal file
File diff suppressed because one or more lines are too long
1
mio/unix/sidebar-items.js
Normal file
1
mio/unix/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"mod":["pipe"],"struct":["SourceFd"]};
|
||||
79
mio/unix/struct.SourceFd.html
Normal file
79
mio/unix/struct.SourceFd.html
Normal file
File diff suppressed because one or more lines are too long
11
mio/waker/struct.Waker.html
Normal file
11
mio/waker/struct.Waker.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../mio/struct.Waker.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../mio/struct.Waker.html">../../mio/struct.Waker.html</a>...</p>
|
||||
<script>location.replace("../../mio/struct.Waker.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue