mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
74 lines
36 KiB
HTML
74 lines
36 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 `AsyncWriteExt` trait in crate `futures`."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncWriteExt"><title>futures::io::AsyncWriteExt - 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 AsyncWriteExt</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.write">write</a><a href="#method.close">close</a><a href="#method.flush">flush</a><a href="#method.into_sink">into_sink</a><a href="#method.write_vectored">write_vectored</a><a href="#method.write_all">write_all</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">io</a></p><div id="sidebar-vars" data-name="AsyncWriteExt" 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">io</a>::<wbr><a class="trait" href="">AsyncWriteExt</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/io/mod.rs.html#406-588" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AsyncWriteExt: <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> {
|
||
pub fn <a href="#method.flush" class="fnname">flush</a>(&mut self) -> <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.close" class="fnname">close</a>(&mut self) -> <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.write" class="fnname">write</a>(&'a mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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.usize.html">usize</a>, <a class="struct" href="../../futures/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.write_vectored" class="fnname">write_vectored</a>(<br> &'a mut self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="struct" href="../../futures/io/struct.IoSlice.html" title="struct futures::io::IoSlice">IoSlice</a><'a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br> ) -> <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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.usize.html">usize</a>, <a class="struct" href="../../futures/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.write_all" class="fnname">write_all</a>(&'a mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
|
||
{ ... }
|
||
<div class="item-spacer"></div> pub fn <a href="#method.into_sink" class="fnname">into_sink</a><Item>(self) -> <a class="struct" href="../../futures/io/struct.IntoSink.html" title="struct futures::io::IntoSink">IntoSink</a><Self, Item><br> <span class="where">where<br> Item: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>></span>,
|
||
{ ... }
|
||
}</pre></div><div class="docblock"><p>An extension trait which adds utility methods to <code>AsyncWrite</code> types.</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.flush" class="method"><code>pub fn <a href="#method.flush" class="fnname">flush</a>(&mut self) -> <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Flush.html" title="struct futures::io::Flush">Flush</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#429-430" title="goto source code">[src]</a></h3><div class="docblock"><p>Creates a future which will entirely flush this <code>AsyncWrite</code>.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">io</span>::{<span class="ident">AllowStdIo</span>, <span class="ident">AsyncWriteExt</span>};
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::{<span class="ident">BufWriter</span>, <span class="ident">Cursor</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">5</span>];
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="ident">writer</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">output</span>);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buffered</span> <span class="op">=</span> <span class="ident">AllowStdIo</span>::<span class="ident">new</span>(<span class="ident">BufWriter</span>::<span class="ident">new</span>(<span class="ident">writer</span>));
|
||
<span class="ident">buffered</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>]).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
<span class="ident">buffered</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span>[<span class="number">3</span>, <span class="number">4</span>]).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
<span class="ident">buffered</span>.<span class="ident">flush</span>().<span class="kw">await</span><span class="question-mark">?</span>;
|
||
}
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">output</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">0</span>]);</pre></div>
|
||
</div><h3 id="method.close" class="method"><code>pub fn <a href="#method.close" class="fnname">close</a>(&mut self) -> <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Close.html" title="struct futures::io::Close">Close</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#436-437" title="goto source code">[src]</a></h3><div class="docblock"><p>Creates a future which will entirely close this <code>AsyncWrite</code>.</p>
|
||
</div><h3 id="method.write" class="method"><code>pub fn <a href="#method.write" class="fnname">write</a>(&'a mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.Write.html" title="struct futures::io::Write">Write</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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.usize.html">usize</a>, <a class="struct" href="../../futures/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#446-447" title="goto source code">[src]</a></h3><div class="docblock"><p>Creates a future which will write bytes from <code>buf</code> into the object.</p>
|
||
<p>The returned future will resolve to the number of bytes written once the write
|
||
operation is completed.</p>
|
||
</div><h3 id="method.write_vectored" class="method"><code>pub fn <a href="#method.write_vectored" class="fnname">write_vectored</a>(<br> &'a mut self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="struct" href="../../futures/io/struct.IoSlice.html" title="struct futures::io::IoSlice">IoSlice</a><'a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.WriteVectored.html" title="struct futures::io::WriteVectored">WriteVectored</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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.usize.html">usize</a>, <a class="struct" href="../../futures/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#457-458" title="goto source code">[src]</a></h3><div class="docblock"><p>Creates a future which will write bytes from <code>bufs</code> into the object using vectored
|
||
IO operations.</p>
|
||
<p>The returned future will resolve to the number of bytes written once the write
|
||
operation is completed.</p>
|
||
</div><h3 id="method.write_all" class="method"><code>pub fn <a href="#method.write_all" class="fnname">write_all</a>(&'a mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'a [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'a, Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'_, W></h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../futures/io/struct.WriteAll.html" title="struct futures::io::WriteAll">WriteAll</a><'_, W> <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <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/io/struct.Error.html" title="struct futures::io::Error">Error</a>>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#483-484" title="goto source code">[src]</a></h3><div class="docblock"><p>Write data into this object.</p>
|
||
<p>Creates a future that will write the entire contents of the buffer <code>buf</code> into
|
||
this <code>AsyncWrite</code>.</p>
|
||
<p>The returned future will not complete until all the data has been written.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">io</span>::{<span class="ident">AsyncWriteExt</span>, <span class="ident">Cursor</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">writer</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">5</span>]);
|
||
|
||
<span class="ident">writer</span>.<span class="ident">write_all</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">writer</span>.<span class="ident">into_inner</span>(), [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">0</span>]);</pre></div>
|
||
</div><h3 id="method.into_sink" class="method"><code>pub fn <a href="#method.into_sink" class="fnname">into_sink</a><Item>(self) -> <a class="struct" href="../../futures/io/struct.IntoSink.html" title="struct futures::io::IntoSink">IntoSink</a><Self, Item> <span class="where fmt-newline">where<br> Item: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a class="srclink" href="../../src/futures_util/io/mod.rs.html#583-584" title="goto source code">[src]</a></h3><div class="docblock"><p>Allow using an <a href="../../futures/io/trait.AsyncWrite.html" title="AsyncWrite"><code>AsyncWrite</code></a> as a <a href="../../futures/sink/trait.Sink.html"><code>Sink</code></a><code><Item: AsRef<[u8]>></code>.</p>
|
||
<p>This adapter produces a sink that will write each value passed to it
|
||
into the underlying writer.</p>
|
||
<p>Note that this function consumes the given writer, returning a wrapped
|
||
version.</p>
|
||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
|
||
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">stream</span>::{<span class="self">self</span>, <span class="ident">StreamExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">stream</span>::<span class="ident">iter</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="prelude-val">Ok</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]), <span class="prelude-val">Ok</span>([<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>])]);
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">writer</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
|
||
<span class="ident">stream</span>.<span class="ident">forward</span>((<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">writer</span>).<span class="ident">into_sink</span>()).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">writer</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</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-AsyncWriteExt" class="impl"><code class="in-band">impl<W> AsyncWriteExt for W <span class="where fmt-newline">where<br> W: <a class="trait" href="../../futures/io/trait.AsyncWrite.html" title="trait futures::io::AsyncWrite">AsyncWrite</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-AsyncWriteExt" class="anchor"></a><a class="srclink" href="../../src/futures_util/io/mod.rs.html#590" 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/io/trait.AsyncWriteExt.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> |