mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-25 12:44:07 +01:00
48 lines
13 KiB
HTML
48 lines
13 KiB
HTML
<!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 `LocalSpawnExt` trait in crate `futures`."><meta name="keywords" content="rust, rustlang, rust-lang, LocalSpawnExt"><title>futures::task::LocalSpawnExt - 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="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../futures/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait LocalSpawnExt</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.spawn_local">spawn_local</a><a href="#method.spawn_local_with_handle">spawn_local_with_handle</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">futures</a>::<wbr><a href="index.html">task</a></p><div id="sidebar-vars" data-name="LocalSpawnExt" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<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">Trait <a href="../index.html">futures</a>::<wbr><a href="index.html">task</a>::<wbr><a class="trait" href="">LocalSpawnExt</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">−</span>]</a></span><a class="srclink" href="../../src/futures_util/task/spawn.rs.html#97-163" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait LocalSpawnExt: <a class="trait" href="../../futures/task/trait.LocalSpawn.html" title="trait futures::task::LocalSpawn">LocalSpawn</a> {
|
||
pub fn <a href="#method.spawn_local" class="fnname">spawn_local</a><Fut>(&self, future: Fut) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../futures/task/struct.SpawnError.html" title="struct futures::task::SpawnError">SpawnError</a>><br> <span class="where">where<br> Fut: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> + 'static</span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.spawn_local_with_handle" class="fnname">spawn_local_with_handle</a><Fut>(<br> &self, <br> future: Fut<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../futures/future/struct.RemoteHandle.html" title="struct futures::future::RemoteHandle">RemoteHandle</a><<Fut as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>>::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>>, <a class="struct" href="../../futures/task/struct.SpawnError.html" title="struct futures::task::SpawnError">SpawnError</a>><br> <span class="where">where<br> Fut: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> + 'static</span>,
|
||
{ ... }
|
||
}</pre></div><div class="docblock"><p>Extension trait for <code>LocalSpawn</code>.</p>
|
||
</div><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.spawn_local" class="method"><code>pub fn <a href="#method.spawn_local" class="fnname">spawn_local</a><Fut>(&self, future: Fut) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../futures/task/struct.SpawnError.html" title="struct futures::task::SpawnError">SpawnError</a>> <span class="where fmt-newline">where<br> Fut: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a><Output = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> + 'static, </span></code><a class="srclink" href="../../src/futures_util/task/spawn.rs.html#124-126" title="goto source code">[src]</a></h3><div class="docblock"><p>Spawns a task that polls the given future with output <code>()</code> to
|
||
completion.</p>
|
||
<p>This method returns a <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="Result"><code>Result</code></a> that contains a <a href="../../futures/task/struct.SpawnError.html" title="SpawnError"><code>SpawnError</code></a> if
|
||
spawning fails.</p>
|
||
<p>You can use <a href="../../futures/task/trait.SpawnExt.html#method.spawn_with_handle"><code>spawn_with_handle</code></a> if
|
||
you want to spawn a future with output other than <code>()</code> or if you want
|
||
to be able to await its completion.</p>
|
||
<p>Note this method will eventually be replaced with the upcoming
|
||
<code>Spawn::spawn</code> method which will take a <code>dyn Future</code> as input.
|
||
Technical limitations prevent <code>Spawn::spawn</code> from being implemented
|
||
today. Feel free to use this method in the meantime.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">executor</span>::<span class="ident">LocalPool</span>;
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">task</span>::<span class="ident">LocalSpawnExt</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">executor</span> <span class="op">=</span> <span class="ident">LocalPool</span>::<span class="ident">new</span>();
|
||
<span class="kw">let</span> <span class="ident">spawner</span> <span class="op">=</span> <span class="ident">executor</span>.<span class="ident">spawner</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="comment">/* ... */</span> };
|
||
<span class="ident">spawner</span>.<span class="ident">spawn_local</span>(<span class="ident">future</span>).<span class="ident">unwrap</span>();</pre></div>
|
||
</div><h3 id="method.spawn_local_with_handle" class="method"><code>pub fn <a href="#method.spawn_local_with_handle" class="fnname">spawn_local_with_handle</a><Fut>(<br> &self, <br> future: Fut<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../futures/future/struct.RemoteHandle.html" title="struct futures::future::RemoteHandle">RemoteHandle</a><<Fut as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>>::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>>, <a class="struct" href="../../futures/task/struct.SpawnError.html" title="struct futures::task::SpawnError">SpawnError</a>> <span class="where fmt-newline">where<br> Fut: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> + 'static, </span></code><a class="srclink" href="../../src/futures_util/task/spawn.rs.html#152-157" title="goto source code">[src]</a></h3><div class="docblock"><p>Spawns a task that polls the given future to completion and returns a
|
||
future that resolves to the spawned future's output.</p>
|
||
<p>This method returns a <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="Result"><code>Result</code></a> that contains a <a href="../../futures/future/struct.RemoteHandle.html"><code>RemoteHandle</code></a>, or, if
|
||
spawning fails, a <a href="../../futures/task/struct.SpawnError.html" title="SpawnError"><code>SpawnError</code></a>. <a href="../../futures/future/struct.RemoteHandle.html"><code>RemoteHandle</code></a> is a future that
|
||
resolves to the output of the spawned future.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">executor</span>::<span class="ident">LocalPool</span>;
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">task</span>::<span class="ident">LocalSpawnExt</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">executor</span> <span class="op">=</span> <span class="ident">LocalPool</span>::<span class="ident">new</span>();
|
||
<span class="kw">let</span> <span class="ident">spawner</span> <span class="op">=</span> <span class="ident">executor</span>.<span class="ident">spawner</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="number">1</span> };
|
||
<span class="kw">let</span> <span class="ident">join_handle_fut</span> <span class="op">=</span> <span class="ident">spawner</span>.<span class="ident">spawn_local_with_handle</span>(<span class="ident">future</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">executor</span>.<span class="ident">run_until</span>(<span class="ident">join_handle_fut</span>), <span class="number">1</span>);</pre></div>
|
||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-LocalSpawnExt" class="impl"><code class="in-band">impl<Sp> LocalSpawnExt for Sp <span class="where fmt-newline">where<br> Sp: <a class="trait" href="../../futures/task/trait.LocalSpawn.html" title="trait futures::task::LocalSpawn">LocalSpawn</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-LocalSpawnExt" class="anchor"></a><a class="srclink" href="../../src/futures_util/task/spawn.rs.html#17" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/futures_util/task/spawn/trait.LocalSpawnExt.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="futures"></div>
|
||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |