index.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="generator" content="rustdoc">
  7. <meta name="description" content="API documentation for the Rust `future` mod in crate `futures`.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, future">
  9. <title>futures::future - Rust</title>
  10. <link rel="stylesheet" type="text/css" href="../../normalize.css">
  11. <link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
  12. <link rel="stylesheet" type="text/css" href="../../dark.css">
  13. <link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
  14. <script src="../../storage.js"></script>
  15. </head>
  16. <body class="rustdoc mod">
  17. <!--[if lte IE 8]>
  18. <div class="warning">
  19. This old browser is unsupported and will most likely display funky
  20. things.
  21. </div>
  22. <![endif]-->
  23. <nav class="sidebar">
  24. <div class="sidebar-menu">&#9776;</div>
  25. <p class='location'>Module future</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>futures</a></p><script>window.sidebarCurrent = {name: 'future', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div>
  26. </nav>
  27. <div class="theme-picker">
  28. <button id="theme-picker" aria-label="Pick another theme!">
  29. <img src="../../brush.svg" width="18" alt="Pick another theme!">
  30. </button>
  31. <div id="theme-choices"></div>
  32. </div>
  33. <script src="../../theme.js"></script>
  34. <nav class="sub">
  35. <form class="search-form js-only">
  36. <div class="search-container">
  37. <input class="search-input" name="search"
  38. autocomplete="off"
  39. placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
  40. type="search">
  41. </div>
  42. </form>
  43. </nav>
  44. <section id='main' class="content">
  45. <h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>futures</a>::<wbr><a class="mod" href=''>future</a></span><span class='out-of-band'><span id='render-detail'>
  46. <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
  47. [<span class='inner'>&#x2212;</span>]
  48. </a>
  49. </span><a class='srclink' href='../../src/futures/future/mod.rs.html#1-1170' title='goto source code'>[src]</a></span></h1>
  50. <div class='docblock'><p>Futures</p>
  51. <p>This module contains the <code>Future</code> trait and a number of adaptors for this
  52. trait. See the crate docs, and the docs for <code>Future</code>, for full detail.</p>
  53. </div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
  54. <table>
  55. <tr class=' module-item'>
  56. <td><a class="struct" href="struct.AndThen.html"
  57. title='struct futures::future::AndThen'>AndThen</a></td>
  58. <td class='docblock-short'>
  59. <p>Future for the <code>and_then</code> combinator, chaining a computation onto the end of
  60. another future which completes successfully.</p>
  61. </td>
  62. </tr>
  63. <tr class=' module-item'>
  64. <td><a class="struct" href="struct.CatchUnwind.html"
  65. title='struct futures::future::CatchUnwind'>CatchUnwind</a></td>
  66. <td class='docblock-short'>
  67. <p>Future for the <code>catch_unwind</code> combinator.</p>
  68. </td>
  69. </tr>
  70. <tr class=' module-item'>
  71. <td><a class="struct" href="struct.Empty.html"
  72. title='struct futures::future::Empty'>Empty</a></td>
  73. <td class='docblock-short'>
  74. <p>A future which is never resolved.</p>
  75. </td>
  76. </tr>
  77. <tr class=' module-item'>
  78. <td><a class="struct" href="struct.ExecuteError.html"
  79. title='struct futures::future::ExecuteError'>ExecuteError</a></td>
  80. <td class='docblock-short'>
  81. <p>Errors returned from the <code>Spawn::spawn</code> function.</p>
  82. </td>
  83. </tr>
  84. <tr class=' module-item'>
  85. <td><a class="struct" href="struct.Flatten.html"
  86. title='struct futures::future::Flatten'>Flatten</a></td>
  87. <td class='docblock-short'>
  88. <p>Future for the <code>flatten</code> combinator, flattening a future-of-a-future to get just
  89. the result of the final future.</p>
  90. </td>
  91. </tr>
  92. <tr class=' module-item'>
  93. <td><a class="struct" href="struct.FlattenStream.html"
  94. title='struct futures::future::FlattenStream'>FlattenStream</a></td>
  95. <td class='docblock-short'>
  96. <p>Future for the <code>flatten_stream</code> combinator, flattening a
  97. future-of-a-stream to get just the result of the final stream as a stream.</p>
  98. </td>
  99. </tr>
  100. <tr class=' module-item'>
  101. <td><a class="struct" href="struct.FromErr.html"
  102. title='struct futures::future::FromErr'>FromErr</a></td>
  103. <td class='docblock-short'>
  104. <p>Future for the <code>from_err</code> combinator, changing the error type of a future.</p>
  105. </td>
  106. </tr>
  107. <tr class=' module-item'>
  108. <td><a class="struct" href="struct.Fuse.html"
  109. title='struct futures::future::Fuse'>Fuse</a></td>
  110. <td class='docblock-short'>
  111. <p>A future which &quot;fuses&quot; a future once it's been resolved.</p>
  112. </td>
  113. </tr>
  114. <tr class=' module-item'>
  115. <td><a class="struct" href="struct.FutureResult.html"
  116. title='struct futures::future::FutureResult'>FutureResult</a></td>
  117. <td class='docblock-short'>
  118. <p>A future representing a value that is immediately ready.</p>
  119. </td>
  120. </tr>
  121. <tr class=' module-item'>
  122. <td><a class="struct" href="struct.Inspect.html"
  123. title='struct futures::future::Inspect'>Inspect</a></td>
  124. <td class='docblock-short'>
  125. <p>Do something with the item of a future, passing it on.</p>
  126. </td>
  127. </tr>
  128. <tr class=' module-item'>
  129. <td><a class="struct" href="struct.IntoStream.html"
  130. title='struct futures::future::IntoStream'>IntoStream</a></td>
  131. <td class='docblock-short'>
  132. <p>Future that forwards one element from the underlying future
  133. (whether it is success of error) and emits EOF after that.</p>
  134. </td>
  135. </tr>
  136. <tr class=' module-item'>
  137. <td><a class="struct" href="struct.Join.html"
  138. title='struct futures::future::Join'>Join</a></td>
  139. <td class='docblock-short'>
  140. <p>Future for the <code>join</code> combinator, waiting for two futures to
  141. complete.</p>
  142. </td>
  143. </tr>
  144. <tr class=' module-item'>
  145. <td><a class="struct" href="struct.Join3.html"
  146. title='struct futures::future::Join3'>Join3</a></td>
  147. <td class='docblock-short'>
  148. <p>Future for the <code>join3</code> combinator, waiting for three futures to
  149. complete.</p>
  150. </td>
  151. </tr>
  152. <tr class=' module-item'>
  153. <td><a class="struct" href="struct.Join4.html"
  154. title='struct futures::future::Join4'>Join4</a></td>
  155. <td class='docblock-short'>
  156. <p>Future for the <code>join4</code> combinator, waiting for four futures to
  157. complete.</p>
  158. </td>
  159. </tr>
  160. <tr class=' module-item'>
  161. <td><a class="struct" href="struct.Join5.html"
  162. title='struct futures::future::Join5'>Join5</a></td>
  163. <td class='docblock-short'>
  164. <p>Future for the <code>join5</code> combinator, waiting for five futures to
  165. complete.</p>
  166. </td>
  167. </tr>
  168. <tr class=' module-item'>
  169. <td><a class="struct" href="struct.JoinAll.html"
  170. title='struct futures::future::JoinAll'>JoinAll</a></td>
  171. <td class='docblock-short'>
  172. <p>A future which takes a list of futures and resolves with a vector of the
  173. completed values.</p>
  174. </td>
  175. </tr>
  176. <tr class=' module-item'>
  177. <td><a class="struct" href="struct.Lazy.html"
  178. title='struct futures::future::Lazy'>Lazy</a></td>
  179. <td class='docblock-short'>
  180. <p>A future which defers creation of the actual future until a callback is
  181. scheduled.</p>
  182. </td>
  183. </tr>
  184. <tr class=' module-item'>
  185. <td><a class="struct" href="struct.LoopFn.html"
  186. title='struct futures::future::LoopFn'>LoopFn</a></td>
  187. <td class='docblock-short'>
  188. <p>A future implementing a tail-recursive loop.</p>
  189. </td>
  190. </tr>
  191. <tr class=' module-item'>
  192. <td><a class="struct" href="struct.Map.html"
  193. title='struct futures::future::Map'>Map</a></td>
  194. <td class='docblock-short'>
  195. <p>Future for the <code>map</code> combinator, changing the type of a future.</p>
  196. </td>
  197. </tr>
  198. <tr class=' module-item'>
  199. <td><a class="struct" href="struct.MapErr.html"
  200. title='struct futures::future::MapErr'>MapErr</a></td>
  201. <td class='docblock-short'>
  202. <p>Future for the <code>map_err</code> combinator, changing the error type of a future.</p>
  203. </td>
  204. </tr>
  205. <tr class=' module-item'>
  206. <td><a class="struct" href="struct.OrElse.html"
  207. title='struct futures::future::OrElse'>OrElse</a></td>
  208. <td class='docblock-short'>
  209. <p>Future for the <code>or_else</code> combinator, chaining a computation onto the end of
  210. a future which fails with an error.</p>
  211. </td>
  212. </tr>
  213. <tr class=' module-item'>
  214. <td><a class="struct" href="struct.PollFn.html"
  215. title='struct futures::future::PollFn'>PollFn</a></td>
  216. <td class='docblock-short'>
  217. <p>A future which adapts a function returning <code>Poll</code>.</p>
  218. </td>
  219. </tr>
  220. <tr class=' module-item'>
  221. <td><a class="struct" href="struct.Select.html"
  222. title='struct futures::future::Select'>Select</a></td>
  223. <td class='docblock-short'>
  224. <p>Future for the <code>select</code> combinator, waiting for one of two futures to
  225. complete.</p>
  226. </td>
  227. </tr>
  228. <tr class=' module-item'>
  229. <td><a class="struct" href="struct.Select2.html"
  230. title='struct futures::future::Select2'>Select2</a></td>
  231. <td class='docblock-short'>
  232. <p>Future for the <code>select2</code> combinator, waiting for one of two differently-typed
  233. futures to complete.</p>
  234. </td>
  235. </tr>
  236. <tr class=' module-item'>
  237. <td><a class="struct" href="struct.SelectAll.html"
  238. title='struct futures::future::SelectAll'>SelectAll</a></td>
  239. <td class='docblock-short'>
  240. <p>Future for the <code>select_all</code> combinator, waiting for one of any of a list of
  241. futures to complete.</p>
  242. </td>
  243. </tr>
  244. <tr class=' module-item'>
  245. <td><a class="struct" href="struct.SelectNext.html"
  246. title='struct futures::future::SelectNext'>SelectNext</a></td>
  247. <td class='docblock-short'>
  248. <p>Future yielded as the second result in a <code>Select</code> future.</p>
  249. </td>
  250. </tr>
  251. <tr class=' module-item'>
  252. <td><a class="struct" href="struct.SelectOk.html"
  253. title='struct futures::future::SelectOk'>SelectOk</a></td>
  254. <td class='docblock-short'>
  255. <p>Future for the <code>select_ok</code> combinator, waiting for one of any of a list of
  256. futures to successfully complete. Unlike <code>select_all</code>, this future ignores all
  257. but the last error, if there are any.</p>
  258. </td>
  259. </tr>
  260. <tr class=' module-item'>
  261. <td><a class="struct" href="struct.Shared.html"
  262. title='struct futures::future::Shared'>Shared</a></td>
  263. <td class='docblock-short'>
  264. <p>A future that is cloneable and can be polled in multiple threads.
  265. Use <code>Future::shared()</code> method to convert any future into a <code>Shared</code> future.</p>
  266. </td>
  267. </tr>
  268. <tr class=' module-item'>
  269. <td><a class="struct" href="struct.SharedError.html"
  270. title='struct futures::future::SharedError'>SharedError</a></td>
  271. <td class='docblock-short'>
  272. <p>A wrapped error of the original future that is cloneable and implements Deref
  273. for ease of use.</p>
  274. </td>
  275. </tr>
  276. <tr class=' module-item'>
  277. <td><a class="struct" href="struct.SharedItem.html"
  278. title='struct futures::future::SharedItem'>SharedItem</a></td>
  279. <td class='docblock-short'>
  280. <p>A wrapped item of the original future that is cloneable and implements Deref
  281. for ease of use.</p>
  282. </td>
  283. </tr>
  284. <tr class=' module-item'>
  285. <td><a class="struct" href="struct.Then.html"
  286. title='struct futures::future::Then'>Then</a></td>
  287. <td class='docblock-short'>
  288. <p>Future for the <code>then</code> combinator, chaining computations on the end of
  289. another future regardless of its outcome.</p>
  290. </td>
  291. </tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
  292. <table>
  293. <tr class=' module-item'>
  294. <td><a class="enum" href="enum.Either.html"
  295. title='enum futures::future::Either'>Either</a></td>
  296. <td class='docblock-short'>
  297. <p>Combines two different futures yielding the same item and error
  298. types into a single type.</p>
  299. </td>
  300. </tr>
  301. <tr class=' module-item'>
  302. <td><a class="enum" href="enum.ExecuteErrorKind.html"
  303. title='enum futures::future::ExecuteErrorKind'>ExecuteErrorKind</a></td>
  304. <td class='docblock-short'>
  305. <p>Kinds of errors that can be returned from the <code>Execute::spawn</code> function.</p>
  306. </td>
  307. </tr>
  308. <tr class=' module-item'>
  309. <td><a class="enum" href="enum.Loop.html"
  310. title='enum futures::future::Loop'>Loop</a></td>
  311. <td class='docblock-short'>
  312. <p>The status of a <code>loop_fn</code> loop.</p>
  313. </td>
  314. </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
  315. <table>
  316. <tr class=' module-item'>
  317. <td><a class="trait" href="trait.Executor.html"
  318. title='trait futures::future::Executor'>Executor</a></td>
  319. <td class='docblock-short'>
  320. <p>A trait for types which can spawn fresh futures.</p>
  321. </td>
  322. </tr>
  323. <tr class=' module-item'>
  324. <td><a class="trait" href="trait.Future.html"
  325. title='trait futures::future::Future'>Future</a></td>
  326. <td class='docblock-short'>
  327. <p>Trait for types which are a placeholder of a value that may become
  328. available at some later point in time.</p>
  329. </td>
  330. </tr>
  331. <tr class=' module-item'>
  332. <td><a class="trait" href="trait.FutureFrom.html"
  333. title='trait futures::future::FutureFrom'>FutureFrom</a></td>
  334. <td class='docblock-short'>
  335. <p>Asynchronous conversion from a type <code>T</code>.</p>
  336. </td>
  337. </tr>
  338. <tr class=' module-item'>
  339. <td><a class="trait" href="trait.IntoFuture.html"
  340. title='trait futures::future::IntoFuture'>IntoFuture</a></td>
  341. <td class='docblock-short'>
  342. <p>Class of types which can be converted into a future.</p>
  343. </td>
  344. </tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
  345. <table>
  346. <tr class=' module-item'>
  347. <td><a class="fn" href="fn.empty.html"
  348. title='fn futures::future::empty'>empty</a></td>
  349. <td class='docblock-short'>
  350. <p>Creates a future which never resolves, representing a computation that never
  351. finishes.</p>
  352. </td>
  353. </tr>
  354. <tr class=' module-item'>
  355. <td><a class="fn" href="fn.err.html"
  356. title='fn futures::future::err'>err</a></td>
  357. <td class='docblock-short'>
  358. <p>Creates a &quot;leaf future&quot; from an immediate value of a failed computation.</p>
  359. </td>
  360. </tr>
  361. <tr class=' module-item'>
  362. <td><a class="fn" href="fn.join_all.html"
  363. title='fn futures::future::join_all'>join_all</a></td>
  364. <td class='docblock-short'>
  365. <p>Creates a future which represents a collection of the results of the futures
  366. given.</p>
  367. </td>
  368. </tr>
  369. <tr class=' module-item'>
  370. <td><a class="fn" href="fn.lazy.html"
  371. title='fn futures::future::lazy'>lazy</a></td>
  372. <td class='docblock-short'>
  373. <p>Creates a new future which will eventually be the same as the one created
  374. by the closure provided.</p>
  375. </td>
  376. </tr>
  377. <tr class=' module-item'>
  378. <td><a class="fn" href="fn.loop_fn.html"
  379. title='fn futures::future::loop_fn'>loop_fn</a></td>
  380. <td class='docblock-short'>
  381. <p>Creates a new future implementing a tail-recursive loop.</p>
  382. </td>
  383. </tr>
  384. <tr class=' module-item'>
  385. <td><a class="fn" href="fn.ok.html"
  386. title='fn futures::future::ok'>ok</a></td>
  387. <td class='docblock-short'>
  388. <p>Creates a &quot;leaf future&quot; from an immediate value of a finished and
  389. successful computation.</p>
  390. </td>
  391. </tr>
  392. <tr class=' module-item'>
  393. <td><a class="fn" href="fn.poll_fn.html"
  394. title='fn futures::future::poll_fn'>poll_fn</a></td>
  395. <td class='docblock-short'>
  396. <p>Creates a new future wrapping around a function returning <code>Poll</code>.</p>
  397. </td>
  398. </tr>
  399. <tr class=' module-item'>
  400. <td><a class="fn" href="fn.result.html"
  401. title='fn futures::future::result'>result</a></td>
  402. <td class='docblock-short'>
  403. <p>Creates a new &quot;leaf future&quot; which will resolve with the given result.</p>
  404. </td>
  405. </tr>
  406. <tr class=' module-item'>
  407. <td><a class="fn" href="fn.select_all.html"
  408. title='fn futures::future::select_all'>select_all</a></td>
  409. <td class='docblock-short'>
  410. <p>Creates a new future which will select over a list of futures.</p>
  411. </td>
  412. </tr>
  413. <tr class=' module-item'>
  414. <td><a class="fn" href="fn.select_ok.html"
  415. title='fn futures::future::select_ok'>select_ok</a></td>
  416. <td class='docblock-short'>
  417. <p>Creates a new future which will select the first successful future over a list of futures.</p>
  418. </td>
  419. </tr></table></section>
  420. <section id='search' class="content hidden"></section>
  421. <section class="footer"></section>
  422. <aside id="help" class="hidden">
  423. <div>
  424. <h1 class="hidden">Help</h1>
  425. <div class="shortcuts">
  426. <h2>Keyboard Shortcuts</h2>
  427. <dl>
  428. <dt><kbd>?</kbd></dt>
  429. <dd>Show this help dialog</dd>
  430. <dt><kbd>S</kbd></dt>
  431. <dd>Focus the search field</dd>
  432. <dt><kbd>↑</kbd></dt>
  433. <dd>Move up in search results</dd>
  434. <dt><kbd>↓</kbd></dt>
  435. <dd>Move down in search results</dd>
  436. <dt><kbd>↹</kbd></dt>
  437. <dd>Switch tab</dd>
  438. <dt><kbd>&#9166;</kbd></dt>
  439. <dd>Go to active search result</dd>
  440. <dt><kbd>+</kbd></dt>
  441. <dd>Expand all sections</dd>
  442. <dt><kbd>-</kbd></dt>
  443. <dd>Collapse all sections</dd>
  444. </dl>
  445. </div>
  446. <div class="infos">
  447. <h2>Search Tricks</h2>
  448. <p>
  449. Prefix searches with a type followed by a colon (e.g.
  450. <code>fn:</code>) to restrict the search to a given type.
  451. </p>
  452. <p>
  453. Accepted types are: <code>fn</code>, <code>mod</code>,
  454. <code>struct</code>, <code>enum</code>,
  455. <code>trait</code>, <code>type</code>, <code>macro</code>,
  456. and <code>const</code>.
  457. </p>
  458. <p>
  459. Search functions by type signature (e.g.
  460. <code>vec -> usize</code> or <code>* -> vec</code>)
  461. </p>
  462. </div>
  463. </div>
  464. </aside>
  465. <script>
  466. window.rootPath = "../../";
  467. window.currentCrate = "futures";
  468. </script>
  469. <script src="../../main.js"></script>
  470. <script defer src="../../search-index.js"></script>
  471. </body>
  472. </html>