index.html 26 KB

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