1
0
mirror of https://github.com/actix/actix-website synced 2024-12-04 20:51:54 +01:00
actix-website/static/img/diagrams/cheatsheet-for-futures.html
2018-05-22 23:15:08 +02:00

53 lines
13 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Cheatsheet for Futures</title>
</head>
<body><pre style="margin: 0"><code style="background: transparent"><span style="color: #8e908c">// Constructing leaf futures</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.empty.html">empty</a> () -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.ok.html">ok</a> (<var>T</var>) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.err.html">err</a> (<var>E</var>) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.result.html">result</a>(<span style="color: #4271ae">Result</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8e908c">// General future constructor</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.poll_fn.html">poll_fn</a>(<span style="color: #8959a8">FnMut</span>(<span style="color: #3e999f">thread_local!</span>(<span style="color: #4271ae">Task</span>)) -&gt; <span style="color: #4271ae">Poll</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8e908c">// Mapping futures</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.map">Future::map</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #8959a8">FnOnce</span>(<var>T</var>) -&gt; <var>U</var>) -&gt; <span style="color: #c82829">Future</span>&lt;<var>U</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.map_err">Future::map_err</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #8959a8">FnOnce</span>(<var>E</var>) -&gt; <var>F</var>) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>F</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.from_err">Future::from_err</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <span style="color: #4271ae">Into</span>&lt;<var>E</var>&gt;&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8e908c">// Chaining (sequencing) futures</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.then">Future::then</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #8959a8">FnOnce</span>(<span style="color: #4271ae">Result</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>F</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>U</var>, <var>F</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.and_then">Future::and_then</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #8959a8">FnOnce</span>(<var>T</var>) -&gt; <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>U</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.or_else">Future::or_else</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #8959a8">FnOnce</span>(<var>E</var>) -&gt; <span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>F</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>F</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.flatten">Future::flatten</a> (<span style="color: #c82829">Future</span>&lt;<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #4271ae">Into</span>&lt;<var>E</var>&gt;&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8e908c">// Joining (waiting) futures</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.join">Future::join</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <var>U</var>), <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.join3">Future::join3</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>V</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <var>U</var>, <var>V</var>), <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.join4">Future::join4</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>V</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>W</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <var>U</var>, <var>V</var>, <var>W</var>), <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.join5">Future::join5</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>V</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>W</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>X</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <var>U</var>, <var>V</var>, <var>W</var>, <var>X</var>), <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.join_all.html">join_all</a> (<span style="color: #4271ae">IntoIterator</span>&lt;<span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<span style="color: #4271ae">Vec</span>&lt;<var>T</var>&gt;, <var>E</var>&gt;
<span style="color: #8e908c">// Selecting (racing) futures</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.select">Future::select</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;), (<var>E</var>, <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;)&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.select2">Future::select2</a>(<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #c82829">IntoFuture</span>&lt;<var>U</var>, <var>F</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<span style="color: #4271ae">Either</span>&lt;(<var>T</var>, <span style="color: #c82829">Future</span>&lt;<var>U</var>, <var>F</var>&gt;), (<var>U</var>, <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;)&gt;, <span style="color: #4271ae">Either</span>&lt;(<var>E</var>, <span style="color: #c82829">Future</span>&lt;<var>U</var>, <var>F</var>&gt;), (<var>F</var>, <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;)&gt;&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.select_all.html">select_all</a> (<span style="color: #4271ae">IntoIterator</span>&lt;<span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <span style="color: #4271ae">usize</span>, <span style="color: #4271ae">Vec</span>&lt;<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;), (<var>E</var>, <span style="color: #4271ae">usize</span>, <span style="color: #4271ae">Vec</span>&lt;<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;)&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.select_ok.html">select_ok</a> (<span style="color: #4271ae">IntoIterator</span>&lt;<span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;(<var>T</var>, <span style="color: #4271ae">Vec</span>&lt;<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;&gt;), <var>E</var>&gt;
<span style="color: #8e908c">// Utility</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.lazy.html">lazy</a> (<span style="color: #8959a8">FnOnce</span>() -&gt; <span style="color: #c82829">IntoFuture</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/fn.loop_fn.html">loop_fn</a> (<var>S</var>, <span style="color: #8959a8">FnMut</span>(<var>S</var>) -&gt; <span style="color: #c82829">IntoFuture</span>&lt;<span style="color: #4271ae">Loop</span>&lt;<var>T</var>, <var>S</var>&gt;, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8e908c">// Miscellaneous</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.into_stream">Future::into_stream</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #4271ae">Stream</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.flatten_stream">Future::flatten_stream</a>(<span style="color: #c82829">Future</span>&lt;<span style="color: #4271ae">Stream</span>&lt;<var>T</var>, <var>E</var>&gt;, <var>E</var>&gt;) -&gt; <span style="color: #4271ae">Stream</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.fuse">Future::fuse</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.catch_unwind">Future::catch_unwind</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;+<span style="color: #4271ae">UnwindSafe</span>) -&gt; <span style="color: #c82829">Future</span>&lt;<span style="color: #4271ae">Result</span>&lt;<var>T</var>, <var>E</var>&gt;, <span style="color: #4271ae">Any</span>+<span style="color: #4271ae">Send</span>&gt;
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.shared">Future::shared</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #c82829">Future</span>&lt;<span style="color: #4271ae">SharedItem</span>&lt;<var>T</var>&gt;, <span style="color: #4271ae">SharedError</span>&lt;<var>E</var>&gt;&gt;+<span style="color: #4271ae">Clone</span>
<span style="color: #8959a8">fn</span> <a href="https://docs.rs/futures/0.1.13/futures/future/trait.Future.html#method.wait">Future::wait</a> (<span style="color: #c82829">Future</span>&lt;<var>T</var>, <var>E</var>&gt;) -&gt; <span style="color: #4271ae">Result</span>&lt;<var>T</var>, <var>E</var>&gt;
</code></pre></body>
</html>